From bb8fba76d8c69f6957c606c2f3bb501af952b533 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 04 七月 2024 23:11:17 +0800
Subject: [PATCH] 班制更新

---
 src/views/tigerprojects/system/lowcode/detail/detail.vue |  107 +++++++++++++++++++----------------------------------
 1 files changed, 39 insertions(+), 68 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/detail/detail.vue b/src/views/tigerprojects/system/lowcode/detail/detail.vue
index 7fef75c..38b9a5c 100644
--- a/src/views/tigerprojects/system/lowcode/detail/detail.vue
+++ b/src/views/tigerprojects/system/lowcode/detail/detail.vue
@@ -37,6 +37,7 @@
   import { useGo } from '/@/hooks/web/usePage';
   import { DeleteEntity, getListByPage } from '/@/api/tigerapi/system';
   import { useI18n } from '/@/hooks/web/useI18n';
+  import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel';
 
   const { t } = useI18n();
 
@@ -46,7 +47,7 @@
   });
   const objParams = inject('objParams') as Ref<any>;
   const data = inject('data') as Ref<Recordable[]>;
-  const others = inject('others') as Ref<Recordable[]>;
+  const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>;
   const go = useGo();
   const [registerDrawer, { openDrawer }] = useDrawer();
   const [registerItemAdd, { openModal: openItemModal }] = useModal();
@@ -55,14 +56,42 @@
   const dtlSlots = ref([] as any[]);
   const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶
   const useFormData = ref({});
-  const custImport = ref<any[]>(await import(`../entityts/${props.entityName}.ts`));
-  const [{ EditeOperation, GetBaseColumns, GetSearchForm, GetCrudForm, OthersValues }] =
-    custImport.value['default']();
-  others.value = OthersValues(objParams['CODE'], objParams['ID']);
+  const custImport = ref<any[]>([]);
+  const EntityCustFunction = ref([
+    {
+      ActionItem(params, data, ...args) {},
+      EditOperation(data, d, u, item) {},
+      GetBaseColumns(type: string | undefined) {},
+      GetSearchForm(type: string | undefined) {},
+      GetCrudForm(type: string | undefined, ...args) {},
+      KeyFieldValues(val, id) {},
+      GetSelectSuccess(d, u, ...args) {},
+      OpenSelectItem(openItemModal: Fn, ...args) {},
+    } as EntityCustFunctionType,
+  ]);
+  /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
+  try {
+    custImport.value = await import(`../entityts/${objParams['Name']}.ts`);
+  } catch (e) {}
+  const [
+    {
+      ActionItem: nActionItem,
+      EditOperation,
+      GetBaseColumns,
+      GetSearchForm,
+      GetCrudForm,
+      KeyFieldValues,
+      GetSelectSuccess,
+      OpenSelectItem,
+    },
+  ] = isNullOrUnDef(custImport.value['default'])
+    ? EntityCustFunction.value
+    : custImport.value['default']();
+  keyFieldValues.value = KeyFieldValues(objParams['CODE'], objParams['ID']);
   const [registerTable, { getForm, reload, setProps }] = useTable({
     title: `${objParams['firstTitle']}鍒楄〃`,
     api: getListByPage,
-    searchInfo: { TABLE_NAME: objParams['Name'], ...objParams['others'] },
+    searchInfo: { TABLE_NAME: objParams['Name'], ...objParams['keyFieldValues'] },
     columns: GetBaseColumns(),
     formConfig: {
       labelWidth: 140,
@@ -121,8 +150,7 @@
     if (isNullOrUnDef(custImport.value)) {
       return actionItem;
     }
-    const [{ ActionItem }] = custImport.value['default']();
-    return ActionItem(
+    return nActionItem(
       params,
       actionItem,
       openDrawer,
@@ -175,7 +203,7 @@
       entityName: props.entityName,
       formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`),
       crudColSlots: colSlots.value,
-      others: others.value,
+      keyFieldValues: keyFieldValues.value,
       isExistSql: isExistSql,
     });
   }
@@ -198,21 +226,7 @@
    * @return {*}
    */
   function handleItemSuccess(d, u, item) {
-    /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
-    try {
-      import(
-        `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts`
-      )
-        .then((m) => {
-          const [{ GetSelectSuccess }] = m.default();
-          getForm().setFieldsValue(GetSelectSuccess(d, u));
-        })
-        .catch(() => {
-          getForm().setFieldsValue({
-            ITEM_CODE: d.values['val'],
-          });
-        });
-    } catch (e) {}
+    getForm().setFieldsValue(GetSelectSuccess(d, u));
   }
 
   /**
@@ -221,49 +235,6 @@
    * @return {*}
    */
   function handleSelectItem(item) {
-    /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */
-    try {
-      import(
-        `../entityts/${props.useTableData['table'][1].getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts`
-      )
-        .then((m) => {
-          const [{ OpenSelectItem }] = m.default();
-          OpenSelectItem(openItemModal);
-        })
-        .catch(() => {
-          openItemModal(true, {
-            title: '鐗╂枡鍒楄〃',
-            schemas: [
-              {
-                field: 'ITEM_CODE',
-                component: 'Input',
-                label: '鐗╂枡缂栫爜',
-                colProps: {
-                  span: 12,
-                },
-              },
-            ],
-            ItemColumns: [
-              {
-                title: t('鐗╂枡缂栫爜'),
-                dataIndex: 'ITEM_CODE',
-                resizable: true,
-                sorter: true,
-                width: 200,
-              },
-              {
-                title: t('鐗╂枡鍚嶇О'),
-                dataIndex: 'ITEM_NAME',
-                resizable: true,
-                sorter: true,
-                width: 180,
-              },
-            ],
-            tableName: 'BAS_ITEM',
-            rowKey: 'ITEM_CODE',
-            searchInfo: { TABLE_NAME: 'BAS_ITEM' },
-          });
-        });
-    } catch (e) {}
+    OpenSelectItem(openItemModal);
   }
 </script>

--
Gitblit v1.9.3