Ver Fonte

fix:修改动态表单弹窗增加是否编辑状态

zcuishan há 4 meses atrás
pai
commit
9d704ae820

+ 4 - 3
src/components/SimpleForm/src/components/SimpleFormItem.vue

@@ -234,7 +234,7 @@
 <script lang="ts" setup>
   import { Form, Col, Row, Tabs, TabPane, Divider } from 'ant-design-vue';
   import { isBoolean, isFunction, upperFirst, cloneDeep } from 'lodash-es';
-  import { computed, onMounted, unref, inject, Ref, watch, ref } from 'vue';
+  import { computed, onMounted, unref, inject, Ref, watch, ref, nextTick } from 'vue';
   import { componentMap } from '/@/components/Form/src/componentMap';
   import { checkedValueComponents } from '/@/components/Form/src/helper';
   import { useItemLabelWidth } from '/@/components/Form/src/hooks/useLabelWidth';
@@ -269,7 +269,6 @@
     },
     isUpdate: {
       type: Boolean,
-      default: false,
     },
   });
 
@@ -277,7 +276,6 @@
   const formProps = inject<Ref<FormProps>>('formProps');
   const tabActiveKey = inject<Ref<number>>('tabActiveKey', ref(0));
   const activeKey = ref<number>(0);
-  formModel.isUpdate = props.isUpdate;
   watch(
     () => tabActiveKey?.value,
     (val) => {
@@ -443,6 +441,9 @@
     //     emit('update:value', defaultValue);
     //   }
     // }
+    nextTick(() => {
+      formModel.isUpdate = props.isUpdate;
+    });
   });
 
   const formComponent = (schema) => {

+ 6 - 4
src/views/form/template/components/FormModal.vue

@@ -1,11 +1,11 @@
 <template>
   <BasicModal
+    destroyOnClose
     v-if="formType === 'modal'"
     v-bind="$attrs"
     @register="registerModal"
     :title="getTitle"
     @ok="handleSubmit"
-    :is-update="state.isUpdate"
     @cancel="handleClose"
     :paddingRight="15"
     :bodyStyle="{ minHeight: '400px !important' }"
@@ -18,6 +18,7 @@
     />
   </BasicModal>
   <BasicDrawer
+    destroyOnClose
     v-else
     showFooter
     v-bind="$attrs"
@@ -61,7 +62,7 @@
 
   const state = reactive({
     formModel: {},
-    isUpdate: true,
+    isUpdate: false,
     isView: false,
     isCopy: false,
     rowId: '',
@@ -73,14 +74,15 @@
   const { t } = useI18n();
 
   const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
+    console.log(data);
     if (props.formType === 'modal') {
-      handleInner(data, setModalProps);
+      await handleInner(data, setModalProps);
     }
   });
 
   const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
     if (props.formType === 'drawer') {
-      handleInner(data, setDrawerProps);
+      await handleInner(data, setDrawerProps);
     }
   });