You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.1 KiB
61 lines
2.1 KiB
var __rest = (this && this.__rest) || function (s, e) { |
|
var t = {}; |
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
|
t[p] = s[p]; |
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") |
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
|
t[p[i]] = s[p[i]]; |
|
} |
|
return t; |
|
}; |
|
import { cacheData } from 'actions/base.action'; |
|
import { getStorage } from '@component/utils'; |
|
import { isEmpty, map, flatMap } from 'lodash'; |
|
function analysisOrgan(data, key) { |
|
if (isEmpty(data)) { |
|
return []; |
|
} |
|
const organ = new Map(); |
|
const convertMenu = (list) => { |
|
list.forEach((item) => { |
|
const { children = [] } = item, other = __rest(item, ["children"]); |
|
organ.set(item[key], other); |
|
if (!isEmpty(children)) { |
|
convertMenu(children); |
|
} |
|
}); |
|
}; |
|
convertMenu(data); |
|
return Array.from(organ.values()); |
|
} |
|
function getRoute(data = [], id) { |
|
const result = []; |
|
(function f(array) { |
|
for (const arrayElement of array) { |
|
if ((arrayElement === null || arrayElement === void 0 ? void 0 : arrayElement.organId) == id) { |
|
result.push(analysisOrgan([arrayElement], 'organId')); |
|
break; |
|
} |
|
else { |
|
if (!isEmpty(arrayElement === null || arrayElement === void 0 ? void 0 : arrayElement.children)) { |
|
f(arrayElement.children); |
|
} |
|
} |
|
} |
|
})(data); |
|
return flatMap(result); |
|
} |
|
export function getOrganTreeData(values, key = 'organIds') { |
|
if (isEmpty(values)) { |
|
return {}; |
|
} |
|
const organData = cacheData.get(`organId_${getStorage('organId')}`); |
|
const result = flatMap(values.map((item) => getRoute(organData, item.value))); |
|
return { |
|
[key]: map(result, 'organId').join(','), |
|
branchOrganIds: map(values, 'value').join(','), |
|
branchOrganNames: map(values, 'label').join(','), |
|
}; |
|
} |
|
function get() { }
|
|
|