From 8e288eefbd4e8dbf7d0180dd880ce93256daa7a5 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 22 六月 2024 01:05:18 +0800
Subject: [PATCH] 低代码优化

---
 src/views/tigerprojects/system/lowcode/data.ts |  300 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 223 insertions(+), 77 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts
index 57bd4b3..6e7c47b 100644
--- a/src/views/tigerprojects/system/lowcode/data.ts
+++ b/src/views/tigerprojects/system/lowcode/data.ts
@@ -18,84 +18,97 @@
  *                                //.-~~~-~_--~- |-------~~~~~~~~
  *                                       //.-~~~--\
  *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * 
+ *
  *                               绁炲吔淇濅綉            姘告棤BUG
  */
-
 
 /*
  * @Description: 閫氱敤浣庝唬鐮佸憟鐜伴〉闈富鏁版嵁
  * @Author: Ben Lin
- * @version: 
+ * @version:
  * @Date: 2024-06-02 17:52:35
  * @LastEditors: Ben Lin
  * @LastEditTime: 2024-06-14 09:08:11
  */
 
 import {
-  DftGrpRelease,
   dftGrpOpenSelectItem,
   dftGrpGetSelectSuccess,
   dftGrpactionColumn,
   baseSchema,
-  DftGrpEdit,
   searchSchema,
   defectBaseColumn,
   crudSchema,
-  DftGrpDel,
+  dftEditeOperation,
 } from './normal/basDefectGrp';
-import { onChangeFns, rsGrpGetSelectSuccess, rsGrpOpenSelectItem } from './normal/basReasonGrp';
-import { DeleteEntity } from '/@/api/tigerapi/system';
+import {
+  onChangeFns,
+  rsGrpGetSelectSuccess,
+  rsGrpOpenSelectItem,
+  rsnBaseSchema,
+  rsnCrudSchema,
+  rsnSearchSchema,
+  rsnBaseColumn,
+  rsnEditeOperation,
+} from './normal/basReasonGrp';
+import { DeleteEntity, convertToTree, getEntity } from '/@/api/tigerapi/system';
 import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
 import { useI18n } from '/@/hooks/web/useI18n';
 import { isNullOrEmpty } from '/@/utils/is';
 import { woCustFn, woformSchema } from '/@/views/components/bizMesWo';
 import { useModal } from '/@/components/Modal';
-import { goDetail, labelActionItem, labelGetSelectSuccess, labelOpenSelectItem } from './detail/basLabelVar';
+import {
+  labelGetSelectSuccess,
+  labelOpenSelectItem,
+} from './detail/basLabelVar';
 import { buildUUID } from '/@/utils/uuid';
-import { Tag } from 'ant-design-vue';
 import { Ref, h } from 'vue';
+import {
+  pkgBaseColumn,
+  pkgBaseSchema,
+  pkgCrudSchema,
+  pkgEditeOperation,
+  pkgSearchSchema,
+} from './basPkgrule';
+import { GetRoutePTree } from '/@/api/tigerapi/mes/router';
 
 const { t } = useI18n();
-
 /**
  * @description: 浣庝唬鐮侀〉闈㈣幏鍙栨搷浣滃瓧娈电粨鏋凧son锛屽澧炲姞鎸夐挳鍙婃柟娉�
+ * 鏀荤暐:
+ *  1. 鍙︽柊寤洪┘宄板疄浣撳悕.ts鐨勬枃浠讹紝濡傦細basDefectGrp.ts銆備互渚垮尯鍒笉鍚岄〉闈㈢殑鏂规硶
+ *  2. 鏇挎崲涓婚〉闈㈢紪杈戞寜閽柟娉曞彉涓鸿烦杞埌楂樼骇椤甸潰锛屾柟娉曚腑浼犲叆 { CODE: 涓昏〃璁板綍鐨勫叧閿瓧娈靛�硷紝涓�鑸槸XXX_CODE鐨勫��, ID: 褰撳墠璁板綍鐨処D, Name: 'BAS_DEFECT'锛堣烦杞繃鍘婚渶瑕佹柊澧炵紪杈戠殑瀹炰綋鍚嶏級, Title: `缂栬緫涓嶈壇浠g爜缁勶細${params['record']['DFTG_CODE']}`锛堝畾涔塼ab椤电鐨勬爣棰橈級, pCode: 'DFTG_CODE'锛堜富琛ㄧ殑鍏抽敭瀛楁浠g爜锛� }
+ *     鏇挎崲涓婚〉闈㈡柊澧炴寜閽柟娉曞悓涓�
+ *  3. 鍦ㄨ彍鍗曠鐞嗘柊寤轰竴涓珮绾ч〉闈€��
+ *  4. 閰嶇疆楂樼骇椤甸潰锛屽畾涔夎〃鍗曞垪 getFormSchema
+ *  5. 鍒濆鍖栬〃鏍� GetBasicColumnAndInit
+ *  6. 璁剧疆杩斿洖 getHomeUrl
+ *  7. 璁剧疆鏍囬 getTitle
+ *  8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getOthersValues
+ *  9. 鏇挎崲鍒犻櫎鏂规硶 GetActionsData
  * @param {*} params
  * @param {array} args
  * @return {*}
  */
