From 858b9bccead46cdefc99325b7c956d50a2964309 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 08 三月 2025 10:20:28 +0800
Subject: [PATCH] 一些优化

---
 src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts |  400 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 365 insertions(+), 35 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
index 18cd2bb..aeaf0d0 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts
@@ -2,52 +2,382 @@
  * @Description: 涓嶈壇鍘熷洜鐩稿叧
  * @Author: Ben Lin
  * @version:
- * @Date: 2024-06-19 20:34:27
+ * @Date: 2024-06-22 00:58:43
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-06-22 00:59:05
+ * @LastEditTime: 2024-07-04 11:21:56
  */
-
-import { DeleteEntity } from '/@/api/tigerapi/system';
-import { ActionItem } from '/@/components/Table';
-import { isNullOrEmpty } from '/@/utils/is';
+import { Ref, h } from 'vue';
+import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
+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, custDel } from '../data';
 
 function _default() {
-  /**
-   * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽�
-   * @return {*}
-   */
-  function ActionItem(params: Recordable<any>, data, ...args): ActionItem[] {
-    data[1].popConfirm.confirm = rsnGrpDel.bind(null, args, params);
-    return data;
-  }
+  const ActionColumn: BasicColumn = {
+    width: 80,
+    title: '鎿嶄綔',
+    dataIndex: 'action',
+    slots: { customRender: 'action' },
+    fixed: undefined,
+  };
 
   /**
-   * @description: 鑷畾涔夊垹闄ゆ柟娉�
-   * @param {Fn} args
-   * @param {*} params
+   * @description: 涓�浜涜嚜瀹氫箟鏂规硶
    * @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: [],
+  const methods = {
+    /**
+     * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓�
+     * @return {*}
+     */
+    CreateAction: (type: string) => {
+      return {
+        action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�)
+      };
+    },
+    /**
+     * @description: 鎿嶄綔瀛楁鑷畾涔夋寜閽�
+     * @return {*}
+     */
+    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
+      if (!isNullOrUnDef(data[1])) {
+        data[1].popConfirm.confirm = custDel.bind(null, args, params);
+      }
+      return data;
+    },
+    /**
+     * @description: 鑷畾涔夋槑缁嗚〃涓紪杈戣繑鍥炴柟娉�
+     * @param {string} type
+     * @param {*} d
+     * @param {*} u
+     * @return {*}
+     */
+    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;
       });
-      args[6]({
-        dataSource: params['data'],
-      });
-      args[1]();
-    } else {
-      DeleteEntity(params['record'], params['entityName']).then((action) => {
-        if (action.IsSuccessed) {
-          args[1]();
+      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: (type) => {
+      return baseColumns[type];
+    },
+    GetSearchForm: (type: string) => {
+      return searchForms[type];
+    },
+    GetCrudForm: (type: string) => {
+      return crudForms[type];
+    },
+    GetBaseForm: () => {
+      return [
+        {
+          field: 'RSNG_CODE',
+          label: '涓嶈壇鍘熷洜缁勭紪鐮�',
+          component: 'Input',
+          required: true,
+          colProps: {
+            span: 8,
+          },
+        },
+        {
+          label: '涓嶈壇鍘熷洜缁勫悕绉�',
+          field: 'RSNG_NAME',
+          required: true,
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
+        },
+        {
+          label: '澶囨敞',
+          field: 'REMARK',
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
+        },
+        {
+          label: 'ID',
+          field: 'ID',
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
+          show: false,
+        },
+      ];
+    },
+    GetBaseCards: () => {
+      return [
+        {
+          name: 'BaseForm',
+          slots: [],
+          preIcons: {},
+          title: '涓嶈壇鍘熷洜缁勪俊鎭�',
+          entityName: 'BAS_REASON_GRP',
+        },
+      ];
+    },
+    /**
+     * @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: false,
+          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: '涓嶈壇鍘熷洜绠$悊',
         }
-      });
-    }
-  }
+      };
+    },
+    GetUseForm: () => {
+      return {};
+    },
+  };
 
-  return [ActionItem];
+  /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport锛屼緵涓婇潰鐨勬柟娉曡皟鐢� */
+
+  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];
 }
 
 export default _default;

--
Gitblit v1.9.3