From 68d75a540ec8b3168c3af956ea00b898036d92cd Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 04 七月 2024 00:17:17 +0800
Subject: [PATCH] 包装规则更新

---
 src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts |  515 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 297 insertions(+), 218 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
index 9916686..fbf62b6 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
@@ -1,56 +1,23 @@
 /*
- * @Description: file content
+ * @Description: 涓嶈壇鍘熷洜鐩稿叧
  * @Author: Ben Lin
  * @version:
  * @Date: 2024-06-22 00:58:43
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-06-24 15:50:42
+ * @LastEditTime: 2024-07-03 21:39:08
  */
-/*
- * @Description: 涓嶈壇鍘熷洜鐩稿叧
- * @Author: Ben Lin
- * @version:
- * @Date: 2024-06-19 20:34:27
- * @LastEditors: Ben Lin
- * @LastEditTime: 2024-06-23 18:12:40
- */
-
 import { Ref, h } from 'vue';
 import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
-import { ActionItem, BasicColumn } from '/@/components/Table';
-import { isNullOrEmpty } from '/@/utils/is';
+import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table';
+import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
 import { buildUUID } from '/@/utils/uuid';
 import { useUserStore } from '/@/store/modules/user';
 import { formatToDateTime } from '/@/utils/dateUtil';
 import { Tag } from 'ant-design-vue';