-export function GetActionsData(params: {}, ...args: Fn[]) {
-  let data = [
-    {
-      icon: 'clarity:note-edit-line',
-      onClick: editRecord.bind(null, args[0], params),
-    },
-    {
-      icon: 'ant-design:delete-outlined',
-      color: 'error',
-      popConfirm: {
-        title: '鏄惁纭鍒犻櫎?',
-        placement: 'left',
-        confirm: deleteRecord.bind(null, args[1], params),
-      },
-    },
-  ] as ActionItem[];
-  switch (params['entityName']) {
-    /* 涓嶈壇浠g爜缁� */
-    case 'BAS_DEFECT_GRP':
-      data[0].onClick = DftGrpEdit.bind(null, args, params);
-      break;
-    case 'BAS_DEFECT':
-      data[1].popConfirm.confirm = DftGrpDel.bind(null, args, params);
-      break;
-    /* 鏍囩妯℃澘 */
-    case 'BAS_LABEL_TEMP':
-      const _data = labelActionItem;
-      _data[0].onClick = goDetail.bind(null, args[5], params['record'])
-      data = [...data, ..._data];
-      break;
-  }
+export function GetActionsData(params: {}, ...args) {
+  let data = [] as ActionItem[];
   return data;
+}
+
+/**
+ * @description: 鏄庣粏琛ㄤ腑缂栬緫鏂规硶
+ * @return {*}
+ */
+export function EditOperation(type: string, data: Ref<any[]>, d, u) {
+  switch (type) {
+    case 'BAS_PKG_DTL':
+      return pkgEditeOperation(data, d, u);
+      break;
+    case 'BAS_REASON':
+      return rsnEditeOperation(data, d, u);
+    case 'BAS_DEFECT':
+      return dftEditeOperation(data, d, u);
+  }
 }
 
 /**
@@ -109,7 +122,38 @@
     case 'BAS_DEFECT_GRP':
       data.action = 'go';
       data.url = 'BAS_DEFECT/High';
-      data.params = { CODE: '0', ID: buildUUID(), Name: 'BAS_DEFECT', Title: '鏂板涓嶈壇浠g爜缁�', pCode: 'DFTG_CODE' };
+      data.params = {
+        CODE: '0',
+        ID: buildUUID(),
+        Name: 'BAS_DEFECT',
+        Title: '鏂板涓嶈壇浠g爜缁�',
+        pCode: 'DFTG_CODE',
+        IsID: false,
+      };
+      break;
+    case 'BAS_REASON_GRP':
+      data.action = 'go';
+      data.url = 'BAS_REASON/High';
+      data.params = {
+        CODE: '0',
+        ID: buildUUID(),
+        Name: 'BAS_REASON',
+        Title: '鏂板涓嶈壇鍘熷洜缁�',
+        pCode: 'RSNG_CODE',
+        IsID: false,
+      };
+      break;
+    case 'BAS_PKG_RULE':
+      data.action = 'go';
+      data.url = 'BAS_PKG_DTL/High';
+      data.params = {
+        CODE: '0',
+        ID: buildUUID(),
+        Name: 'BAS_PKG_DTL',
+        Title: '鏂板鍖呰瑙勫垯',
+        pCode: 'PKG_RULE_ID',
+        IsID: true,
+      };
       break;
   }
   return data;
@@ -128,32 +172,6 @@
       break;
   }
   return data;
-}
-
-/**
- * @description: 鍏敤缂栬緫鏂规硶
- * @param {Fn} fn
- * @param {*} params
- * @return {*}
- */
-function editRecord(fn: Fn, params: {}) {
-  fn(true, params);
-}
-
-/**
- * @description: 鍏敤鍒犻櫎鏂规硶
- * @param {Fn} fn
- * @param {*} params
- * @return {*}
- */
-function deleteRecord(fn: Fn, params: {}) {
-  console.log(params['record']);
-  //鍒犻櫎
-  DeleteEntity(params['record'], params['entityName']).then((action) => {
-    if (action.IsSuccessed) {
-      fn();
-    }
-  });
 }
 
 /**
@@ -265,6 +283,7 @@
         ],
         tableName: 'BAS_ITEM',
         rowKey: 'ITEM_CODE',
+        searchInfo: { TABLE_NAME: 'BAS_ITEM' },
       });
       break;
   }
@@ -285,10 +304,10 @@
         break;
       default:
         break;
-        (e) => { };
+        (e) => {};
     }
   } else {
-    (e) => { };
+    (e) => {};
   }
 }
 
@@ -339,6 +358,7 @@
         ],
         tableName: 'BAS_ITEM',
         rowKey: 'ITEM_CODE',
+        searchInfo: { TABLE_NAME: 'BAS_ITEM' },
       });
       break;
   }
@@ -355,7 +375,7 @@
     case 'BIZ_MES_WO':
       _formSchema = woformSchema;
       break;
-    case 'BaseForm':
+    case 'BAS_DEFECT_BaseForm':
       _formSchema = baseSchema;
       break;
     case 'BAS_DEFECT_Search':
@@ -363,6 +383,24 @@
       break;
     case 'BAS_DEFECT_Crud':
       _formSchema = crudSchema;
+      break;
+    case 'BAS_REASON_BaseForm':
+      _formSchema = rsnBaseSchema;
+      break;
+    case 'BAS_REASON_Search':
+      _formSchema = rsnSearchSchema;
+      break;
+    case 'BAS_REASON_Crud':
+      _formSchema = rsnCrudSchema;
+      break;
+    case 'BAS_PKG_DTL_BaseForm':
+      _formSchema = pkgBaseSchema;
+      break;
+    case 'BAS_PKG_DTL_Search':
+      _formSchema = pkgSearchSchema;
+      break;
+    case 'BAS_PKG_DTL_Crud':
+      _formSchema = pkgCrudSchema;
       break;
     default:
       break;
@@ -381,7 +419,7 @@
     case 'BAS_DEFECT':
       data = defectBaseColumn;
       args[0].value[entityName] = getFormSchema(entityName);
-      args[0].value['BaseForm'] = getFormSchema('BaseForm');
+      args[0].value['BaseForm'] = getFormSchema('BAS_DEFECT_BaseForm');
       args[1].value = {
         BaseForm: args[4]({
           labelWidth: 120,
@@ -393,7 +431,13 @@
         }),
       };
       args[2].value = [
-        { name: 'BaseForm', slots: [], preIcons: {}, title: '涓嶈壇浠g爜缁勪俊鎭�', entityName: 'BAS_DEFECT_GRP' },
+        {
+          name: 'BaseForm',
+          slots: [],
+          preIcons: {},
+          title: '涓嶈壇浠g爜缁勪俊鎭�',
+          entityName: 'BAS_DEFECT_GRP',
+        },
         // {
         //   name: 'prodinfo',
         //   slots: ['addRot', 'setRot'],
@@ -401,6 +445,52 @@
         //   title: '浜у搧淇℃伅',
         // },
         // { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' },
+      ];
+      break;
+    case 'BAS_REASON':
+      data = rsnBaseColumn;
+      args[0].value['BaseForm'] = getFormSchema('BAS_REASON_BaseForm');
+      args[1].value = {
+        BaseForm: args[4]({
+          labelWidth: 120,
+          schemas: args[0].value['BaseForm'],
+          actionColOptions: {
+            span: 24,
+          },
+          showActionButtonGroup: false,
+        }),
+      };
+      args[2].value = [
+        {
+          name: 'BaseForm',
+          slots: [],
+          preIcons: {},
+          title: '涓嶈壇鍘熷洜缁勪俊鎭�',
+          entityName: 'BAS_REASON_GRP',
+        },
+      ];
+      break;
+    case 'BAS_PKG_DTL':
+      data = pkgBaseColumn;
+      args[0].value['BaseForm'] = getFormSchema('BAS_PKG_DTL_BaseForm');
+      args[1].value = {
+        BaseForm: args[4]({
+          labelWidth: 120,
+          schemas: args[0].value['BaseForm'],
+          actionColOptions: {
+            span: 24,
+          },
+          showActionButtonGroup: false,
+        }),
+      };
+      args[2].value = [
+        {
+          name: 'BaseForm',
+          slots: [],
+          preIcons: {},
+          title: '鍖呰淇℃伅',
+          entityName: 'BAS_PKG_RULE',
+        },
       ];
       break;
     default:
@@ -421,6 +511,18 @@
       const param = { ID: 'BAS_DEFECT_GRP', colSlots: [], crudColSlots: [] };
       url = `/BAS_DEFECT_GRP/LC/${encodeURI(JSON.stringify(param))}`;
       break;
+    case 'BAS_REASON':
+      url = `/BAS_REASON_GRP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_REASON_GRP', colSlots: [], crudColSlots: [] }))}`;
+      break;
+    case 'BAS_PKG_DTL':
+      url = `/BAS_PKG_RULE/LC/${encodeURI(JSON.stringify({ ID: 'BAS_PKG_RULE', colSlots: [], crudColSlots: [] }))}`;
+      break;
+    case 'BAS_LABEL_VAR':
+      url = `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`;
+      break;
+    case 'ProdRouteBinding':
+      url = `/V_BAS_PROD/LC/${encodeURI(JSON.stringify({ ID: 'V_BAS_PROD', colSlots: [], crudColSlots: [] }))}`;
+      break;
     default:
       break;
   }
@@ -436,7 +538,25 @@
   let title = {};
   switch (type) {
     case 'BAS_DEFECT':
-      title = { pageTitle: '涓嶈壇浠g爜缁勭鐞�', pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹唬鐮佺粍鍜屼笉鑹唬鐮併��', baseTableTitle: '涓嶈壇浠g爜绠$悊' };
+      title = {
+        pageTitle: '涓嶈壇浠g爜缁勭鐞�',
+        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹唬鐮佺粍鍜屼笉鑹唬鐮併��',
+        baseTableTitle: '涓嶈壇浠g爜绠$悊',
+      };
+      break;
+    case 'BAS_REASON':
+      title = {
+        pageTitle: '涓嶈壇鍘熷洜缁勭鐞�',
+        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹師鍥犵粍鍜屼笉鑹唬鐮併��',
+        baseTableTitle: '涓嶈壇鍘熷洜绠$悊',
+      };
+      break;
+    case 'BAS_PKG_DTL':
+      title = {
+        pageTitle: '鍖呰瑙勫垯绠$悊',
+        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀瑰寘瑁呰鍒欏拰鍖呰淇℃伅銆�',
+        baseTableTitle: '鍖呰淇℃伅绠$悊',
+      };
       break;
     default:
       break;
@@ -450,11 +570,17 @@
  * @param {string} val
  * @return {*}
  */
-export function getOthersValues(type: string, val: string) {
+export function getOthersValues(type: string, val: string, id: string) {
   let Values = {};
   switch (type) {
     case 'BAS_DEFECT':
       Values = { DFTG_CODE: val };
+      break;
+    case 'BAS_REASON':
+      Values = { RSNG_CODE: val };
+      break;
+    case 'BAS_PKG_DTL':
+      Values = { PKG_RULE_ID: id };
       break;
     default:
       break;
@@ -462,4 +588,24 @@
   return Values;
 }
 
-
+/**
+ * @description: 鑾峰彇鏍戝舰鏁版嵁
+ * @param {string} type
+ * @return {*}
+ */
+export async function fetchTreeData(type: string, itemCode: string) {
+  let data = { title: '', treeData: [] as any[], fieldNames: {} };
+  switch (type) {
+    case 'ProdRouteBinding':
+      let prodTreeData = await GetRoutePTree(itemCode);
+      data.treeData = convertToTree(prodTreeData, 'pid', 'id', 'root');
+      data.title = '宸ヨ壓璺嚎';
+      data.fieldNames = { key: 'id', title: 'name' };
+      break;
+    case 'BAS_PKG_DTL':
+      break;
+    default:
+      break;
+  }
+  return data;
+}

--
Gitblit v1.9.3