| | |
| | | return result; |
| | | } |
| | | |
| | | export function convertToTree(data: [], parentId: string, id: string, pid?: string) { |
| | | const result: any[] = []; |
| | | let temp: any[] = []; |
| | | /** |
| | | * @description: 树形表结构转树形Json |
| | | * @param {T} data |
| | | * @param {string} parentField 父字段名 |
| | | * @param {string} idField 唯一key字段名 |
| | | * @param {string} pid_val 父id值 |
| | | * @return {*} |
| | | */ |
| | | export function convertToTree<T>(data: T[], parentField: string, idField: string, pid?: string) { |
| | | const result: T[] = []; |
| | | let temp: T[] = []; |
| | | const _pid = isNullOrEmpty(pid) ? '' : pid; |
| | | for (let i = 0; i < data.length; i++) { |
| | | const currPid = data[i][parentId] == null ? '' : data[i][parentId]; |
| | | const currPid = data[i][parentField] == null ? '' : data[i][parentField]; |
| | | if (currPid === _pid) { |
| | | const obj = data[i] as {}; |
| | | temp = convertToTree(data, parentId, id, data[i][id]); |
| | | const obj = data[i] as T; |
| | | temp = convertToTree(data, parentField, idField, data[i][idField]); |
| | | if (temp.length > 0) { |
| | | obj['children'] = temp; |
| | | } |
| | |
| | | } |
| | | async function getListByPageAsync(params: any) { |
| | | const data = await defHttp.post( |
| | | { url: Api.QueryUrl, params }, |
| | | { url: Api.QueryUrl, params,timeout:50000 }, |
| | | { |
| | | isTransformResponse: false, |
| | | }, |