From 21a4e09672b1177d40c2bb5b937a8780c5eaa7fb Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 08 三月 2025 15:03:34 +0800
Subject: [PATCH] 一些更新

---
 src/views/tigerprojects/system/lowcode/data.ts |  848 ++++++++++++++++++-------------------------------------
 1 files changed, 283 insertions(+), 565 deletions(-)

diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts
index ca94f66..f5ac450 100644
--- a/src/views/tigerprojects/system/lowcode/data.ts
+++ b/src/views/tigerprojects/system/lowcode/data.ts
@@ -1,93 +1,35 @@
 /*
- *                                                     __----~~~~~~~~~~~------___
- *                                    .  .   ~~//====......          __--~ ~~
- *                    -.            \_|//     |||\\  ~~~~~~::::... /~
- *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
- *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
- *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
- *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
- *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
- *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
- *           '         ~-|      /|    |-~\~~       __--~~
- *                       |-~~-_/ |    |   ~\_   _-~            /\
- *                            /  \     \__   \/~                \__
- *                        _--~ _/ | .-~~____--~-/                  ~~==.
- *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
- *                                  -_     ~\      ~~---l__i__i__i--~~_/
- *                                  _-~-__   ~)  \--______________--~~
- *                                //.-~~~-~_--~- |-------~~~~~~~~
- *                                       //.-~~~--\
- *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *                               绁炲吔淇濅綉            姘告棤BUG
- */
-
-/*
  * @Description: 閫氱敤浣庝唬鐮佸憟鐜伴〉闈富鏁版嵁
  * @Author: Ben Lin
  * @version:
  * @Date: 2024-06-02 17:52:35
  * @LastEditors: Ben Lin
- * @LastEditTime: 2024-06-14 09:08:11
+ * @LastEditTime: 2024-10-23 23:01:49
  */
 
-import {
-  dftGrpOpenSelectItem,
-  dftGrpGetSelectSuccess,
-  dftGrpactionColumn,
-  baseSchema,
-  DftGrpEdit,
-  searchSchema,
-  defectBaseColumn,
-  crudSchema,
-  DftGrpDel,
-  dftEditeOperation,
-} from './normal/basDefectGrp';
-import {
-  onChangeFns,
-  rsnGrpEdit,
-  rsGrpGetSelectSuccess,
-  rsGrpOpenSelectItem,
-  rsnBaseSchema,
-  rsnCrudSchema,
-  rsnSearchSchema,
-  rsnBaseColumn,
-  rsnGrpDel,
-  rsnEditeOperation,
-} from './normal/basReasonGrp';
-import { DeleteEntity, convertToTree, getEntity } from '/@/api/tigerapi/system';
-import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
+import { ActionItem, FormSchema, PopConfirm } from '/@/components/Table';
 import { useI18n } from '/@/hooks/web/useI18n';
-import { isNullOrEmpty } from '/@/utils/is';
+import { isArray, isNullOrEmpty, isNullOrUnDef, isTimeViaRegExp8601 } from '/@/utils/is';
 import { woCustFn, woformSchema } from '/@/views/components/bizMesWo';
 import { useModal } from '/@/components/Modal';
-import {
-  goDetail,
-  labelActionItem,
-  labelGetSelectSuccess,
-  labelOpenSelectItem,
-} from './detail/basLabelVar';
+import { Ref, unref } from 'vue';
+import { getRouteData, getWoRouteData } from '/@/api/tigerapi/mes/router';
 import { buildUUID } from '/@/utils/uuid';
-import { Tag } from 'ant-design-vue';
-import { Ref, h } from 'vue';
-import {
-  pkgBaseColumn,
-  pkgBaseSchema,
-  pkgCrudSchema,
-  pkgEditeOperation,
-  pkgGrpEdit,
-  pkgSearchSchema,
-} from './basPkgrule';
-import { GetRoutePTree } from '/@/api/tigerapi/mes/router';
-import { V_MES_ROUTE_PTREE } from '/@/api/tigerapi/model/router';
-import { prodRouteCreateIcon } from './composition/prodRoute';
+import { useUserStore } from '/@/store/modules/user';
+import { dateUtil, formatToDateTime } from '/@/utils/dateUtil';
+import { DeleteEntity, getEntity } from '/@/api/tigerapi/system';
+import { useGo } from '/@/hooks/web/usePage';
+import { useQueryStore } from '/@/store/modules/queryInpage';
+import { RouteRecordName } from 'vue-router';
+import { cloneDeep } from 'lodash-es';
+import dayjs from 'dayjs';
+import { utils } from 'sortablejs';
 
 const { t } = useI18n();
