From 043701d5a28df6a0ea596ed7e4198676480bcc60 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 05 三月 2025 16:12:55 +0800 Subject: [PATCH] 工具维护更新 --- src/api/tigerapi/system.ts | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 105 insertions(+), 12 deletions(-) diff --git a/src/api/tigerapi/system.ts b/src/api/tigerapi/system.ts index dae8570..334fcb0 100644 --- a/src/api/tigerapi/system.ts +++ b/src/api/tigerapi/system.ts @@ -29,11 +29,13 @@ EntityList, iSYS_ROLE_PROD, pParams, + ImportEntityValidate, + ImportInput, } from './model/systemModel'; import { defHttp } from '/@/utils/http/axios'; -import { isArray, isNullOrEmpty, isNullOrUnDef, isTimeViaRegExp8601 } from '/@/utils/is'; +import { isArray, isNullOrEmpty, isTimeViaRegExp8601 } from '/@/utils/is'; import { isNumber } from 'xe-utils'; -import { dateUtil, formatToDateTime } from '/@/utils/dateUtil'; +import { useUserStore } from '/@/store/modules/user'; export enum Api { QueryUrl = '/Base/Query', @@ -42,6 +44,8 @@ EntityPageList = '/Base/QueryCustomPage', IsAccountExist = '/Base/IsExist', AddAfterDelete = '/Base/AddAfterDelete', + ImportExcel = '/Base/ImportExcel', + BaseValidateTableImport = '/Base/ValidateTableImport', setRoleStatus = '/system/setRoleStatus', MenuList = '/SYS/getMenuListAll', SaveMenu = '/SYS/SaveMenu', @@ -66,7 +70,11 @@ StartJob = '/Tsk/StartJob', StopJob = '/Tsk/PauseJob', AddJob = '/Tsk/AddJob', + AddTskJob = '/Tsk/AddTskJob', + ImmediateRun = '/Tsk/ImmediateRun', + RemoveTskJob = '/Tsk/RemoveTskJob', UpdateJob = '/Tsk/UpdateJob', + SaveTskJob = '/Tsk/SaveTskJob', urlQueryEnum = '/Base/QueryEnum', DeleteWareHouse = '/WMS/DelWareHouseModel', AddLocation = '/WMS/AddLoctionModel', @@ -134,7 +142,7 @@ /* * 鐢熸垚Action */ -export function genAction<T>(datatype: string, data: T, option?: object) { +export function genAction<T>(datatype: string, data: T, option?: object, NeedInclude?: boolean) { const time = new Date(); const params: ApiAction<T> = { ID: buildUUID(), @@ -148,7 +156,23 @@ StatusCode: 0, Data: data, LocaleMsg: undefined, + NeedInclude: isNullOrEmpty(NeedInclude) ? false : NeedInclude, }; + return params; +} + +/** + * @desc 鐢熸垚Action + */ +export function generateAction<T>( + datatype: string, + DataAssembly: string, + data: T, + option?: object, + NeedInclude?: boolean, +) { + const params = genAction(datatype, data, option, NeedInclude); + params.DataAssembly = DataAssembly; return params; } export function genActionjob<sting>( @@ -308,6 +332,30 @@ } } return result; +} + +/** + * @description: 鑾峰彇鐖堕」 + * @param {any} nodes + * @param {string} childId + * @return {*} + */ +export function findParent(tree: any[], nodeId: string): any | undefined { + for (const node of tree) { + if (node.children) { + for (const child of node.children) { + if (child.tid === nodeId) { + return node; + } + // 閫掑綊鏌ユ壘瀛愭爲 + const potentialParent = findParent(node.children, nodeId); + if (potentialParent) { + return potentialParent; + } + } + } + } + return undefined; // 娌℃湁鎵惧埌瀵瑰簲鐨勭埗浜茶妭鐐� } /* @@ -729,6 +777,7 @@ }, }, params['option'], + params['NeedInclude'], ); return getListByPageAsync(rParams, params['apiUrl']); //濡傛灉涓嶆兂鐢ㄩ粯璁ょ殑鍩虹鏂规硶鑾峰彇鍒嗛〉鏁版嵁锛屽彲浠ユ崲鍏朵粬鐨刟pi } @@ -766,17 +815,26 @@ Keys[k] != 'option' && Keys[k] != '0' && Keys[k] != 'apiUrl' && + Keys[k] != 'NeedInclude' && + Keys[k] != 'nolike' && !Keys[k].toString().endsWith('PSelect_0') ) { - if (!isNullOrEmpty(params[Keys[k]].length) && isTimeViaRegExp8601(params[Keys[k]][0])) { - sqlcmd += ` And ${Keys[k]} > '${params[Keys[k]][0]}'`; - sqlcmd += ` And ${Keys[k]} < '${params[Keys[k]][1]}'`; + if (!isNullOrEmpty(params[Keys[k]].length) && isArray(params[Keys[k]])) { + if (isTimeViaRegExp8601(params[Keys[k]][0])) { + sqlcmd += ` And ${Keys[k]} > '${params[Keys[k]][0]}'`; + sqlcmd += ` And ${Keys[k]} < '${params[Keys[k]][1]}'`; + } else { + sqlcmd += `And '${params[Keys[k]].join(',')}' like '%'+${Keys[k]}+'%'`; + } } else if (isNumber(params[Keys[k]])) { sqlcmd += `And ${Keys[k]} = ${params[Keys[k]]}`; - } else if (Keys[k] == 'sqlcmd') { - sqlcmd += ` And ${params[Keys[k]]}`; + } else if(Keys[k].toString().startsWith('IFEMPTY_')){ + sqlcmd +=params[Keys[k]]=='Y'? `And (${Keys[k].split('IFEMPTY_')[1]} != '' OR ${Keys[k].split('IFEMPTY_')[1]} is not NULL)`: `And (${Keys[k].split('IFEMPTY_')[1]} = '' OR ${Keys[k].split('IFEMPTY_')[1]} is NULL)`; } else { - sqlcmd += `And ${Keys[k]} like '%${params[Keys[k]]}%'`; + sqlcmd += + params['nolike'] == 'Y' + ? `And ${Keys[k]} = '${params[Keys[k]]}'` + : `And ${Keys[k]} like '%${params[Keys[k]]}%'`; } } } @@ -794,13 +852,14 @@ }, ); } else { - var check = await isExist(genAction(entityName, args[0])); + const check = await isExist(genAction(entityName, args[0])); if (check.Data) { check.IsSuccessed = false; check.Message = '璁板綍宸茬粡瀛樺湪锛屼笉鑳芥柊澧烇紒'; return check; } params['ID'] = args[1] == true ? params['ID'] : buildUUID(); //鐢熸垚GUID + params['AUTH_ORG'] = useUserStore().getUserInfo.orgCode as string; data = await defHttp.post( { url: Api.AddEntity, params: genAction(entityName, params) }, { @@ -813,7 +872,7 @@ } export async function AddListEntity<T>(params: T, entityName: string) { - let data = await defHttp.post( + const data = await defHttp.post( { url: Api.AddListEntity, params: genAction(entityName, params) }, { errorMessageMode: 'none', @@ -842,7 +901,7 @@ * @return {*} */ export async function AddAfterDelete(entityName: string, items: [], where: string) { - let data = await defHttp.post( + const data = await defHttp.post( { url: Api.AddAfterDelete, params: genAction(entityName, { @@ -977,3 +1036,37 @@ isTransformResponse: false, }, ); + + /** + * @desc 瀵煎叆Excel + */ +export async function ImportExcel(entityName: string, items: ImportInput) { + const data = await defHttp.post( + { + url: Api.ImportExcel, + params: genAction(entityName, items), + }, + { + errorMessageMode: 'none', + isTransformResponse: false, + }, + ); + return data; +} + +/** + * @desc 瀵煎叆Excel + */ +export async function ValidateTableImport(entityName: string, items: ImportEntityValidate) { +const data = await defHttp.post( + { + url: Api.BaseValidateTableImport, + params: genAction(entityName, items), + }, + { + errorMessageMode: 'none', + isTransformResponse: false, + }, +); +return data; +} -- Gitblit v1.9.3