From 0a8a3f71f2e50f0603077197d9b1971431a64b36 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 28 八月 2024 23:24:33 +0800
Subject: [PATCH] 条码规则更新

---
 src/views/components/CustModal.vue |   75 ++++++++++++++++++++++---------------
 1 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/src/views/components/CustModal.vue b/src/views/components/CustModal.vue
index efbf7eb..9f1cc14 100644
--- a/src/views/components/CustModal.vue
+++ b/src/views/components/CustModal.vue
@@ -4,7 +4,7 @@
  * @version: 
  * @Date: 2024-06-05 15:46:07
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-07-16 16:55:52
+ * @LastEditTime: 2024-08-22 12:00:25
 -->
 <template>
   <BasicModal
@@ -12,6 +12,7 @@
     @register="registerModal"
     :title="title"
     @ok="handleSuccess"
+    @cancel="handleCancel"
     :width="width"
   >
     <a-layout>
@@ -45,20 +46,18 @@
   const ALayout = Layout;
   const ACard = Card;
   const ALayoutContent = LayoutContent;
-  const emit = defineEmits(['success', 'register']);
+  const emit = defineEmits(['success', 'register', 'modalInner', 'cancel']);
   const isUpdate = ref(true);
   const cType = ref('');
   const title = ref('');
   const width = ref('');
-  const FnName = ref({});
+  const FnName = ref('');
   const mValues = ref<Recordable>({});
   const initFnName = ref({});
-  const dtlSlots = ref([] as any[]);
   const formSchema = ref([] as FormSchema[]);
   const formElName = ref([]);
   const useFormData = ref<any>({});
   const props = defineProps({
-    detailSlots: { type: Array, default: [] },
     entityName: { type: String },
   });
 
@@ -70,44 +69,50 @@
   ]);
   /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
   try {
-    custImport.value = await import(`../tigerprojects/system/lowcode/entityts/${props.entityName}.ts`);
+    custImport.value = await import(
+      `../tigerprojects/system/lowcode/entityts/${props.entityName}.ts`
+    );
   } catch (e) {}
-  const [{ CustFunc }] = isNullOrUnDef(custImport.value['default'])
+  const [{ CustFunc, GetDtlSlots }] = isNullOrUnDef(custImport.value['default'])
     ? EntityCustFunction.value
     : custImport.value['default']();
+  const dtlSlots = ref<any[]>([]);
+  // watch(
+  //   () => props.detailSlots,
+  //   (v) => {
+  //     if (v !== dtlSlots.value) {
+  //       // dtlSlots.value = v;
+  //     }
+  //   },
+  //   { deep: true },
+  // );
 
-  watch(
-    () => props.detailSlots,
-    (v) => {
-      if (v !== dtlSlots.value) {
-        dtlSlots.value = v;
-      }
-    },
-    { deep: true },
-  );
-
-  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
-    await nextTick();
+  const [registerModal, { setModalProps, closeModal }] = useModalInner((data) => {
     formSchema.value = [];
     setModalProps({ confirmLoading: false });
     isUpdate.value = !!data?.isUpdate; //鏄惁鏇存柊
     cType.value = data?.ctype; //鏄摢涓〉闈�
+    dtlSlots.value = GetDtlSlots(cType.value);
     title.value = data?.title; //寮规鏍囬
     width.value = data?.width; //寮规瀹藉害
     formElName.value = data?.formElName; //寮规涓〃鍗曞悕瀛楁暟缁�
     useFormData.value = data?.formEl; //寮规涓〃鍗曞疄渚嬫暟缁�
     FnName.value = data?.fnName; //淇濆瓨鏁版嵁鏂规硶
     mValues.value = data?.values; //涓昏〃鍗曚紶杩囨潵鐨勬暟鎹�
-    //寰幆琛ㄥ崟鍚嶆暟缁勶紝鎿嶄綔鍚勮〃鍗曞瓧娈�
-    formElName.value.forEach((name) => {
-      if (!isNullOrUnDef(useFormData.value[name])) {
-        useFormData.value[name][1]['resetFields']();
-        if (unref(isUpdate)) {
-          useFormData.value[name][1]['setFieldsValue']({
-            ...mValues.value,
-          });
+
+    emit('modalInner', dtlSlots.value, async () => {
+      await nextTick();
+      //寰幆琛ㄥ崟鍚嶆暟缁勶紝鎿嶄綔鍚勮〃鍗曞瓧娈�
+      formElName.value.forEach((name) => {
+        if (!isNullOrUnDef(useFormData.value[name])) {
+          useFormData.value[name][1]['resetFields']();
+          if (unref(isUpdate)) {
+            useFormData.value[name][1]['setFieldsValue']({
+              ...mValues.value,
+            });
+          }
         }
-      }
+      });
     });
     //鍒濆鍖栨柟娉曡嚜瀹氫箟
     if (!isNullOrEmpty(data?.initFnName)) {
@@ -115,10 +120,10 @@
       let param: CustModalParams = {
         cType: cType.value,
         values: unref(isUpdate.value),
-        initFnName: initFnName.value[cType.value],
         mValues: mValues.value,
         others: data?.others,
-        FnName: '',
+        FnName: initFnName.value[cType.value],
+        initFnName: '',
       };
       CustFunc(param);
     }
@@ -151,7 +156,7 @@
       const action = await CustFunc({
         cType: cType.value,
         values: values,
-        FnName: FnName.value[cType.value],
+        FnName: FnName.value,
       } as unknown as CustModalParams);
       if (action.IsSuccessed) {
         closeModal();
@@ -174,4 +179,12 @@
       setModalProps({ confirmLoading: false });
     }
   }
+
+  /**
+   * @description: 鍙栨秷鎸夐挳瑙﹀彂鍙栨秷浜嬩欢
+   * @return {*}
+   */
+  function handleCancel() {
+    emit('cancel');
+  }
 </script>

--
Gitblit v1.9.3