From 925a72d879f399c2597b08e0becff4f7db6d399f Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 24 十月 2024 14:52:17 +0800 Subject: [PATCH] 低代码页面更新 --- src/views/tigerprojects/system/lowcode/data.ts | 123 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 116 insertions(+), 7 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts index 4544abf..8136cb0 100644 --- a/src/views/tigerprojects/system/lowcode/data.ts +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -4,20 +4,23 @@ * @version: * @Date: 2024-06-02 17:52:35 * @LastEditors: Ben Lin - * @LastEditTime: 2024-07-20 02:17:35 + * @LastEditTime: 2024-10-23 23:01:49 */ 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 { Ref, unref } from 'vue'; -import { getRouteData } from '/@/api/tigerapi/mes/router'; +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 } from '/@/api/tigerapi/system'; +import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; +import { useGo } from '/@/hooks/web/usePage'; +import { useQueryStore } from '/@/store/modules/queryInpage'; +import { RouteRecordName } from 'vue-router'; const { t } = useI18n(); /** @@ -154,10 +157,10 @@ * @param {*} lf * @return {*} */ -export async function initRoute(lf, rotId, routeData, currlf) { +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) => { @@ -303,7 +306,7 @@ * @param {*} params * @return {*} */ -function editRecord(fn: Fn, params: {}) { +export function editRecord(fn: Fn, params: {}) { fn(true, params); } @@ -322,3 +325,109 @@ } }); } + +/** + * @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}))}`); + } +} + + + + /** + * @description: 璋冪敤api鍓嶏紝鍙傛暟鏁寸悊 + * @param {*} t + * @return {*} + */ + 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 }); + } + if (isNullOrEmpty(param.option) && ByOrg) { + param.option = { + //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + UserId: useUserStore().getUserInfo.userId, + ByOrg: true, + CurOrg: useUserStore().getUserInfo.orgCode, + }; + } + return param; + } + + + /** + * @description: 璇锋眰涔嬪悗瀵硅繑鍥炲�艰繘琛屽鐞� + * @param {*} t + * @return {*} + */ + 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); + f.setFieldsValue(curSearchInfo[0].searchInfo); + } + } -- Gitblit v1.9.3