Ben Lin
2024-06-09 38b2a8369513ebcc34c6dd01a176593b825fe71e
src/api/tigerapi/system.ts
@@ -32,6 +32,7 @@
} from './model/systemModel';
import { defHttp } from '/@/utils/http/axios';
import { isNullOrEmpty, isTimeType } from '/@/utils/is';
import { MES_ROUTE_EDGE, MES_ROUTE_NODE } from './model/router';
export enum Api {
  QueryUrl = '/Base/Query',
@@ -829,3 +830,31 @@
    },
  );
};
/*
 * 转换工艺路线为树形json
 */
function convertRouteToTreeData(
  nodes: MES_ROUTE_NODE[],
  edges: MES_ROUTE_EDGE[],
  parentId: string,
  id: string,
  pid?: string,
) {
  const result: treeParamsListItem[] = [];
  let temp: treeParamsListItem[] = [];
  const _pid = pid == undefined ? '' : pid;
  for (let i = 0; i < nodes.length; i++) {
    const currPid = data[i][parentId] == null ? '' : data[i][parentId];
    if (currPid === _pid) {
      const obj: treeParamsListItem = data[i];
      obj.PARAM_TYPE = _pid == '' ? '0' : '1'; //增加类型
      temp = convertToTreeData(data, parentId, id, data[i][id]);
      if (temp.length > 0) {
        obj.children = temp;
      }
      result.push(obj);
    }
  }
  return result;
}