From 78999ce1626d2a786f3a705281eeba79c2f1d6dd Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 22 十月 2024 09:32:27 +0800 Subject: [PATCH] 工艺页面缓存优化 --- src/views/tigerprojects/system/lowcode/data.ts | 241 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 218 insertions(+), 23 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts index d1ad12c..c5ec40c 100644 --- a/src/views/tigerprojects/system/lowcode/data.ts +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -4,27 +4,21 @@ * @version: * @Date: 2024-06-02 17:52:35 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-29 06:12:26 + * @LastEditTime: 2024-10-15 20:55:16 */ -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 { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { woCustFn, woformSchema } from '/@/views/components/bizMesWo'; import { useModal } from '/@/components/Modal'; -import LogicFlow from '@logicflow/core'; -import { BpmnElement } from '@logicflow/extension/es/bpmn'; -import { Ref, ref, unref } from 'vue'; -import customEdge from '/@/components/FlowChart/src/customEdge'; -import actionRect from '/@/components/FlowChart/src/actionRect'; -import TestNode from '/@/components/FlowChart/src/TestNode'; -import CollectNode from '/@/components/FlowChart/src/CollectNode'; -import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode'; -import PackingNode from '/@/components/FlowChart/src/PackingNode'; -import RepairNode from '/@/components/FlowChart/src/RepairNode'; -import { getRouteData } from '/@/api/tigerapi/mes/router'; -import { toLogicFlowData } from '/@/components/FlowChart/src/adpterForTurbo'; -import { SelectionSelect } from '@logicflow/extension'; +import { Ref, unref } from 'vue'; +import { getRouteData, getWoRouteData } from '/@/api/tigerapi/mes/router'; +import { buildUUID } from '/@/utils/uuid'; +import { useUserStore } from '/@/store/modules/user'; +import { formatToDateTime } from '/@/utils/dateUtil'; +import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; +import { useGo } from '/@/hooks/web/usePage'; const { t } = useI18n(); /** @@ -38,7 +32,7 @@ * 5. 鍒濆鍖栬〃鏍� GetBasicColumnAndInit * 6. 璁剧疆杩斿洖 getHomeUrl * 7. 璁剧疆鏍囬 getTitle - * 8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getOthersValues + * 8. 璁剧疆鏂板鏃跺氨榛樿鐨勫�� getKeyFieldValues * 9. 鏇挎崲鍒犻櫎鏂规硶 GetActionsData * @param {*} params * @param {array} args @@ -157,14 +151,14 @@ } /** - * @description: 宸ヨ壓璺嚎鍒濆鍖� - * @param {*} lf - * @return {*} - */ -export async function initRoute(lf, rotId, routeData, currlf) { + * @description: 宸ヨ壓璺嚎鍒濆鍖� + * @param {*} lf + * @return {*} + */ +export async function initRoute(lf, rotId, routeData, currlf, rotType) { currlf.value = unref(lf); //閫氳繃宸ヨ壓璺嚎ID鑾峰彇鍥惧舰鏁版嵁锛屽苟娓叉煋 - var _data = await getRouteData(rotId); + var _data = rotType == 'Wo' ? await getWoRouteData(rotId) : await getRouteData(rotId); console.log('缁勪欢宸叉寕杞�', _data); if (_data.Data != null) { _data.Data.nodes.forEach((n) => { @@ -182,5 +176,206 @@ routeData.value.nodes.push(act.node); }); unref(lf).render(routeData.value); + // lf.graphModel.translateCenter(); + // lf.graphModel.fitView(); + } +} + +/* 楂樼骇琛ㄥ崟鍏敤鏂规硶 *********************************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: 楂樼骇琛ㄥ崟鏂板缂栬緫鏂规硶 + * @param {Ref} data + * @param {*} d + * @param {*} u + * @param {*} item + * @param {*} updates + * @return {*} + */ +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; + var _data2: any[] = []; + if (!isNullOrEmpty(data.value[item])) { + _data2 = data.value[item].map((item) => { + return item; + }); + } + _data2.push(d); + data.value[item] = _data2; + } +} + +/** + * @description: 鑷畾涔夊垹闄ゆ柟娉� + * @param {Fn} args + * @param {*} params + * @return {*} + */ +export function custDel(args: Fn[], params: {}) { + const name = params['name']; + const useTables = args[1]; + if (!isNullOrEmpty(params['data'])) { + var _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) { + let actionItem = [] as 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), + }; + } + } + 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: `ASSEMBLY_NAME ='${path.split('/')[1]}'`, + entityName: 'SYS_LOW_CODE', + order: '', + }).then((data) => { + var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON); + let colSlots = [] as string[]; + for (const i in searchForms) { + if (!isNullOrUnDef(searchForms[i]['colSlot'])) { + colSlots.push('form-' + searchForms[i]['colSlot']); + } + } + + var _cruds = JSON.parse(data.Data.Items[0].FORM_JSON); + let 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`, + }; + // 灏嗗璞¤浆鎹负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}))}`); } } -- Gitblit v1.9.3