From eed29804d3973801f8eac3ad9bead1e608f05b6a Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 20 七月 2024 22:31:56 +0800
Subject: [PATCH] 工单及自定义弹出窗口更新

---
 src/views/tigerprojects/system/lowcode/detail/detail.vue |  116 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 60 insertions(+), 56 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/detail/detail.vue b/src/views/tigerprojects/system/lowcode/detail/detail.vue
index 38b9a5c..4705ff7 100644
--- a/src/views/tigerprojects/system/lowcode/detail/detail.vue
+++ b/src/views/tigerprojects/system/lowcode/detail/detail.vue
@@ -2,7 +2,15 @@
   <div>
     <BasicTable @register="registerTable">
       <template #toolbar>
-        <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </a-button>
+        <a-button
+          type="primary"
+          @click="handleCreate(item['DO_METHOD'])"
+          :preIcon="item['ICON_URL']"
+          v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)"
+          :key="item"
+        >
+          {{ item['FUNC_NAME'] }}
+        </a-button>
       </template>
       <template #action="{ record }">
         <TableAction :actions="createActions(record)" />
@@ -32,15 +40,18 @@
   import { useDrawer } from '/@/components/Drawer';
   import GeneralModal from '/@/views/components/GeneralModal.vue';
   import normalDrawer from '../normalDrawer.vue';
-  import { isNullOrUnDef } from '/@/utils/is';
+  import { isFunction, isNullOrUnDef } from '/@/utils/is';
   import { useModal } from '/@/components/Modal';
   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';
+  import { GenerateActionButton } from '../data';
+  import { getRoleButtons } from '/@/api/sys/menu';
+  import { useRouter } from 'vue-router';
 
   const { t } = useI18n();
-
+  const { currentRoute } = useRouter();
   const props = defineProps({
     useTableData: { type: Object as PropType<{}>, default: { table: [] } },
     entityName: { type: String },
@@ -87,7 +98,11 @@
   ] = isNullOrUnDef(custImport.value['default'])
     ? EntityCustFunction.value
     : custImport.value['default']();
-  keyFieldValues.value = KeyFieldValues(objParams['CODE'], objParams['ID']);
+  const buttons = ref<[]>(await getRoleButtons(currentRoute.value.meta.menuCode as string));
+  keyFieldValues.value =
+    KeyFieldValues && isFunction(KeyFieldValues)
+      ? KeyFieldValues(objParams['CODE'], objParams['ID'])
+      : [];
   const [registerTable, { getForm, reload, setProps }] = useTable({
     title: `${objParams['firstTitle']}鍒楄〃`,
     api: getListByPage,
@@ -132,22 +147,8 @@
       crudColSlots: colSlots.value,
       data,
     };
-    const actionItem = [
-      {
-        icon: 'clarity:note-edit-line',
-        onClick: editRecord.bind(null, openDrawer, params),
-      },
-      {
-        icon: 'ant-design:delete-outlined',
-        color: 'error',
-        popConfirm: {
-          title: '鏄惁纭鍒犻櫎?',
-          placement: 'left',
-          confirm: deleteRecord.bind(null, reload, params),
-        },
-      },
-    ];
-    if (isNullOrUnDef(custImport.value)) {
+    const actionItem = GenerateActionButton(params, buttons, openDrawer, reload);
+    if (isNullOrUnDef(custImport.value['default'])) {
       return actionItem;
     }
     return nActionItem(
@@ -163,33 +164,7 @@
     );
   }
 
-  /**
-   * @description: 鍏敤缂栬緫鏂规硶
-   * @param {Fn} fn
-   * @param {*} params
-   * @return {*}
-   */
-  function editRecord(fn: Fn, params: {}) {
-    fn(true, params);
-  }
-
-  /**
-   * @description: 鍏敤鍒犻櫎鏂规硶
-   * @param {Fn} fn
-   * @param {*} params
-   * @return {*}
-   */
-  function deleteRecord(fn: Fn, params: {}) {
-    console.log(params['record']);
-    //鍒犻櫎
-    DeleteEntity(params['record'], params['entityName']).then((action) => {
-      if (action.IsSuccessed) {
-        fn();
-      }
-    });
-  }
-
-  function handleCreate() {
+  function handleCreate(fnName: string) {
     const _cruds = GetCrudForm();
     let isExistSql = '';
     for (const i in _cruds) {
@@ -197,15 +172,44 @@
         isExistSql = _cruds[i].field;
       }
     }
-    openDrawer(true, {
-      isUpdate: false,
-      ifSave: false,
-      entityName: props.entityName,
-      formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`),
-      crudColSlots: colSlots.value,
-      keyFieldValues: keyFieldValues.value,
-      isExistSql: isExistSql,
-    });
+
+    if (isNullOrUnDef(custImport.value['default'])) {
+      openDrawer(true, {
+        isUpdate: false,
+        ifSave: false,
+        entityName: props.entityName,
+        formJson: _cruds, //getFormSchema(`${entityName.value}_Crud`),
+        crudColSlots: colSlots.value,
+        keyFieldValues: keyFieldValues.value,
+        isExistSql: isExistSql,
+      });
+    } else {
+      const [{ CreateAction }] = custImport.value['default']();
+      const result = CreateAction(fnName);
+      switch (result.action) {
+        case 'go':
+          // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage
+          sessionStorage.setItem(
+            `${result.params.Name}_params`,
+            encodeURI(JSON.stringify(result.params)),
+          );
+          go(
+            `/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`,
+          );
+          break;
+        case 'drawer':
+          openDrawer(true, {
+            isUpdate: false,
+            ifSave: false,
+            entityName: props.entityName,
+            formJson: _cruds, //getFormSchema(`${entityName.value}_Crud`),
+            crudColSlots: colSlots.value,
+            keyFieldValues: keyFieldValues.value,
+            isExistSql: isExistSql,
+          });
+          break;
+      }
+    }
   }
 
   /**

--
Gitblit v1.9.3