From 2e2ec72bdefad3ff51c786721f11b0d8b82d8b1b Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期二, 20 八月 2024 15:04:07 +0800
Subject: [PATCH] 打印模板更新

---
 src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts | 1246 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 1,180 insertions(+), 66 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts
index b1609d0..b669e72 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts
@@ -1,23 +1,36 @@
 /*
- * @Description: 浜у搧宸ヨ壓璺嚎鐩稿叧
+ * @Description: 妯℃澘鍙橀噺鐩稿叧
  * @Author: Ben Lin
  * @version:
  * @Date: 2024-06-19 20:34:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-06-23 23:42:04
+ * @LastEditTime: 2024-08-20 14:59:13
  */
 
 import { Tag, Tooltip } from 'ant-design-vue';
-import { ActionItem, BasicColumn } from '/@/components/Table';
+import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table';
 import { useI18n } from '/@/hooks/web/useI18n';
-import { h, unref } from 'vue';
-import { GetEnum } from '/@/api/tigerapi/system';
+import { h, ref, Ref, unref } from 'vue';
+import { AddAfterDelete, getEntity, GetEnum } from '/@/api/tigerapi/system';
 import { useLocale } from '/@/locales/useLocale';
+import { useDrawer } from '/@/components/Drawer';
+import { custDel, EditOperation, Search } from '../data';
+import { buildUUID } from '/@/utils/uuid';
+import { CustModalParams, FunctionType } from '/@/api/tigerapi/model/systemModel';
+import { useModal } from '/@/components/Modal';
+import { SaveLabelTemplate } from '/@/api/tigerapi/mes/label';
+import {
+  BAS_LABEL_TEMP,
+  BAS_LABEL_VAR,
+  BAS_LABEL_VAR_WO,
+  BasLabelTempInput,
+} from '/@/api/tigerapi/model/mesModel';
+import { useUserStore } from '/@/store/modules/user';
 
 const { getLocale } = useLocale();
 
 const { t } = useI18n();
-
+let newRow = {};
 function _default() {
   const ActionColumn: BasicColumn = {
     width: 80,
@@ -26,92 +39,213 @@
     slots: { customRender: 'action' },
     fixed: undefined,
   };
+
+  /**
+   * @description: 涓�浜涜嚜瀹氫箟鏂规硶
+   * @return {*}
+   */
   const methods = {
     /**
      * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓猴紝蹇呴渶瑕佹湁鐨勬柟娉�
      * @return {*}
      */
-    CreateAction: (fnName: string) => {
-      return {
-        action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�)
-      };
+    CreateAction: (type: string) => {
+      let action = {} as any;
+      switch (type) {
+        case 'BAS_LABEL_VAR':
+        case 'BAS_LABEL_VAR_WO':
+          action = {
+            action: 'edit', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�) | edit(濡傛灉鏄〃鏍煎彲缂栬緫椤甸潰灏辨槸鑷畾涔夋柟娉�)
+          };
+          break;
+      }
+      return action;
     },
     /**
-     * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽紝蹇呴渶瑕佹湁鐨勬柟娉�
+     * @description: 鎿嶄綔瀛楁鑷畾涔夋寜閽紝蹇呴渶瑕佹湁鐨勬柟娉�
      * @return {*}
      */
     ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
+      data.map((x) => {
+        if (x.name == 'Delete') {
+          x.popConfirm.confirm = custDel.bind(null, args, params);
+          x.tooltip = '鍒犻櫎';
+        }
+      });
       return data;
     },
     /**
      * @description: 楂樼骇琛ㄥ崟鍜岃鎯呴〉闈㈣繑鍥炰富椤甸潰鐨剈rl
      * @return {*}
-     */    
-    GetHomeUrl: () => {
-      return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`;
+     */
+    GetHomeUrl: (params: {}) => {
+      return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: params['colSlots'], crudColSlots: [] }))}`;
     },