+import { useDrawer } from '/@/components/Drawer';
+import { EditOperation, Search } from '../data';
 
 function _default() {
-  /**
-   * @description: 鑷畾涔夊垹闄ゆ柟娉�
-   * @param {Fn} args
-   * @param {*} params
-   * @return {*}
-   */
-  function rsnGrpDel(args: Fn[], params: {}) {
-    if (!isNullOrEmpty(params['data'])) {
-      var _data = params['data'].value.filter((item) => item['ID'] != params['record']['ID']);
-      params['data'].value = _data;
-      args[6]({
-        dataSource: [],
-      });
-      args[6]({
-        dataSource: params['data'],
-      });
-      args[1]();
-    } else {
-      DeleteEntity(params['record'], params['entityName']).then((action) => {
-        if (action.IsSuccessed) {
-          args[1]();
-        }
-      });
-    }
-  }
-
   const ActionColumn: BasicColumn = {
     width: 80,
     title: '鎿嶄綔',
@@ -59,6 +26,10 @@
     fixed: undefined,
   };
 
+  /**
+   * @description: 涓�浜涜嚜瀹氫箟鏂规硶
+   * @return {*}
+   */
   const methods = {
     /**
      * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓�
@@ -70,11 +41,13 @@
       };
     },
     /**
-     * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽�
+     * @description: 鎿嶄綔瀛楁鑷畾涔夋寜閽�
      * @return {*}
      */
     ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
-      data[1].popConfirm.confirm = rsnGrpDel.bind(null, args, params);
+      if (!isNullOrUnDef(data[1])) {
+        data[1].popConfirm.confirm = rsnGrpDel.bind(null, args, params);
+      }
       return data;
     },
     /**
@@ -84,188 +57,36 @@
      * @param {*} u
      * @return {*}
      */
-    EditeOperation: (data: Ref<any[]>, d, u) => {
-      if (u.isUpdate) {
-        //鏇存柊
-        var _data = data.value.map((item) => {
-          if (item['ID'] == d.ID)
-            return {
-              ...item,
-              RSN_CODE: d.RSN_CODE,
-              RSN_NAME: d.RSN_NAME,
-              NEED_REPLACE: d.NEED_REPLACE,
-              REMARK: d.REMARK,
-            };
-          return item;
-        });
-        data.value = _data;
-      } else {
-        //鏂板
-        d.ID = buildUUID();
-        d.CREATE_USER = useUserStore().getUserInfo.userId as string;
-        d.UPDATE_TIME = formatToDateTime(new Date());
-        d.UPDATE_USER = useUserStore().getUserInfo.userId as string;
-        var _data2: any[] = [];
-        if (!isNullOrEmpty(data.value)) {
-          _data2 = data.value.map((item) => {
-            return item;
-          });
-        }
-        _data2.push(d);
-        data.value = _data2;
-      }
+    EditOperation: (data: Ref<any[]>, d, u, item) => {
+       //鏇存柊
+       var _data = data.value[item].map((item) => {
+        if (item['ID'] == d.ID)
+          return {
+            ...item,
+            RSN_CODE: d.RSN_CODE,
+            RSN_NAME: d.RSN_NAME,
+            NEED_REPLACE: d.NEED_REPLACE,
+            REMARK: d.REMARK,
+          };
+        return item;
+      });
+      EditOperation(data,d, u, item, _data);
     },
+    /**
+     * @description: 楂樼骇琛ㄥ崟鍜岃鎯呴〉闈㈣繑鍥炰富椤甸潰鐨剈rl
+     * @return {*}
+     */
     GetHomeUrl: () => {
       return `/BAS_REASON_GRP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_REASON_GRP', colSlots: [], crudColSlots: [] }))}`;
     },
-    GetBaseColumns: () => {
-      return [
-        {
-          title: '涓嶈壇鍘熷洜缂栫爜',
-          dataIndex: 'RSN_CODE',
-          // ifShow: false,
-          width: 180,
-        },
-        {
-          title: '涓嶈壇鍘熷洜鍚嶇О',
-          dataIndex: 'RSN_NAME',
-        },
-        {
-          title: '鏄惁蹇呴』鏇存崲闆朵欢',
-          dataIndex: 'NEED_REPLACE',
-          customRender: ({ record }) => {
-            const type = record.NEED_REPLACE;
-            var text = '';
-            var color = 'green';
-            switch (type) {
-              case 'Y':
-                text = '鏇存崲';
-                break;
-              case 'N':
-                color = 'blue';
-                text = '涓嶆洿鎹�';
-                break;
-            }
-            return h(Tag, { color: color }, () => text);
-          },
-        },
-        {
-          title: '涓嶈壇鍘熷洜缁勭紪鐮�',
-          dataIndex: 'RSNG_CODE',
-        },
-        {
-          title: '澶囨敞',
-          dataIndex: 'REMARK',
-        },
-        {
-          title: '鏇存柊鏃堕棿',
-          dataIndex: 'UPDATE_TIME',
-        },
-        {
-          title: '鏇存柊浜�',
-          dataIndex: 'UPDATE_USER',
-        },
-      ];
+    GetBaseColumns: (type) => {
+      return baseColumns[type];
     },
-    GetSearchForm: () => {
-      return [
-        {
-          field: 'RSN_CODE',
-          label: '涓嶈壇鍘熷洜缂栫爜',
-          component: 'Input',
-          colProps: {
-            span: 8,
-          },
-        },
-        {
-          label: '涓嶈壇鍘熷洜鍚嶇О',
-          field: 'RSN_NAME',
-          component: 'Input',
-          colProps: {
-            span: 8,
-          },
-        },
-      ];
+    GetSearchForm: (type: string) => {
+      return searchForms[type];
     },
-    GetCrudForm: () => {
-      return [
-        {
-          field: 'RSN_CODE',
-          label: '涓嶈壇鍘熷洜缂栫爜',
-          component: 'Input',
-          required: true,
-          colProps: {
-            span: 24,
-          },
-        },
-        {
-          label: '涓嶈壇鍘熷洜鍚嶇О',
-          field: 'RSN_NAME',
-          component: 'Input',
-          required: true,
-          colProps: {
-            span: 24,
-          },
-        },
-        {
-          label: '涓嶈壇鍘熷洜缁勭紪鐮�',
-          field: 'RSNG_CODE',
-          component: 'ApiSelect',
-          colProps: {
-            span: 24,
-          },
-          componentProps: {
-            api: getEntity,
-            params: { entityName: 'BAS_REASON_GRP', sqlcmd: ' 1=1 ' },
-            resultField: 'Data.Items',
-            labelField: 'RSNG_NAME',
-            valueField: 'RSNG_CODE',
-          },
-          dynamicDisabled: ({ values }) => {
-            return true;
-          },
-        },
-        {
-          label: '鏄惁蹇呴』鏇存崲闆朵欢',
-          field: 'NEED_REPLACE',
-          component: 'Select',
-          required: true,
-          colProps: {
-            span: 24,
-          },
-          componentProps: {
-            options: [
-              {
-                label: '鏇存崲',
-                value: 'Y',
-                key: 'Y',
-              },
-              {
-                label: '涓嶆洿鎹�',
-                value: 'N',
-                key: 'N',
-              },
-            ],
-          },
-        },
-        {
-          label: '澶囨敞',
-          field: 'REMARK',
-          component: 'Input',
-          colProps: {
-            span: 24,
-          },
-        },
-        {
-          label: 'ID',
-          field: 'ID',
-          component: 'Input',
-          colProps: {
-            span: 24,
-          },
-          show: false,
-        },
-      ];
+    GetCrudForm: (type: string) => {
+      return crudForms[type];
     },
     GetBaseForm: () => {
       return [
@@ -317,9 +138,267 @@
         },
       ];
     },
-    OthersValues: (val: string, id: string) => {
+    /**
+     * @description: 鑾峰彇鍙充晶杈规use鏂规硶
+     * @return {*}
+     */
+    GetUseDrawers: () => {
+      return [
+        {
+          BAS_REASON: useDrawer(),
+        },
+      ];
+    },
+    /**
+     * @description: 鑾峰彇琛ㄦ牸use鍒楄〃
+     * @param {string} type
+     * @param {array} args
+     * @return {*}
+     */
+    GetUseTables: (data: Ref<{}>, ...args) => {
+      return {
+        BAS_REASON: useTable({
+          title: '鍒楄〃淇℃伅',
+          dataSource: data.value['BAS_REASON'],
+          columns: baseColumns['BAS_REASON'],
+          formConfig: {
+            labelWidth: 140,
+            schemas: searchForms['BAS_REASON'],
+            submitFunc: () => Search('BAS_REASON', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠�
+          },
+          useSearchForm: true,
+          showTableSetting: true,
+          bordered: true,
+          canResize: true,
+          showIndexColumn: false,
+          actionColumn: {
+            width: 130,
+            title: '鎿嶄綔',
+            dataIndex: 'action',
+            slots: { customRender: 'action' },
+            fixed: 'right',
+          }, //鑷畾涔夋搷浣滃垪
+        }),
+      };
+    },
+    /**
+     * @description: 琛ㄦ牸鏌ヨ鍥炶皟锛岀埗缁勪欢涓�氳繃瀛愮粍浠惰Е鍙戠殑浜嬩欢鑾峰彇浼犲叆鐨勫�硷紝鍋氬叿浣撶殑鏌ヨ閫昏緫瀹炵幇
+     * @param {*} d
+     * @return {*}
+     */
+    FormSearch: (d) => {
+      let data = {} as any;
+      switch (d.type) {
+        case 'BAS_REASON':
+          data = d.data.value[d.type].filter(
+            (item) =>
+              item.RSN_CODE.includes(d.values.RSN_CODE) || item.RSN_NAME == d.values.RSN_NAME,
+          );
+          if (isNullOrEmpty(d.values.RSN_CODE) && isNullOrEmpty(d.values.RSN_NAME)) {
+            data = d.data.value[d.type];
+          }
+          break;
+      }
+      return data;
+    },
+    KeyFieldValues: (val: string, id: string) => {
       return { RSNG_CODE: val };
     },
+    /**
+     * @description: 鑾峰彇鏍囬淇℃伅
+     * @param {string} type
+     * @return {*}
+     */
+    GetTitle: () => {
+      return {
+        pageTitle: '涓嶈壇鍘熷洜缁勭鐞�',
+        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹師鍥犵粍鍜屼笉鑹唬鐮併��',
+        tableTitle: {
+          BAS_REASON: '涓嶈壇鍘熷洜绠$悊',
+        }
+      };
+    },
+  };
+
+  /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport锛屼緵涓婇潰鐨勬柟娉曡皟鐢� */
+
+  /**
+   * @description: 鑷畾涔夊垹闄ゆ柟娉�
+   * @param {Fn} args
+   * @param {*} params
+   * @return {*}
+   */
+  function rsnGrpDel(args: Fn[], params: {}) {
+    const name = params['name'];
+    if (!isNullOrEmpty(params['data'])) {
+      var _data = params['data'].value[name].filter((item) => item['ID'] != params['record']['ID']);
+      params['data'].value[name] = _data;
+      args[6]({
+        dataSource: [],
+      });
+      args[6]({
+        dataSource: params['data'].value[name],
+      });
+      args[1]();
+    } else {
+      DeleteEntity(params['record'], params['entityName']).then((action) => {
+        if (action.IsSuccessed) {
+          args[1]();
+        }
+      });
+    }
+  }
+
+  const baseColumns = {
+    BAS_REASON: [
+      {
+        title: '涓嶈壇鍘熷洜缂栫爜',
+        dataIndex: 'RSN_CODE',
+        // ifShow: false,
+        width: 180,
+      },
+      {
+        title: '涓嶈壇鍘熷洜鍚嶇О',
+        dataIndex: 'RSN_NAME',
+      },
+      {
+        title: '鏄惁蹇呴』鏇存崲闆朵欢',
+        dataIndex: 'NEED_REPLACE',
+        customRender: ({ record }) => {
+          const type = record.NEED_REPLACE;
+          var text = '';
+          var color = 'green';
+          switch (type) {
+            case 'Y':
+              text = '鏇存崲';
+              break;
+            case 'N':
+              color = 'blue';
+              text = '涓嶆洿鎹�';
+              break;
+          }
+          return h(Tag, { color: color }, () => text);
+        },
+      },
+      {
+        title: '涓嶈壇鍘熷洜缁勭紪鐮�',
+        dataIndex: 'RSNG_CODE',
+      },
+      {
+        title: '澶囨敞',
+        dataIndex: 'REMARK',
+      },
+      {
+        title: '鏇存柊鏃堕棿',
+        dataIndex: 'UPDATE_TIME',
+      },
+      {
+        title: '鏇存柊浜�',
+        dataIndex: 'UPDATE_USER',
+      },
+    ] as BasicColumn[],
+  };
+
+  const searchForms = {
+    BAS_REASON: [
+      {
+        field: 'RSN_CODE',
+        label: '涓嶈壇鍘熷洜缂栫爜',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+      {
+        label: '涓嶈壇鍘熷洜鍚嶇О',
+        field: 'RSN_NAME',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+    ] as FormSchema[],
+  };
+
+  const crudForms = {
+    BAS_REASON: [
+      {
+        field: 'RSN_CODE',
+        label: '涓嶈壇鍘熷洜缂栫爜',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '涓嶈壇鍘熷洜鍚嶇О',
+        field: 'RSN_NAME',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '涓嶈壇鍘熷洜缁勭紪鐮�',
+        field: 'RSNG_CODE',
+        component: 'ApiSelect',
+        colProps: {
+          span: 24,
+        },
+        componentProps: {
+          api: getEntity,
+          params: { entityName: 'BAS_REASON_GRP', sqlcmd: ' 1=1 ' },
+          resultField: 'Data.Items',
+          labelField: 'RSNG_NAME',
+          valueField: 'RSNG_CODE',
+        },
+        dynamicDisabled: ({ values }) => {
+          return true;
+        },
+      },
+      {
+        label: '鏄惁蹇呴』鏇存崲闆朵欢',
+        field: 'NEED_REPLACE',
+        component: 'Select',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+        componentProps: {
+          options: [
+            {
+              label: '鏇存崲',
+              value: 'Y',
+              key: 'Y',
+            },
+            {
+              label: '涓嶆洿鎹�',
+              value: 'N',
+              key: 'N',
+            },
+          ],
+        },
+      },
+      {
+        label: '澶囨敞',
+        field: 'REMARK',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: 'ID',
+        field: 'ID',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+        show: false,
+      },
+    ] as FormSchema[],
   };
 
   return [methods, ActionColumn];

--
Gitblit v1.9.3