From a82003f4cf9ae6b69f70212374b3a71090f1770f Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 27 七月 2024 13:24:37 +0800
Subject: [PATCH] 打印模板更新为高级页面

---
 src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts |  738 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 679 insertions(+), 59 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 d14c700..c3d087d 100644
--- a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts
+++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts
@@ -4,15 +4,19 @@
  * @version:
  * @Date: 2024-06-19 20:34:27
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-07-20 21:18:56
+ * @LastEditTime: 2024-07-27 13:22:30
  */
 
 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, unref } from 'vue';
+import { AddAfterDelete, getEntity, GetEnum } from '/@/api/tigerapi/system';
 import { useLocale } from '/@/locales/useLocale';
+import { useDrawer } from '/@/components/Drawer';
+import { formatTime } from '/@/utils/dateUtil';
+import { Search } from '../data';
+import { buildUUID } from '/@/utils/uuid';
 
 const { getLocale } = useLocale();
 
@@ -30,7 +34,7 @@
   /**
    * @description: 涓�浜涜嚜瀹氫箟鏂规硶
    * @return {*}
-   */  
+   */
   const methods = {
     /**
      * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓猴紝蹇呴渶瑕佹湁鐨勬柟娉�
@@ -51,72 +55,82 @@
     /**
      * @description: 楂樼骇琛ㄥ崟鍜岃鎯呴〉闈㈣繑鍥炰富椤甸潰鐨剈rl
      * @return {*}
-     */    
+     */
     GetHomeUrl: () => {
       return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`;
     },
-    GetBaseColumns: () => {
+    /**
+     * @description: 鑾峰彇涓讳俊鎭�
+     * @return {*}
+     */
+    GetBaseForm: () => {
       return [
         {
-          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: '鍙橀噺绫诲瀷',
-          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));
+          field: 'LABEL_CODE',
+          label: '鏍囩妯℃澘缂栫爜',
+          component: 'Input',
+          required: true,
+          colProps: {
+            span: 8,
           },
         },
         {
-          dataIndex: 'VAR_VALUE',
-          title: '鍙橀噺鍊�',
-          ifShow: true,
-          sorter: true,
-          resizable: true,
+          label: '鏍囩妯℃澘鍚嶇О',
+          field: 'LABEL_NAME',
+          required: true,
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
         },
         {
-          dataIndex: 'REMARK',
-          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,
+          },
+        },
+        {
+          label: '澶囨敞',
+          field: 'REMARK',
+          component: 'Input',
+          colProps: {
+            span: 16,
+          },
+        },
+        {
+          label: 'ID',
+          field: 'ID',
+          component: 'Input',
+          colProps: {
+            span: 8,
+          },
+          show: false,
         },
       ];
+    },
+    GetBaseColumns: () => {
+      return [];
     },
     GetSearchForm: () => {
       return [
@@ -215,6 +229,612 @@
     GetUseForm: () => {
       return {};
     },
+    /**
+     * @description: 鑾峰彇鏍囬淇℃伅
+     * @param {string} type
+     * @return {*}
+     */
+    GetTitle: () => {
+      return {
+        pageTitle: '鎵撳嵃妯℃澘绠$悊',
+        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀规ā鏉垮拰妯℃澘鍙橀噺鍙婂伐鍗曟ā鏉垮彉閲忋��',
+        tableTitle: {
+          BAS_LABEL_VAR: '妯℃澘鍙橀噺绠$悊',
+          MES_SHIFT_PRD: '鏃舵绠$悊',
+        },
+      };
+    },
+    /**
+     * @description: 鑾峰彇鍗$墖鍐呴厤缃垪琛紝浠ュ惊鐜樉绀哄涓崱鐗囧苟閰嶇疆澶氫釜鎻掓Ы
+     * @return {*}
+     */
+    GetBaseCards: (type: string) => {
+      return [
+        {
+          name: 'BaseForm',
+          slots: [],
+          preIcons: {},
+          title: '妯℃澘淇℃伅',
+          entityName: 'BAS_LABEL_TEMP',
+        },
+      ];
+    },
+    /**
+     * @description: 鑾峰彇鍙充晶杈规use鏂规硶
+     * @return {*}
+     */
+    GetUseDrawers: () => {
+      return [
+        {
+          BAS_LABEL_VAR: useDrawer(),
+        },
+        // { MES_SHIFT_PRD: 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: baseColumns['BAS_LABEL_VAR'],
+          maxHeight: 560,
+          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,
+          actionColumn: {
+            width: 130,
+            title: '鎿嶄綔',
+            dataIndex: 'action',
+            slots: { customRender: 'action' },
+            fixed: 'right',
+          }, //鑷畾涔夋搷浣滃垪
+        }),
+        //  MES_SHIFT_PRD: useTable({
+        //    title: '鍒楄〃淇℃伅',
+        //    dataSource: data.value['MES_SHIFT_PRD'],
+        //    columns: baseColumns['MES_SHIFT_PRD'],
+        //    maxHeight: 550,
+        //    formConfig: {
+        //      labelWidth: 140,
+        //      schemas: searchForms['MES_SHIFT_PRD'],
+        //      submitFunc: () => Search('MES_SHIFT_PRD', 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: 鎻愪氦鎵�鏈�
+     * @return {*}
+     */
+    SubmitAll: (data: Ref<any[]>, keyFieldValues: Ref<{}>, ...args) => {
+      const drawers = [
+        { name: 'BAS_LABEL_VAR', code: 'LABEL_ID', type: 'one', keyName: 'BAS_LABEL_VAR', order: 'VAR_NAME' },
+        // { name: 'MES_SHIFT_PRD', code: 'SFT_CODE', type: 'all', keyName: 'MES_SHIFT', order: '' },
+      ];
+      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'] == 'MES_SHIFT') {
+          //   item.SFT_BEGIN = tsToHHmm(item.SFT_BEGIN);
+          //   item.SFT_END = tsToHHmm(item.SFT_END);
+          // }
+          // if (d['name'] == 'MES_SHIFT_PRD') {
+          //   item.PRD_BEGIN = tsToHHmm(item.PRD_BEGIN);
+          //   item.PRD_END = tsToHHmm(item.PRD_END);
+          // }
+        });
+        AddAfterDelete(d['name'], data.value[d['name']], where).then((action) => {
+          if (action.IsSuccessed) {
+            args[0]();
+          }
+        });
+      });
+    },
+  };
+
+  /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport */
+
+  /**
+   * @description: 琛ㄦ牸鍩烘湰瀛楁
+   * @return {*}
+   */
+  const baseColumns = {
+    BAS_LABEL_VAR: [
+      {
+        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: '鍙橀噺绫诲瀷',
+        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));
+        },
+      },
+      {
+        dataIndex: 'VAR_VALUE',
+        title: '鍙橀噺鍊�',
+        ifShow: true,
+        sorter: true,
+        resizable: true,
+      },
+      {
+        dataIndex: 'REMARK',
+        title: '澶囨敞',
+        ifShow: true,
+        sorter: true,
+        resizable: true,
+      },
+    ],
+    MES_SHIFT_PRD: [
+      {
+        title: '鏃舵缂栫爜',
+        dataIndex: 'PRD_CODE',
+        // ifShow: false,
+        width: 180,
+      },
+      {
+        title: '鏃舵鍚嶇О',
+        dataIndex: 'PRD_NAME',
+      },
+      {
+        title: '鐝缂栫爜',
+        dataIndex: 'SFT_CODE',
+      },
+      {
+        title: '鏃舵寮�濮嬫椂闂�',
+        dataIndex: 'PRD_BEGIN',
+        customRender: ({ record }) => {
+          return formatTime(new Date(record.PRD_BEGIN));
+        },
+      },
+      {
+        title: '鏃舵缁撴潫鏃堕棿',
+        dataIndex: 'PRD_END',
+        customRender: ({ record }) => {
+          return formatTime(new Date(record.PRD_END));
+        },
+      },
+      {
+        title: '鏄惁璺ㄥぉ',
+        dataIndex: 'IS_ACROSS',
+        customRender: ({ record }) => {
+          const type = record.IS_ACROSS;
+          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: 'IS_REST',
+        customRender: ({ record }) => {
+          const type = record.IS_REST;
+          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: 'SEQ',
+      },
+      {
+        title: '澶囨敞',
+        dataIndex: 'REMARK',
+      },
+      {
+        title: '鏇存柊鏃堕棿',
+        dataIndex: 'UPDATE_TIME',
+      },
+      {
+        title: '鏇存柊浜�',
+        dataIndex: 'UPDATE_USER',
+      },
+    ],
+  };
+
+  /**
+   * @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