From 28a53fe81cdb551d2bf2023167487a3060e0f180 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 30 十月 2024 00:35:51 +0800
Subject: [PATCH] 一些更改

---
 src/api/tigerapi/system.ts |   97 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 75 insertions(+), 22 deletions(-)

diff --git a/src/api/tigerapi/system.ts b/src/api/tigerapi/system.ts
index 1afc595..55d337e 100644
--- a/src/api/tigerapi/system.ts
+++ b/src/api/tigerapi/system.ts
@@ -65,7 +65,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',
@@ -133,7 +137,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(),
@@ -147,7 +151,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>(
@@ -288,7 +308,7 @@
  * @param {T} data
  * @param {string} parentField 鐖跺瓧娈靛悕
  * @param {string} idField 鍞竴key瀛楁鍚�
- * @param {string} pid_val 鐖秈d鍊�
+ * @param {string} pid 鐖秈d鍊�
  * @return {*}
  */
 export function convertToTree<T>(data: T[], parentField: string, idField: string, pid?: string) {
@@ -307,6 +327,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; // 娌℃湁鎵惧埌瀵瑰簲鐨勭埗浜茶妭鐐�
 }
 
 /*
@@ -714,24 +758,27 @@
   }
   const rParams = genAction(
     params['TABLE_NAME'],
-    {
-      QueryAble_T: '',
-      where: sqlcmd,
-      order: order,
-      page: {
-        pageAble_T: 'string',
-        draw: 1,
-        pageIndex: params['page'],
-        pageSize: params['pageSize'],
-      },
-    },
+    !isNullOrEmpty(params['apiUrl'])
+      ? params
+      : {
+          QueryAble_T: '',
+          where: sqlcmd,
+          order: order,
+          page: {
+            pageAble_T: 'string',
+            draw: 1,
+            pageIndex: params['page'],
+            pageSize: params['pageSize'],
+          },
+        },
     params['option'],
+    params['NeedInclude'],
   );
-  return getListByPageAsync(rParams);
+  return getListByPageAsync(rParams, params['apiUrl']); //濡傛灉涓嶆兂鐢ㄩ粯璁ょ殑鍩虹鏂规硶鑾峰彇鍒嗛〉鏁版嵁锛屽彲浠ユ崲鍏朵粬鐨刟pi
 }
-async function getListByPageAsync(params: any) {
+async function getListByPageAsync(params: any, apiUrl: string | null | undefined) {
   const data = await defHttp.post(
-    { url: Api.QueryUrl, params, timeout: 50000 },
+    { url: !isNullOrEmpty(apiUrl) ? apiUrl : Api.QueryUrl, params, timeout: 50000 },
     {
       isTransformResponse: false,
     },
@@ -762,11 +809,17 @@
       Keys[k] != 'field' &&
       Keys[k] != 'option' &&
       Keys[k] != '0' &&
+      Keys[k] != 'apiUrl' &&
+      Keys[k] != 'NeedInclude' &&
       !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 {
@@ -788,7 +841,7 @@
       },
     );
   } 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 = '璁板綍宸茬粡瀛樺湪锛屼笉鑳芥柊澧烇紒';
@@ -807,7 +860,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',
@@ -836,7 +889,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, {

--
Gitblit v1.9.3