-    GetBaseColumns: () => {
+    /**
+     * @description: 鑾峰彇涓讳俊鎭�
+     * @return {*}
+     */
+    GetBaseForm: (type, ...args) => {
       return [
         {
-          dataIndex: 'LABEL_ID',
-          title: '鏍囩妯℃澘ID',
-          ifShow: false,
-          sorter: true,
-          resizable: true,
+          field: 'LABEL_CODE',
+          label: '鏍囩妯℃澘缂栫爜',
+          component: 'Input',
+          required: true,
+          isexist: 'Y',
+          colProps: {
+            span: 8,
+          },
+          dynamicDisabled: true,
         },
         {
-          dataIndex: 'VAR_NAME',
-          title: '鍙橀噺鍚嶇О',
-          ifShow: true,
-          sorter: true,
-          resizable: true,
-          customRender: () => {},
-        },
-        {
-          dataIndex: 'VAR_TYPE',
-          title: '鍙橀噺绫诲瀷',
-          ifShow: true,
-          sorter: true,
-          resizable: true,
-          customRender: ({ record }) => {
-            let color = '';
-            let text = '';
-            switch (record.VAR_TYPE) {
-              case 0:
-                text = '甯搁噺';
-                color = 'green';
-                break;
-              case 1:
-                text = '杩囩▼鍙橀噺';
-                color = 'orange';
-                break;
-              case 2:
-                text = '鏃ユ湡鍙橀噺';
-                color = '#4f68b0';
-                break;
-              case 3:
-                text = '鑷畾涔夊彉閲�';
-                color = '#bfbfbf';
-                break;
-            }
-            return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text));
+          label: '鏍囩妯℃澘鍚嶇О',
+          field: 'LABEL_NAME',
+          required: true,
+          component: 'Input',
+          colProps: {
+            span: 8,
           },
         },
         {
-          dataIndex: 'VAR_VALUE',
-          title: '鍙橀噺鍊�',
-          ifShow: true,
-          sorter: true,
-          resizable: true,
+          label: '妯℃澘绫诲瀷',
+          field: 'TEMP_TYPE',
+          required: true,
+          component: 'ApiSelect',
+          colProps: {
+            span: 8,
+          },
+          componentProps: {
+            api: GetEnum,
+            params: { name: 'BAS_LABEL_TEMP+TEMP_TYPEs' },
+            resultField: 'Data',
+            labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
+            valueField: 'Value',
+          },
+        },
+        // {
+        //   field: 'TEMP_PATH',
+        //   label: '鏍囩妯℃澘鐩稿璺緞',
+        //   component: 'Upload',
+        //   isexist: 'N',
+        //   show: true,
+        //   required: true,
+        //   colProps: {
+        //     span: 8,
+        //   },
+        //   componentProps: ({ formModel }) => {
+        //     return {
+        //       resultField: 'data3.url',
+        //       multiple: false,
+        //       uploadParams: { entityName: type },
+        //       api: (file, progress) => {
+        //         console.log(formModel);
+        //         return new Promise((resolve) => {
+        //           uploadApi(file, progress).then((uploadApiResponse) => {
+        //             const webSocketStore = useWebSocketStore();
+        //             if (webSocketStore.GetSocketState == 1) {
+        //               webSocketStore.sendMessage(
+        //                 `wsSubStrings ${formModel['ID']}_#_${uploadApiResponse.data.url}`,
+        //               );
+        //             }
+        //             resolve({
+        //               code: 200,
+        //               data3: {
+        //                 url: uploadApiResponse.data.url,
+        //               },
+        //             });
+        //           });
+        //         });
+        //       },
+        //     };
+        //   },
+        // },
+        {
+          field: 'PROD_CODE',
+          label: '浜у搧缂栫爜',
+          component: 'Input',
+          isexist: 'N',
+          show: true,
+          required: true,
+          colProps: {
+            span: 7,
+          },
         },
         {
-          dataIndex: 'REMARK',
-          title: '澶囨敞',
-          ifShow: true,
-          sorter: true,
-          resizable: true,
+          field: 'BAS_LABEL_VAR1PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂�
+          label: '1',
+          defaultValue: 'BAS_LABEL_VAR',
+          component: 'Input',
+          colProps: { span: 1 },
+          colSlot: 'BAS_LABEL_VAR1add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂�
+        },
+        {
+          field: 'CUST_CODE',
+          label: '瀹㈡埛缂栫爜',
+          component: 'Input',
+          isexist: 'N',
+          show: true,
+          // required: true,
+          colProps: {
+            span: 7,
+          },
+        },
+        {
+          field: 'BAS_LABEL_VAR2PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂�
+          label: '1',
+          defaultValue: 'BAS_CUSTOMER',
+          component: 'Input',
+          colProps: { span: 1 },
+          colSlot: 'BAS_LABEL_VAR2add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂�
+        },
+        {
+          label: '澶囨敞',
+          field: 'REMARK',
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
+        },
+        {
+          label: '鏍囩妯℃澘鐩稿璺緞',
+          field: 'TEMP_PATH',
+          required: true,
+          component: 'Input',
+          colProps: {
+            span: 16,
+          },
+        },
+        {
+          label: 'ID',
+          field: 'ID',
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
+          show: false,
         },
       ];
+    },
+    /**
+     * @description: 寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炶祴鍊兼柟娉�
+     * @param {*} d
+     * @param {*} u
+     * @return {*}
+     */
+    GetSelectSuccess: (d, u) => {
+      return {
+        PROD_CODE: d.values['val'],
+      };
+    },
+    /**
+     * @description: 鑾峰彇妯℃�佹搴旂敤鍒楄〃
+     * @return {*}
+     */
+    GetUseModals: () => {
+      return {
+        BAS_LABEL_VAR1add: useModal(),
+        BAS_LABEL_VAR2add: useModal(),
+      };
     },
     GetSearchForm: () => {
       return [
@@ -204,9 +338,989 @@
         },
       ];
     },
