From 2abb91c893f2eed3761bd09aabe12400460d2863 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期五, 21 六月 2024 00:16:35 +0800
Subject: [PATCH] 产品工艺路线更新

---
 src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts |  394 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 382 insertions(+), 12 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts
index b612a93..54cb082 100644
--- a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts
+++ b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts
@@ -1,22 +1,392 @@
-import { ActionItem, BasicColumn } from '/@/components/Table';
-import { useMessage } from '/@/hooks/web/useMessage';
+import { Ref, h, unref } from 'vue';
+import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
+import { useI18n } from '/@/hooks/web/useI18n';
+import { useLocale } from '/@/locales/useLocale';
+import { Tag } from 'ant-design-vue';
+import { DeleteEntity, GetEnum, getEntity } from '/@/api/tigerapi/system';
+import { isNullOrEmpty } from '/@/utils/is';
+import { buildUUID } from '/@/utils/uuid';
+import { useUserStore } from '/@/store/modules/user';
+import { formatToDateTime } from '/@/utils/dateUtil';
 
-const { notification } = useMessage();
-/* 鑷畾涔夋寜閽柟娉� */
-export function DftGrpRelease(fn: Fn, params: {}) {
+const { t } = useI18n();
+const { getLocale } = useLocale();
+
+/**
+ * @description: 鑷畾涔夋寜閽柟娉�
+ * @param {Fn} args
+ * @param {*} params
+ * @return {*}
+ */
+export function DftGrpRelease(args: Fn[], params: {}) {
   console.log('鐐瑰嚮浜嗕笅鍙戞寜閽�');
-  notification.success({
-    message: '鐐瑰嚮浜嗕笅鍙戞寜閽�',
-    description: `${params.entityName}`,
-    duration: 3,
+  // notification.success({
+  //   message: '鐐瑰嚮浜嗕笅鍙戞寜閽�',
+  //   description: `${params.entityName}`,
+  //   duration: 3,
+  // });
+  // reload();
+  // if (params.STATUS == 2) {
+  //   createErrorModal({
+  //     title: t('璀﹀憡'),
+  //     content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'),
+  //     getContainer: () => document.body,
+  //   });
+  //   return;
+  // }
+  params['dtlSlots'].value = [
+    {
+      name: 'forminfo',
+      slots: ['add', 'set'],
+      preIcons: { add: 'search|svg', set: 'config|svg' }, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы銆俿lots鏄脊鍑烘鎸夐挳鐨勬彃妲斤紝preIcons鏄彃妲藉搴旂殑鎸夐挳鍥炬爣
+      title: '涓嬪彂閰嶇疆',
+    },
+  ];
+
+  args[2](true, {
+    isUpdate: true, //鏄惁鏇存柊鎿嶄綔
+    ctype: params['cType'].value, //鏄摢涓〉闈�
+    title: '宸ュ崟涓嬪彂', //鏍囬
+    width: '900px', //寮瑰嚭妗嗗搴�
+    formEl: params['useFormData'].value,
+    formElName: ['forminfo'], //琛ㄥ崟鎻掓Ы鍚嶇О
+    RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode
+    fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //淇濆瓨鏂规硶鍚�
+    initFnName: {}, //鍒濆鍖栨柟娉曞悕
+    values: params['record'], //琛ㄥ崟璁板綍
   });
-  fn();
+}
+
+/**
+ * @description: 鑷畾涔夌紪杈戞柟娉�
+ * @param {Fn} args
+ * @param {*} params
+ * @return {*}
+ */
+export function DftGrpEdit(args: Fn[], params: {}) {
+  const param = { CODE: params['record']['DFTG_CODE'], ID: params['record']['ID'], Name: 'BAS_DEFECT', Title: `缂栬緫涓嶈壇浠g爜缁勶細${params['record']['DFTG_CODE']}`, pCode: 'DFTG_CODE', IsID: false };
+  args[5](`/BAS_DEFECT/High/${encodeURI(JSON.stringify(param))}`);
+}
+
+/**
+ * @description: 鑷畾涔夊垹闄ゆ柟娉�
+ * @param {Fn} args
+ * @param {*} params
+ * @return {*}
+ */
+export function DftGrpDel(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]();
+      }
+    });
+  }
+}
+
+/**
+ * @description: 鑷畾涔夋槑缁嗚〃涓紪杈戣繑鍥炴柟娉�
+ * @param {string} type
+ * @param {*} d
+ * @param {*} u
+ * @return {*}
+ */
+export function dftEditeOperation(data: Ref<any[]>, d, u) {
+  if (u.isUpdate) {
+    //鏇存柊
+    var _data = data.value.map((item) => {
+      if (item['ID'] == d.ID)
+        return {
+          ...item,
+          DFT_CODE: d.DFT_CODE,
+          DFT_NAME: d.DFT_NAME,
+          DFT_LEVEL: d.DFT_LEVEL,
+          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;
+  }
 }
 
 export const dftGrpactionColumn: BasicColumn = {
-  width: 180,
+  width: 100,
   title: '鎿嶄綔',
   dataIndex: 'action',
   slots: { customRender: 'action' },
-  fixed: undefined,
+  fixed: 'right',
 };
+
+// export const dftGrpActionItem: ActionItem[] =[
+//   {
+//     icon: 'clarity:note-edit-line',
+//     onClick: () => {},
+//   },
+//   {
+//     icon: 'ant-design:delete-outlined',
+//     color: 'error',
+//     popConfirm: {
+//       title: '鏄惁纭鍒犻櫎?',
+//       placement: 'left',
+//       confirm: () => {},
+//     },
+//   },
+// ];
+
+export function dftGrpGetSelectSuccess(d, u) {
+  return {
+    ITEM_CODE: d.values['val'],
+  };
+}
+
+export function dftGrpOpenSelectItem(openItemModal: Fn) {
+  openItemModal(true, {
+    title: '鐗╂枡鍒楄〃',
+    schemas: [
+      {
+        field: 'ITEM_CODE',
+        component: 'Input',
+        label: '鐗╂枡缂栫爜',
+        colProps: {
+          span: 12,
+        },
+      },
+    ],
+    ItemColumns: [
+      {
+        title: t('鐗╂枡缂栫爜'),
+        dataIndex: 'ITEM_CODE',
+        resizable: true,
+        sorter: true,
+        width: 200,
+      },
+      {
+        title: t('鐗╂枡鍚嶇О'),
+        dataIndex: 'ITEM_NAME',
+        resizable: true,
+        sorter: true,
+        width: 180,
+      },
+    ],
+    tableName: 'BAS_ITEM',
+    rowKey: 'ITEM_CODE',
+    searchInfo: {TABLE_NAME: 'BAS_ITEM'}
+  });
+}
+
+/**
+ * @description: 涓嶈壇浠g爜鍩烘湰淇℃伅
+ * @return {*}
+ */
+export const baseSchema: FormSchema[] = [
+  {
+    field: 'DFTG_CODE',
+    label: '涓嶈壇浠g爜缁勭紪鐮�',
+    component: 'Input',
+    required: true,
+    colProps: {
+      span: 8,
+    },
+  },
+  {
+    label: '涓嶈壇浠g爜缁勫悕绉�',
+    field: 'DFTG_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,
+  },
+];
+
+export const searchSchema: FormSchema[] = [
+  {
+    field: 'DFT_CODE',
+    label: '涓嶈壇浠g爜缂栫爜',
+    component: 'Input',
+    colProps: {
+      span: 8,
+    },
+  },
+  {
+    label: '涓嶈壇浠g爜鍚嶇О',
+    field: 'DFT_NAME',
+    component: 'Input',
+    colProps: {
+      span: 8,
+    },
+  },
+];
+
+/**
+ * @description: 鑾峰彇涓嶈壇浠g爜澧炲垹鏀硅〃鍗�
+ * @return {*}
+ */
+export const crudSchema: FormSchema[] = [
+  {
+    field: 'DFT_CODE',
+    label: '涓嶈壇浠g爜缂栫爜',
+    component: 'Input',
+    required: true,
+    colProps: {
+      span: 24,
+    },
+  },
+  {
+    label: '涓嶈壇浠g爜鍚嶇О',
+    field: 'DFT_NAME',
+    component: 'Input',
+    required: true,
+    colProps: {
+      span: 24,
+    },
+  },
+  {
+    label: '涓嶈壇浠g爜缁勭紪鐮�',
+    field: 'DFTG_CODE',
+    component: 'ApiSelect',
+    colProps: {
+      span: 24,
+    },
+    componentProps: {
+      api: getEntity,
+      params: { entityName: 'BAS_DEFECT_GRP', sqlcmd: ' 1=1 ' },
+      resultField: 'Data.Items',
+      labelField: 'DFTG_NAME',
+      valueField: 'DFTG_CODE',
+    },
+    dynamicDisabled: ({ values }) => {
+      return true;
+    },
+  },
+  {
+    label: '缂洪櫡绛夌骇',
+    field: 'DFT_LEVEL',
+    component: 'ApiSelect',
+    required: true,
+    colProps: {
+      span: 24,
+    },
+    componentProps: {
+      api: GetEnum,
+      params: { name: 'BAS_DEFECT+DFT_LEVELs' },
+      resultField: 'Data',
+      labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
+      valueField: 'Value',
+    },
+  },
+  {
+    label: '澶囨敞',
+    field: 'REMARK',
+    component: 'Input',
+    colProps: {
+      span: 24,
+    },
+  },
+  {
+    label: 'ID',
+    field: 'ID',
+    component: 'Input',
+    colProps: {
+      span: 24,
+    },
+    show: false,
+  },
+];
+
+/**
+ * @description: 涓嶈壇浠g爜琛ㄦ牸鍒�
+ * @return {*}
+ */
+export const defectBaseColumn: BasicColumn[] = [
+  {
+    title: '涓嶈壇浠g爜缂栫爜',
+    dataIndex: 'DFT_CODE',
+    // ifShow: false,
+    width: 180,
+  },
+  {
+    title: '涓嶈壇浠g爜鍚嶇О',
+    dataIndex: 'DFT_NAME',
+  },
+  {
+    title: '缂洪櫡绛夌骇',
+    dataIndex: 'DFT_LEVEL',
+    customRender: ({ record }) => {
+      const type = record.DFT_LEVEL;
+      var text = '';
+      var color = 'green';
+      switch (type) {
+        case 0:
+          text = '杞诲井缂洪櫡';
+          break;
+        case 1:
+          color = 'blue';
+          text = '涓ラ噸缂洪櫡';
+          break;
+        case 2:
+          color = 'red';
+          text = '鑷村懡缂洪櫡';
+          break;
+      }
+      return h(Tag, { color: color }, () => text);
+    },
+  },
+  {
+    title: '涓嶈壇浠g爜缁勭紪鐮�',
+    dataIndex: 'DFTG_CODE',
+  },
+  {
+    title: '澶囨敞',
+    dataIndex: 'REMARK',
+  },
+  {
+    title: '鏇存柊鏃堕棿',
+    dataIndex: 'UPDATE_TIME',
+  },
+  {
+    title: '鏇存柊浜�',
+    dataIndex: 'UPDATE_USER',
+  },
+];

--
Gitblit v1.9.3