-
 /**
  * @description: 浣庝唬鐮侀〉闈㈣幏鍙栨搷浣滃瓧娈电粨鏋凧son锛屽澧炲姞鎸夐挳鍙婃柟娉�
  * 鏀荤暐:
- *  1. 鍙︽柊寤洪┘宄板疄浣撳悕.ts鐨勬枃浠讹紝濡傦細basDefectGrp.ts銆備互渚垮尯鍒笉鍚岄〉闈㈢殑鏂规硶
+ *  1. 鍙︽柊寤洪┘宄板疄浣撳悕.ts鐨勬枃浠讹紝濡傦細BAS_REASON.ts銆備互渚垮尯鍒笉鍚岄〉闈㈢殑鏂规硶
  *  2. 鏇挎崲涓婚〉闈㈢紪杈戞寜閽柟娉曞彉涓鸿烦杞埌楂樼骇椤甸潰锛屾柟娉曚腑浼犲叆 { CODE: 涓昏〃璁板綍鐨勫叧閿瓧娈靛�硷紝涓�鑸槸XXX_CODE鐨勫��, ID: 褰撳墠璁板綍鐨処D, Name: 'BAS_DEFECT'锛堣烦杞繃鍘婚渶瑕佹柊澧炵紪杈戠殑瀹炰綋鍚嶏級, Title: `缂栬緫涓嶈壇浠g爜缁勶細${params['record']['DFTG_CODE']}`锛堝畾涔塼ab椤电鐨勬爣棰橈級, pCode: 'DFTG_CODE'锛堜富琛ㄧ殑鍏抽敭瀛楁浠g爜锛� }
  *     鏇挎崲涓婚〉闈㈡柊澧炴寜閽柟娉曞悓涓�
  *  3. 鍦ㄨ彍鍗曠鐞嗘柊寤轰竴涓珮绾ч〉闈€��
@@ -95,147 +37,14 @@
  *  5. 鍒濆鍖栬〃鏍� GetBasicColumnAndInit
  *  6. 璁剧疆杩斿洖 getHomeUrl
  *  7. 璁剧疆鏍囬 getTitle
- *  8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getOthersValues
+ *  8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getKeyFieldValues
  *  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;
-    /* 涓嶈壇浠e師鍥犵粍 */
-    case 'BAS_REASON_GRP':
-      data[0].onClick = rsnGrpEdit.bind(null, args, params); //鏇挎崲涓婚〉闈㈢紪杈戞寜閽柟娉曞彉涓鸿烦杞埌楂樼骇椤甸潰
-      break;
-    case 'BAS_DEFECT':
-      data[1].popConfirm.confirm = DftGrpDel.bind(null, args, params);
-      break;
-    case 'BAS_REASON':
-      data[1].popConfirm.confirm = rsnGrpDel.bind(null, args, params);
-      break;
-    /* 鍖呰瑙勫垯 */
-    case 'BAS_PKG_RULE':
-      data[0].onClick = pkgGrpEdit.bind(null, args, params); //鏇挎崲涓婚〉闈㈢紪杈戞寜閽柟娉曞彉涓鸿烦杞埌楂樼骇椤甸潰
-      break;
-    case 'BAS_PKG_DTL':
-      data[1].popConfirm.confirm = custDel.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;
-  }
-  return data;
-}
-
-/**
- * @description: 鑷畾涔夊垹闄ゆ柟娉�
- * @param {Fn} args
- * @param {*} params
- * @return {*}
- */
-export function custDel(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: 鏄庣粏琛ㄤ腑缂栬緫鏂规硶
- * @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);
-  }
-}
-
-/**
- * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓�
- * @param {string} type
- * @return {*}
- */
-export function getCreateAction(type: string) {
-  let data = { action: 'drawer', url: '', params: {} }; //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�)
-  switch (type) {
-    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',
-        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;
-  }
+export function GetActionsData(params: {}, ...args) {
+  const data = [] as ActionItem[];
   return data;
 }
 
@@ -255,147 +64,6 @@
 }
 
 /**
- * @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();
-    }
-  });
-}
-
-/**
- * @description: 鑾峰彇鎿嶄綔鍒楁牱寮忔柟娉�
- * @param {string} entityName
- * @return {*}
- */
-export function GetActionColumn(entityName: string) {
-  let data: BasicColumn = {};
-  switch (entityName) {
-    case 'BAS_DEFECT_GRP':
-      data = dftGrpactionColumn;
-      break;
-    case 'BAS_LABEL_TEMP':
-      data = {
-        width: 120,
-        title: '鎿嶄綔',
-        dataIndex: 'action',
-        slots: { customRender: 'action' },
-        fixed: 'right',
-      };
-      break;
-    default:
-      data = {
-        width: 80,
-        title: '鎿嶄綔',
-        dataIndex: 'action',
-        slots: { customRender: 'action' },
-        fixed: undefined,
-      };
-      break;
-  }
-  return data;
-}
-
-/**
- * @description: 鎵撳紑寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庤繑鍥炴柟娉�
- * @param {*} d
- * @param {*} u
- * @param {string} entityName
- * @return {*}
- */
-export function GetSelectSuccess(d, u, entityName: string) {
-  let data = {};
-  switch (entityName) {
-    case 'BAS_DEFECT_GRP':
-      data = dftGrpGetSelectSuccess(d, u);
-      break;
-    case 'BAS_REASON_GRP':
-      data = rsGrpGetSelectSuccess(d, u);
-      break;
-    case 'BAS_LABEL_PV':
-      data = labelGetSelectSuccess(d, u);
-      break;
-    default:
-      data = {
-        ITEM_CODE: d.values['val'],
-      };
-      break;
-  }
-  return data;
-}
-
-/**
- * @description: 鎵撳紑寮瑰嚭閫夋嫨妗�
- * @param {Fn} openItemModal
- * @param {string} entityName
- * @return {*}
- */
-export function OpenSelectItem(openItemModal: Fn, entityName: string) {
-  switch (entityName) {
-    case 'BAS_DEFECT_GRP':
-      dftGrpOpenSelectItem(openItemModal);
-      break;
-    case 'BAS_REASON_GRP':
-      rsGrpOpenSelectItem(openItemModal);
-      break;
-    case 'BAS_LABEL_PV':
-      labelOpenSelectItem(openItemModal);
-      break;
-    default:
-      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' },
-      });
-      break;
-  }
-}
-
-/**
  * @description: Select 鑷畾涔塷nChange鏂规硶
  * @param {any} e
  * @param {string} fnName
@@ -406,7 +74,7 @@
   if (!isNullOrEmpty(fnName)) {
     switch (entityName) {
       case 'BAS_REASON':
-        onChangeFns[fnName](e);
+        // onChangeFns[fnName](e);
         break;
       default:
         break;
@@ -481,33 +149,6 @@
     case 'BIZ_MES_WO':
       _formSchema = woformSchema;
       break;
-    case 'BAS_DEFECT_BaseForm':
-      _formSchema = baseSchema;
-      break;
-    case 'BAS_DEFECT_Search':
-      _formSchema = searchSchema;
-      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;
   }
@@ -515,219 +156,296 @@
 }
 
 /**
- * @description: 鑾峰彇琛ㄦ牸鍒�
- * @param {string} entityName
+ * @description: 宸ヨ壓璺嚎鍒濆鍖�
+ * @param {*} lf
  * @return {*}
  */