-    OthersValues: (val: string, id: string) => {
+    /**
+     * @description: 鑾峰彇鏂板琛岀殑鏁版嵁
+     * @param {string} type
+     * @return {*}
+     */
+    GetNewRow: (type: string) => {
+      let values = {};
+      switch (type) {
+        case 'BAS_LABEL_VAR_WO':
+          values = newRow;
+          break;
+      }
+      return values;
+    },
+    KeyFieldValues: (val: string, id: string) => {
       return { LABEL_ID: id };
     },
+    GetUseForm: () => {
+      return {};
+    },
+    /**
+     * @description: 鑾峰彇鏍囬淇℃伅
+     * @param {string} type
+     * @return {*}
+     */
+    GetTitle: () => {
+      return {
+        pageTitle: '鎵撳嵃妯℃澘绠$悊',
+        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀规ā鏉垮拰妯℃澘鍙橀噺鍙婂伐鍗曟ā鏉垮彉閲忋��',
+        tableTitle: {
+          BAS_LABEL_VAR: '妯℃澘鍙橀噺绠$悊',
+          BAS_LABEL_VAR_WO: '宸ュ崟妯℃澘鍙橀噺绠$悊',
+        },
+      };
+    },
+    /**
+     * @description: 鑾峰彇鍗$墖鍐呴厤缃垪琛紝浠ュ惊鐜樉绀哄涓崱鐗囧苟閰嶇疆澶氫釜鎻掓Ы
+     * @return {*}
+     */
+    GetBaseCards: (type: string) => {
+      return [
+        {
+          name: 'BaseForm',
+          slots: [],
+          preIcons: {},
+          title: '妯℃澘淇℃伅',
+          entityName: 'BAS_LABEL_TEMP',
+        },
+      ];
+    },
+    /**
+     * @description: 鑾峰彇鍙充晶杈规use鏂规硶
+     * @return {*}
+     */
+    GetUseDrawers: () => {
+      return [
+        {
+          BAS_LABEL_VAR: useDrawer(),
+        },
+        { BAS_LABEL_VAR_WO: useDrawer() },
+      ];
+    },
+    /**
+     * @description: 鑾峰彇琛ㄦ牸use鍒楄〃
+     * @param {string} type
+     * @param {array} args
+     * @return {*}
+     */
+    GetUseTables: (data: Ref<{}>, ...args) => {
+      // _data = data;
+      return {
+        BAS_LABEL_VAR: useTable({
+          title: '鍒楄〃淇℃伅',
+          dataSource: data.value['BAS_LABEL_VAR'],
+          columns: GetBaseColumns('BAS_LABEL_VAR', args[0], data),
+          maxHeight: 520,
+          formConfig: {
+            labelWidth: 140,
+            schemas: searchForms['BAS_LABEL_VAR'],
+            submitFunc: () => Search('BAS_LABEL_VAR', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠�
+          },
+          useSearchForm: false,
+          showTableSetting: false,
+          bordered: true,
+          canResize: true,
+          showIndexColumn: false,
+          // rowSelection: {
+          //   type: 'radio', //'checkbox'
+          // },
+          // actionColumn: {
+          //   width: 130,
+          //   title: '鎿嶄綔',
+          //   dataIndex: 'action',
+          //   slots: { customRender: 'action' },
+          //   fixed: 'right',
+          // }, //鑷畾涔夋搷浣滃垪
+        }),
+        BAS_LABEL_VAR_WO: useTable({
+          title: '鍒楄〃淇℃伅',
+          dataSource: data.value['BAS_LABEL_VAR_WO'],
+          columns: GetBaseColumns('BAS_LABEL_VAR_WO', args[0], data),
+          scroll: { y: 500 },
+          formConfig: {
+            labelWidth: 140,
+            schemas: searchForms['BAS_LABEL_VAR_WO'],
+            submitFunc: () => Search('BAS_LABEL_VAR_WO', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠�
+          },
+          useSearchForm: false,
+          showTableSetting: false,
+          bordered: true,
+          canResize: false,
+          showIndexColumn: false,
+          actionColumn: {
+            width: 130,
+            title: '鎿嶄綔',
+            dataIndex: 'action',
+            slots: { customRender: 'action' },
+            fixed: 'right',
+          }, //鑷畾涔夋搷浣滃垪
+        }),
+      };
+    },
+    /**
+     * @description: 鑷畾涔夊垵濮嬪寲鏂规硶
+     * @param {Ref} data
+     * @param {Ref} keyFieldValues
+     * @param {string} type
+     * @param {any} useTables
+     * @return {*}
+     */
+    CustInitData: (data: Ref<any[]>, keyFieldValues: Ref<{}>, type: string, useTables: any) => {
+      if (type == 'BAS_LABEL_VAR_WO') {
+        if (data.value['BAS_LABEL_VAR_WO'].length > 0) {
+          /* 鍒濆鍖栨暟鎹紝琛岃浆鍒� */
+          let varwos: any[] = [];
+          const map = new Map<string, any>();
+          data.value['BAS_LABEL_VAR_WO'].map((curr) => {
+            if (!map.has(curr.WORK_ORDER)) {
+              const newObj = {};
+              newObj['WORK_ORDER'] = curr.WORK_ORDER;
+              map.set(curr.WORK_ORDER, newObj);
+            }
+            const acc = map.get(curr.WORK_ORDER);
+            Object.keys(curr).forEach((key) => {
+              if (key != 'VAR_NAME' && key != 'VAR_VALUE') {
+                acc[key] = curr[key];
+              } else if (key == 'VAR_NAME') {
+                acc[`DEFAULT_VALUE_${curr.VAR_NAME}`] = curr.DEFAULT_VALUE;
+                acc[`VAR_N_${curr.VAR_NAME}`] = curr.VAR_VALUE;
+              }
+            });
+            // varwos.push(acc);
+          });
+          map.forEach((x) => {
+            varwos.push(x);
+          });
+          data.value['BAS_LABEL_VAR_WO'] = varwos;
+        }
+        useTables[type][1].setProps({
+          dataSource: data.value['BAS_LABEL_VAR_WO'],
+          columns: GetBaseColumns('BAS_LABEL_VAR_WO', null, data),
+          scroll: { y: 500 },
+          useSearchForm: false,
+          showTableSetting: false,
+          bordered: true,
+          canResize: true,
+          showIndexColumn: false,
+          actionColumn: {
+            width: 130,
+            title: '鎿嶄綔',
+            dataIndex: 'action',
+            slots: { customRender: 'action' },
+            fixed: 'right',
+          },
+        });
+        useTables[type][1].reload();
+      }
+    },
+    /**
+     * @description: 鎻愪氦鎵�鏈�
+     * @return {*}
+     */
+    SubmitAll: (data: Ref<any[]>, keyFieldValues: Ref<{}>, ...args) => {
+      const cancel = args[0];
+      const drawers = args[1];
+      const label = args[2]['BaseForm'];
+      // const input: BasLabelTempInput ={
+      //   Label: undefined,
+      //   LabelVar: undefined,
+      //   LabelVarWo: undefined
+      // };
+      const input: BasLabelTempInput = {
+        Label: {
+          ID: buildUUID(),
+          CREATE_USER: useUserStore().getUserInfo.userId as string,
+          UPDATE_USER: useUserStore().getUserInfo.userId as string,
+          GHOST_ROW: false,
+          AUTH_ORG: useUserStore().getUserInfo.orgCode,
+          AUTH_PROD: useUserStore().getUserInfo.prodCode,
+          AUTH_WH: '',
+          LABEL_CODE: label.LABEL_CODE,
+          LABEL_NAME: label.LABEL_NAME,
+          TEMP_TYPE: label.TEMP_TYPE,
+          TEMP_PATH: label.TEMP_PATH,
+          CUST_CODE: label.CUST_CODE,
+          PROD_CODE: label.PROD_CODE,
+          REMARK: '',
+        } as unknown as BAS_LABEL_TEMP,
+        LabelVars: {} as unknown as BAS_LABEL_VAR[],
+        LabelVarWos: {} as unknown as BAS_LABEL_VAR_WO[],
+      };
+      drawers.forEach((d) => {
+        let where = `${d['code']} = '${keyFieldValues.value[d['code']]}'`;
+        /* type: all-琛ㄧず闇�瑕乧ode鐨勬墍鏈夌殑鍊� */
+        if (d['type'] == 'all' && data.value[d['keyName']].length > 0) {
+          where = `${d['code']} in (${data.value[d['keyName']].map((value) => `'${value[d['code']]}'`).join(',')})`;
+        }
+        data.value[d['name']].map((item) => {
+          item.ID = buildUUID();
+        });
+        if (d.name == 'BAS_LABEL_VAR') {
+          input.LabelVars = data.value[d['name']];
+        }
+        if (d.name == 'BAS_LABEL_VAR_WO') {
+          let varwos: any[] = [];
+          data.value[d['name']].map((curr) => {
+            const vKeys: any[] = [];
+            Object.keys(curr).forEach((key) => {
+              if (key.startsWith('VAR_N_')) {
+                vKeys.push(key);
+              }
+              // if (key.startsWith('VAR_N_')) {
+              //   acc['VAR_NAME'] = key.replace('VAR_N_', '');
+              //   acc['VAR_VALUE'] = curr[key];
+              // } else if (key.startsWith('DEFAULT_VALUE_')) {
+              //   acc['DEFAULT_VALUE'] = curr[key]; acc[key] = curr[key];
+              // }
+            });
+            vKeys.forEach((k) => {
+              let acc = {};
+              Object.keys(curr).forEach((key) => {
+                if (key == k) {
+                  acc['VAR_NAME'] = key.replace('VAR_N_', '');
+                  acc['VAR_VALUE'] = curr[key];
+                } else if (key == `DEFAULT_VALUE_${k.replace('VAR_N_', '')}`) {
+                  acc['DEFAULT_VALUE'] = curr[key];
+                } else if (
+                  !key.startsWith('VAR_N_') &&
+                  !key.startsWith('DEFAULT_VALUE_') &&
+                  key != 'DEFAULT_VALUE'
+                ) {
+                  acc[key] = curr[key];
+                }
+              });
+              acc['ID'] = buildUUID();
+              varwos.push(acc);
+            });
+          });
+          input.LabelVarWos = varwos;
+        }
+      });
+      SaveLabelTemplate(input).then((action) => {
+        if (action.IsSuccessed) {
+          cancel();
+        }
+      });
+    },
+    /**
+     * @description: 鑷畾涔夋柟娉�
+     * @param {string} type
+     * @param {array} args
+     * @return {*}
+     */
+    CustFunc: (param: CustModalParams) => {
+      switch (param.cType) {
+        case 'BAS_LABEL_VAR':
+        case 'BAS_LABEL_VAR_WO':
+          return getFns[param.FnName](param) as Promise<any>;
+        // break;
+        default:
+          return new Promise((resolve, reject) => {
+            try {
+              (e) => {};
+              resolve(true);
+            } catch {
+              reject(false);
+            } finally {
+              // args[0][0]({ confirmLoading: false });
+            }
+          });
+        // break;
+      }
+    },
+    /**
+     * @description: 缂栬緫鍗曞厓鏍煎畬鎴愬悗鑷畾涔夋柟娉�
+     * @param {Recordable} param1
+     * @param {*} type
+     * @param {any} useTables
+     * @return {*}
+     */
+    CustEditEnd: ({ record, index, key, value }: Recordable, type, ...args) => {
+      console.log(key, value);
+      const useTables = args[0];
+      const data = args[1];
+      let varWodata: any[] = [];
+      if (
+        (record['VAR_TYPE'] == 1 && record['VAR_VALUE'] != 'PV-WorkOrder-Plan') ||
+        record['VAR_TYPE'] != 1
+      ) {
+        data.value['BAS_LABEL_VAR_WO'].forEach((x) => {
+          let acc: any = {};
+          Object.keys(x).map((key) => {
+            if (key != `VAR_N_${record['VAR_NAME']}`) {
+              acc[key] = x[key];
+            }
+          });
+          varWodata.push(acc);
+        });
+        data.value['BAS_LABEL_VAR_WO'] = varWodata;
+      } else {
+        varWodata = data.value['BAS_LABEL_VAR_WO'];
+      }
+      switch (type) {
+        case 'BAS_LABEL_VAR':
+          useTables['BAS_LABEL_VAR_WO'][1].setProps({
+            dataSource: varWodata,
+            columns: GetBaseColumns('BAS_LABEL_VAR_WO', null, data),
+            scroll: { y: 500 },
+            useSearchForm: false,
+            showTableSetting: false,
+            bordered: true,
+            canResize: true,
+            showIndexColumn: false,
+            actionColumn: {
+              width: 130,
+              title: '鎿嶄綔',
+              dataIndex: 'action',
+              slots: { customRender: 'action' },
+              fixed: 'right',
+            },
+          });
+          useTables['BAS_LABEL_VAR_WO'][1].reload();
+          break;
+        default:
+          break;
+      }
+    },
+  };
+
+  /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport */
+
+  /**
+   * @description: 鑷畾涔夋柟娉�
+   * @return {*}
+   */
+  const getFns: Record<string, FunctionType> = {
+    /**
+     * @description: 鏂板琛屾柟娉�
+     * @param {*} e
+     * @param {array} args
+     * @return {*}
+     */
+    AddRow: (param: CustModalParams) => {
+      return new Promise((resolve, reject) => {
+        try {
+          console.log('AddRow');
+          EditOperation(
+            param.data,
+            { ...param.values, ...param.others },
+            { isUpdate: false },
+            param.cType,
+            {},
+          );
+        } catch {
+          reject(false);
+        }
+      });
+    },
+  };
+
+  let columns: BasicColumn[] = [];
+  /**
+   * @description: 鑾峰彇琛ㄦ牸瀛楁Json
+   * @param {string} type
+   * @return {*}
+   */
+  function GetBaseColumns(type: string, emit, data: Ref<{}>) {
+    columns = [
+      {
+        dataIndex: 'LABEL_ID',
+        title: '鏍囩妯℃澘ID',
+        ifShow: false,
+        sorter: true,
+        resizable: true,
+      },
+      {
+        dataIndex: 'VAR_NAME',
+        title: '鍙橀噺鍚嶇О',
+        ifShow: true,
+        sorter: true,
+        resizable: true,
+        customRender: () => {},
+      },
+      {
+        dataIndex: 'VAR_TYPE',
+        title: '鍙橀噺绫诲瀷',
+        edit: true,
+        editRule: true,
+        ifShow: true,
+        sorter: true,
+        resizable: true,
+        editComponent: 'ApiSelect',
+        editComponentProps: (column) => {
+          return {
+            api: GetEnum,
+            params: { name: 'BAS_LABEL_VAR+VAR_TYPEs' },
+            resultField: 'Data',
+            labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
+            valueField: 'Value',
+            onChange: (e, v) => {
+              if (e == 1 || e == 4) {
+                const where = e == 1? { TABLE_NAME: 'BAS_LABEL_PV', VAR_TYPE: 0}: { TABLE_NAME: 'BAS_LABEL_PV', VAR_TYPE: 1};
+                emit('opencust', {
+                  data: column.record,
+                  name: 'BAS_LABEL_VAR',
+                  modalSchema: {
+                    title: '杩囩▼鍙橀噺鍒楄〃',
+                    schemas: [
+                      {
+                        field: 'VAR_CODE',
+                        component: 'Input',
+                        label: '杩囩▼鍙橀噺缂栫爜',
+                        colProps: {
+                          span: 12,
+                        },
+                      },
+                    ],
+                    ItemColumns: [
+                      {
+                        title: t('杩囩▼鍙橀噺缂栫爜'),
+                        dataIndex: 'VAR_CODE',
+                        resizable: true,
+                        sorter: true,
+                        width: 200,
+                      },
+                      {
+                        title: t('杩囩▼鍙橀噺鍚嶇О'),
+                        dataIndex: 'VAR_NAME',
+                        resizable: true,
+                        sorter: true,
+                        width: 180,
+                      },
+                    ],
+                    tableName: 'BAS_LABEL_PV',
+                    rowKey: 'VAR_CODE',
+                    searchInfo: where,
+                  },
+                });
+              }
+            },
+          };
+        },
+        editRender: ({ record }) => {
+          let color = '';
+          let text = '';
+          switch (record.VAR_TYPE) {
+            case 0:
+              text = '甯搁噺';
+              color = 'green';
+              break;
+            case 1:
+              text = '杩囩▼鍙橀噺';
+              color = 'orange';
+              break;
+            case 2:
+              text = '鏃ユ湡鍙橀噺';
+              color = '#4f68b0';
+              break;
+            case 3:
+              text = '鑷畾涔夊彉閲�';
+              color = '#bfbfbf';
+              break;
+            case 4:
+              text = '鏉$爜鐢熸垚';
+              color = '#b442df';
+              break;
+          }
+          return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text));
+        },
+      },
+    ];
+    switch (type) {
+      case 'BAS_LABEL_VAR':
+        columns = [
+          ...columns,
+          ...[
+            {
+              dataIndex: 'VAR_VALUE',
+              title: '鍙橀噺鍊�',
+              edit: true,
+              // editable: true,
+              editRule: true,
+              ifShow: (column) => true,
+              sorter: true,
+              resizable: true,
+            },
+            {
+              dataIndex: 'BARCODE_RULE',
+              title: '鏉$爜鐢熸垚瑙勫垯',
+              ifShow: true,
+              edit: true,
+              editRule: true,
+              sorter: true,
+              resizable: true,
+              editComponent: 'ApiSelect',
+              editComponentProps: (column) => {
+                return {
+                  api: getEntity,
+                  params: { entityName: 'BAS_CODE_RULE', sqlcmd: ' 1=1 ' },
+                  resultField: 'Data.Items',
+                  labelField: 'RULE_NAME',
+                  valueField: 'RULE_CODE',
+                };
+              },
+            },
+            {
+              dataIndex: 'REMARK',
+              title: '澶囨敞',
+              ifShow: true,
+              sorter: true,
+              resizable: true,
+            },
+          ],
+        ] as BasicColumn[];
+        break;
+      case 'BAS_LABEL_VAR_WO':
+        const _columns = [
+          {
+            dataIndex: 'LABEL_ID',
+            title: '鏍囩妯℃澘ID',
+            ifShow: false,
+            sorter: true,
+            resizable: true,
+          },
+          {
+            title: '宸ュ崟鍙�',
+            dataIndex: 'WORK_ORDER',
+            width: 280,
+            edit: true,
+            editRule: true,
+            // editable: true,
+            ifShow: true,
+          },
+        ] as BasicColumn[];
+        newRow = {
+          ID: buildUUID(),
+          LABEL_ID:
+            data.value['BAS_LABEL_VAR'].length > 0 ? data.value['BAS_LABEL_VAR'][0].LABEL_ID : '',
+          WORK_ORDER: '',
+        };
+        data.value['BAS_LABEL_VAR'].map((x) => {
+          if (x.VAR_TYPE == 1 && x.VAR_VALUE == 'PV-WorkOrder-Plan') {
+            newRow[`${x.VAR_NAME}_DEFAULT_VALUE`] = '';
+            newRow[x.VAR_NAME] = '';
+            _columns.push(
+              {
+                title: `锛堝彉閲忥級${x.VAR_NAME}榛樿鍊糮,
+                dataIndex: `DEFAULT_VALUE_${x.VAR_NAME}`,
+                width: 280,
+                // edit: true,
+                // editRule: true,
+                resizable: true,
+                ifShow: true,
+              },
+              {
+                title: `锛堝彉閲忥級${x.VAR_NAME}`,
+                dataIndex: `VAR_N_${x.VAR_NAME}`,
+                width: 280,
+                edit: true,
+                editRule: true,
+                resizable: true,
+                ifShow: true,
+              },
+            );
+          }
+        });
+        _columns.push({
+          title: `澶囨敞`,
+          dataIndex: 'REMARK',
+          width: 280,
+          edit: true,
+          editRule: true,
+          resizable: true,
+          ifShow: true,
+        });
+        columns = _columns;
+        break;
+    }
+    return columns;
+  }
+
+  /**
+   * @description: 琛ㄦ牸鍩烘湰瀛楁
+   * @return {*}
+   */
+  const baseColumns = {
+    BAS_LABEL_VAR: [],
+    BAS_LABEL_VAR_WO: [
+      {
+        dataIndex: 'LABEL_ID',
+        title: '鏍囩妯℃澘ID',
+        ifShow: false,
+        sorter: true,
+        resizable: true,
+      },
+      {
+        title: '宸ュ崟鍙�',
+        dataIndex: 'WORK_ORDER',
+        edit: true,
+        editRule: true,
+        // editable: true,
+        ifShow: true,
+      },
+      {
+        dataIndex: 'VAR_NAME',
+        title: '鍙橀噺鍚嶇О',
+        edit: true,
+        editRule: true,
+        // editable: true,
+        ifShow: true,
+        sorter: true,
+        resizable: true,
+        customRender: () => {},
+      },
+      {
+        dataIndex: 'VAR_VALUE',
+        title: '鍙橀噺鍊�',
+        edit: true,
+        editRule: true,
+        // editable: true,
+        ifShow: true,
+        sorter: true,
+        resizable: true,
+      },
+      {
+        title: '鏍囩妯℃澘棰勮鍦板潃',
+        dataIndex: 'LABEL_VIEW_PATH',
+        ifShow: false,
+      },
+      {
+        title: '澶囨敞',
+        dataIndex: 'REMARK',
+      },
+      // {
+      //   title: '鏇存柊鏃堕棿',
+      //   dataIndex: 'UPDATE_TIME',
+      // },
+      // {
+      //   title: '鏇存柊浜�',
+      //   dataIndex: 'UPDATE_USER',
+      // },
+    ] as BasicColumn[],
+  };
+
+  /**
+   * @description: 鏌ヨ瀛楁
+   * @return {*}
+   */
+  const searchForms = {
+    MES_SHIFT: [
+      {
+        field: 'SFT_CODE',
+        label: '鐝缂栫爜',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+      {
+        label: '鐝鍚嶇О',
+        field: 'SFT_NAME',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+    ] as FormSchema[],
+    MES_SHIFT_PRD: [
+      {
+        field: 'PRD_CODE',
+        label: '鏃舵缂栫爜',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+      {
+        label: '鏃舵鍚嶇О',
+        field: 'PRD_NAME',
+        component: 'Input',
+        colProps: {
+          span: 8,
+        },
+      },
+    ] as FormSchema[],
+  };
+
+  const crudForms = {
+    MES_SHIFT: [
+      {
+        field: 'SFT_CODE',
+        label: '鐝缂栫爜',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '鐝鍚嶇О',
+        field: 'SFT_NAME',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '鐝埗缂栫爜',
+        field: 'SFTS_CODE',
+        component: 'ApiSelect',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+        componentProps: {
+          api: getEntity,
+          params: { entityName: 'MES_SHIFT_SYS', sqlcmd: ' 1=1 ' },
+          resultField: 'Data.Items',
+          labelField: 'SFTS_NAME',
+          valueField: 'SFTS_CODE',
+        },
+        dynamicDisabled: ({ values }) => {
+          return true;
+        },
+      },
+      // {
+      //   label: '鐝鏃堕棿鑼冨洿',
+      //   field: '[SFT_BEGIN, SFT_END]',
+      //   component: 'TimeRangePicker',
+      //   colProps: {
+      //     span: 24,
+      //   },
+      //   componentProps: ({ formModel }) => {
+      //     return {
+      //       format: 'HH:mm',
+      //       placeholder: ['寮�濮嬫椂闂�', '缁撴潫鏃堕棿'],
+      //       onChange: (e) => {
+      //         const timeRange: any = e;
+      //         console.log(e);
+      //         // if (timeRange) {
+      //         //   formModel.SFT_BEGIN = Number(`${tsToHHmm(timeRange[0].$d)}`);
+      //         //   formModel.SFT_END = Number(`${tsToHHmm(timeRange[1].$d)}`);
+      //         // }
+      //       },
+      //     };
+      //   },
+      // },
+      {
+        label: '鐝寮�濮嬫椂闂�',
+        field: 'SFT_BEGIN',
+        component: 'TimePicker',
+        colProps: {
+          span: 12,
+        },
+        componentProps: ({ formModel }) => {
+          return {
+            format: 'HH:mm',
+          };
+        },
+        // show: false,
+      },
+      {
+        label: '缁撴潫鏃堕棿',
+        field: 'SFT_END',
+        component: 'TimePicker',
+        colProps: {
+          span: 12,
+        },
+        componentProps: ({ formModel }) => {
+          return {
+            format: 'HH:mm',
+          };
+        },
+        // show: false,
+      },
+      {
+        label: '鏄惁璺ㄥぉ',
+        field: 'IS_ACROSS_DAY',
+        component: 'Select',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+        componentProps: {
+          options: [
+            {
+              label: '鏄�',
+              value: 'Y',
+              key: 'Y',
+            },
+            {
+              label: '鍚�',
+              value: 'N',
+              key: 'N',
+            },
+          ],
+        },
+      },
+      // {
+      //   field: 'LOGIN_TIME',
+      //   label: '鐧诲綍鏃堕棿',
+      //   defaultValue: '',
+      //   component: 'RangePicker',
+      //   ifShow: true,
+      //   colProps: { span: 8 },
+      // },
+      {
+        label: '澶囨敞',
+        field: 'REMARK',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: 'ID',
+        field: 'ID',
+        component: 'Input',
+        colProps: {
+          span: 24,
+        },
+        show: false,
+      },
+    ] as FormSchema[],
+    MES_SHIFT_PRD: [
+      {
+        field: 'PRD_CODE',
+        label: '鏃舵缂栫爜',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '鏃舵鍚嶇О',
+        field: 'PRD_NAME',
+        component: 'Input',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '鐝缂栫爜',
+        field: 'SFT_CODE',
+        component: 'Select',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+        componentProps: () => {
+          const options = _data['MES_SHIFT'].map((entity) => ({
+            value: entity.SFT_CODE,
+            label: entity.SFT_NAME,
+          }));
+          return {
+            options: options,
+          };
+        },
+        // dynamicDisabled: ({ values }) => {
+        //   return true;
+        // },
+      },
+      {
+        label: '鏃舵寮�濮嬫椂闂�',
+        field: 'PRD_BEGIN',
+        component: 'TimePicker',
+        colProps: {
+          span: 12,
+        },
+        componentProps: ({ formModel }) => {
+          return {
+            format: 'HH:mm',
+          };
+        },
+      },
+      {
+        label: '缁撴潫鏃堕棿',
+        field: 'PRD_END',
+        component: 'TimePicker',
+        colProps: {
+          span: 12,
+        },
+        componentProps: ({ formModel }) => {
+          return {
+            format: 'HH:mm',
+          };
+        },
+      },
+      {
+        label: '鏃舵鎺掑簭',
+        field: 'SEQ',
+        component: 'InputNumber',
+        colProps: {
+          span: 24,
+        },
+      },
+      {
+        label: '鏄惁璺ㄥぉ',
+        field: 'IS_ACROSS',
+        component: 'Select',
+        required: true,
+        colProps: {
+          span: 24,
+        },
+        componentProps: {
+          options: [
+            {
+              label: '鏄�',
+              value: 'Y',
+              key: 'Y',
+            },
+            {
+              label: '鍚�',
+              value: 'N',
+              key: 'N',
+            },
+          ],
+        },
+      },
+      {
+        label: '鏄惁浼戞伅鏃舵',
+        field: 'IS_REST',
+        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