-export function GetBasicColumnAndInit(entityName: string, ...args) {
-  let data: BasicColumn[] = [];
-  switch (entityName) {
-    case 'BAS_DEFECT':
-      data = defectBaseColumn;
-      args[0].value[entityName] = getFormSchema(entityName);
-      args[0].value['BaseForm'] = getFormSchema('BAS_DEFECT_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: '涓嶈壇浠g爜缁勪俊鎭�',
-          entityName: 'BAS_DEFECT_GRP',
-        },
-        // {
-        //   name: 'prodinfo',
-        //   slots: ['addRot', 'setRot'],
-        //   preIcons: { addRot: 'search|svg', setRot: 'config|svg' },
-        //   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:
-      break;
+export async function initRoute(lf, rotId, routeData, currlf, rotType) {
+  currlf.value = unref(lf);
+  //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋
+  const _data = rotType == 'Wo' ? await getWoRouteData(rotId) : await getRouteData(rotId);
+  console.log('缁勪欢宸叉寕杞�', _data);
+  if (_data.Data != null) {
+    _data.Data.nodes.forEach((n) => {
+      n.node.properties = JSON.parse(n.node.properties);
+      n['node']['text']['value'] = n.NODE_NAME;
+      routeData.value.nodes.push(n['node']);
+    });
+    console.log('111', routeData.value);
+    _data.Data.edges.forEach((e) => {
+      e.edge.properties = JSON.parse(e.edge.properties);
+      routeData.value.edges.push(e.edge);
+    });
+    _data.Data.acts.forEach((act) => {
+      act.node.properties = JSON.parse(act.node.properties);
+      routeData.value.nodes.push(act.node);
+    });
+    unref(lf).render(routeData.value);
+    // lf.graphModel.translateCenter();
+    // lf.graphModel.fitView();
   }
-  return data;
+}
+
+/* 楂樼骇琛ㄥ崟鍏敤鏂规硶 *********************************Start */
+
+/**
+ * @description: 鏌ヨ鑷畾涔夋柟娉曪紝褰撳湪楂樼骇琛ㄥ崟涓殑琛ㄦ牸涓煡璇㈡椂瑙﹀彂浜嬩欢锛屽苟鎶妠 type: type, data: data }浼犲埌鐖剁粍浠�
+ * @param {string} type 琛ㄦ牸鐨勫悕瀛楋紝濂界‘瀹氭槸鍝釜琛ㄦ牸瑕佹煡璇�
+ * @param {Ref} data 姝よ〃鏍肩殑鍘熸暟鎹�
+ * @param {*} emit dtl缁勪欢鐨勪簨浠讹紝瑙﹀彂涓�涓�'search'浜嬩欢
+ * @return {*}
+ */
+export async function Search(type: string, data: Ref<any>, emit) {
+  emit('search', { type: type, data: data });
 }
 
 /**
- * @description: 鑾峰彇goback鐨剈rl
- * @param {string} type
+ * @description: 楂樼骇琛ㄥ崟鏂板缂栬緫鏂规硶
+ * @param {Ref} data
+ * @param {*} d
+ * @param {*} u
+ * @param {*} item
+ * @param {*} updates
  * @return {*}
  */
-export function getHomeUrl(type: string) {
-  let url = '';
-  switch (type) {
-    case 'BAS_DEFECT':
-      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 = `/MaterialInfo`;
-      break;
-    default:
-      break;
+export function EditOperation(data: Ref<any[]>, d, u, item, updates) {
+  if (u.isUpdate) {
+    //鏇存柊
+    data.value[item] = updates;
+  } 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;
+    d.AUTH_ORG = useUserStore().getUserInfo.orgCode as string;
+    let _data2: any[] = cloneDeep(data.value[item]);
+    _data2.push(d);
+    data.value[item] = _data2;
   }
-  return url;
 }
 
 /**
- * @description: 鑾峰彇鏍囬淇℃伅
- * @param {string} type
+ * @description: 鑷畾涔夊垹闄ゆ柟娉�
+ * @param {Fn} args
+ * @param {*} params
  * @return {*}
  */
-export function getTitle(type: string) {
-  let title = {};
-  switch (type) {
-    case 'BAS_DEFECT':
-      title = {
-        pageTitle: '涓嶈壇浠g爜缁勭鐞�',
-        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹唬鐮佺粍鍜屼笉鑹唬鐮併��',
-        baseTableTitle: '涓嶈壇浠g爜绠$悊',
+export function custDel(args: Fn[], params: {}) {
+  const name = params['name'];
+  const useTables = args[1];
+  if (!isNullOrEmpty(params['data'])) {
+    const _data = params['data'].value[name].filter((item) => item['ID'] != params['record']['ID']);
+    params['data'].value[name] = _data;
+    useTables[name][1].setProps({
+      dataSource: [],
+    });
+    useTables[name][1].setProps({
+      dataSource: params['data'].value[name],
+    });
+    useTables[name][1].reload();
+  } else {
+    DeleteEntity(params['record'], params['entityName']).then((action) => {
+      if (action.IsSuccessed) {
+        useTables[name][1].reload();
+      }
+    });
+  }
+}
+
+/* 楂樼骇琛ㄥ崟鍏敤鏂规硶 *********************************End */
+
+/**
+ * @description: 鑾峰彇鏉冮檺鎸夐挳鍒楄〃
+ * @param {*} params
+ * @return {*}
+ */
+export function GenerateActionButton(
+  params: any,
+  buttons: Ref<[]>,
+  openDrawer: Fn,
+  reload: Fn,
+  actionItem: ActionItem[],
+) {
+  buttons.value.map((x) => {
+    if (x['BUTTON_TYPE'] == 1) {
+      let url = '';
+      let color = undefined as 'success' | 'error' | 'warning' | undefined;
+      let _click = null as any;
+      let _popConfirm = undefined as PopConfirm | undefined;
+      let _tooltip = '';
+      if (x['DO_METHOD'] == 'Edit') {
+        url = 'clarity:note-edit-line';
+        _tooltip = '缂栬緫';
+        _click = editRecord.bind(null, openDrawer, params);
+      } else {
+        _click = () => {};
+        if (x['DO_METHOD'] == 'Delete') {
+          url = 'ant-design:delete-outlined';
+          color = 'error';
+          _tooltip = '鍒犻櫎';
+          _popConfirm = {
+            title: '鏄惁纭鍒犻櫎?',
+            placement: 'left',
+            confirm: deleteRecord.bind(null, reload, params),
+          };
+        }
+      }
+      if (x['DO_METHOD'] != 'ToPrint') {
+        actionItem.push({
+          icon: isNullOrEmpty(x['ICON_URL']) ? url : x['ICON_URL'],
+          tooltip: _tooltip,
+          onClick: _click,
+          color: color,
+          popConfirm: _popConfirm,
+          name: x['DO_METHOD'],
+        });
+      }
+    }
+  });
+  return actionItem;
+}
+
+/**
+ * @description: 鍏敤缂栬緫鏂规硶
+ * @param {Fn} fn
+ * @param {*} params
+ * @return {*}
+ */
+export 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();
+    }
+  });
+}
+
+/**
+ * @description: 璺宠浆骞舵牴鎹紶鍏ョ殑鍙傛暟閫氳繃session浼犲叆
+ * @param {string} path 璺宠浆鍦板潃
+ * @return {*}
+ */
+export function goByParams(path: string, params: {}, go) {
+  if (path.split('/').length > 2 && path.split('/')[2] == 'LC') {
+    getEntity({
+      sqlcmd: `CODE_NAME ='${path.split('/')[1]}'`,
+      entityName: 'SYS_LOW_CODE',
+      order: '',
+    }).then((data) => {
+      const searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON);
+      const colSlots = [] as string[];
+      for (const i in searchForms) {
+        if (!isNullOrUnDef(searchForms[i]['colSlot'])) {
+          colSlots.push('form-' + searchForms[i]['colSlot']);
+        }
+      }
+
+      const _cruds = JSON.parse(data.Data.Items[0].FORM_JSON);
+      const crudColSlots = [] as string[];
+      for (const i in _cruds) {
+        if (!isNullOrUnDef(_cruds[i]['colSlot'])) {
+          crudColSlots.push(_cruds[i]['colSlot']);
+        }
+      }
+      const id = {
+        ID: path.split('/')[1],
+        colSlots: colSlots,
+        crudColSlots: crudColSlots,
+        sName: `${path.split('/')[1]}_update`,
       };
-      break;
-    case 'BAS_REASON':
-      title = {
-        pageTitle: '涓嶈壇鍘熷洜缁勭鐞�',
-        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹師鍥犵粍鍜屼笉鑹唬鐮併��',
-        baseTableTitle: '涓嶈壇鍘熷洜绠$悊',
-      };
-      break;
-    case 'BAS_PKG_DTL':
-      title = {
-        pageTitle: '鍖呰瑙勫垯绠$悊',
-        pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀瑰寘瑁呰鍒欏拰鍖呰淇℃伅銆�',
-        baseTableTitle: '鍖呰淇℃伅绠$悊',
-      };
-      break;
-    default:
-      break;
+      // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage
+      sessionStorage.removeItem(`${id.sName}_params`);
+      sessionStorage.setItem(`${id.sName}_params`, encodeURI(JSON.stringify({ params: params })));
+      go(`/${path.split('/')[1]}/${path.split('/')[2]}/${encodeURI(JSON.stringify(id))}`);
+    });
+  } else if (
+    (path.split('/').length > 2 && path.split('/')[2] == 'High') ||
+    path.split('/')[2] == 'CP'
+  ) {
+    const id = { sName: `${path.split('/')[1]}_update`, Name: path.split('/')[1], params: params };
+    // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage
+    sessionStorage.removeItem(`${id.sName}_params`);
+    sessionStorage.setItem(`${id.sName}_params`, encodeURI(JSON.stringify(id)));
+    go(
+      `/${path.split('/')[1]}/${path.split('/')[2]}/${encodeURI(JSON.stringify({ sName: id.sName, Name: id.Name }))}`,
+    );
+  } else {
+    const id = { sName: `${path.split('/')[1]}_update`, params: params };
+    // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage
+    sessionStorage.removeItem(`${id.sName}_params`);
+    sessionStorage.setItem(`${id.sName}_params`, encodeURI(JSON.stringify(id)));
+    go(`${path}/${encodeURI(JSON.stringify({ sName: id.sName }))}`);
   }
-  return title;
 }
 
 /**
- * @description: 鑾峰彇闇�瑕佹柊澧炴椂灏遍粯璁ょ殑鍊硷紝涓�鑸槸涓昏〃淇℃伅
- * @param {string} type
- * @param {string} val
+ * @description: 璋冪敤api鍓嶏紝鍙傛暟鏁寸悊
+ * @param {*} t
  * @return {*}
  */
-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;
+export function SearchInfoFn(param: any, name: RouteRecordName | null | undefined, ByOrg: boolean) {
+  const useQuery = useQueryStore();
+  if (
+    !isNullOrUnDef(useQuery.getCurSearchInfo) &&
+    useQuery.getCurSearchInfo.some((q) => q.name == name)
+  ) {
+    const curSearchInfo = useQuery.getCurSearchInfo.filter((q) => q.name == name);
+    const Keys = Object.getOwnPropertyNames(curSearchInfo[0].searchInfo);
+    for (const k in Keys) {
+      if (Keys[k] != 'page' && Keys[k] != 'pageSize') {
+        param[Keys[k]] = curSearchInfo[0].searchInfo[Keys[k]];
+      }
+    }
+    useQuery.setCurSearchInfo({ name: name, searchInfo: param });
   }
-  return Values;
+  if (isNullOrEmpty(param.option) && ByOrg) {
+    param.option = {
+      //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁�
+      UserId: useUserStore().getUserInfo.userId,
+      ByOrg: true,
+      CurOrg: useUserStore().getUserInfo.orgCode,
+    };
+  }
+  return param;
 }
 
 /**
- * @description: 鑾峰彇鏍戝舰鏁版嵁
- * @param {string} type
+ * @description: 璇锋眰涔嬪悗瀵硅繑鍥炲�艰繘琛屽鐞�
+ * @param {*} t
  * @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;
+export function afterFetchFn(t: any, name: RouteRecordName | null | undefined, f) {
+  const useQuery = useQueryStore();
+  if (
+    !isNullOrUnDef(useQuery.getCurSearchInfo) &&
+    useQuery.getCurSearchInfo.some((q) => q.name == name)
+  ) {
+    const curSearchInfo = useQuery.getCurSearchInfo.filter((q) => q.name == name);
+    const params = cloneDeep(curSearchInfo[0].searchInfo);
+    const Keys = Object.getOwnPropertyNames(params);
+    for (const k in Keys) {
+      if (!isNullOrEmpty(params[Keys[k]]?.length) && isArray(params[Keys[k]])) {
+        if (isTimeViaRegExp8601(params[Keys[k]][0])) {
+          params[Keys[k]][0] = dateUtil(params[Keys[k]][0]);
+          params[Keys[k]][1] = dateUtil(params[Keys[k]][1]);
+        }
+      }
+      if (!isNullOrEmpty(params[Keys[k]]) && isTimeViaRegExp8601(params[Keys[k]])) {
+        params[Keys[k]] = dateUtil(params[Keys[k]]);
+      }
+    }
+    f.setFieldsValue(params);
   }
-  return data;
-}
-
-/**
- * @description: 鏍规嵁type鑾峰彇鍥炬爣
- * @param {Recordable} params
- * @param {string} type
- * @return {*}
- */
-export function createIconByType(params: Recordable<any>, type: string) {
-  let icon = '';
-  switch (type) {
-    case 'ProdRouteBinding':
-      icon = prodRouteCreateIcon(params);
-      break;
-  }
-  return icon;
 }

--
Gitblit v1.9.3