fix: branch INACTIVE can't show subBranch
This commit is contained in:
parent
f5cf3aec57
commit
7e559136af
1 changed files with 12 additions and 5 deletions
|
|
@ -157,14 +157,21 @@ const { locale } = useI18n();
|
|||
const { data: branchData } = storeToRefs(branchStore);
|
||||
|
||||
const treeData = computed(() => {
|
||||
const arr: BranchWithChildren[] = [];
|
||||
const map: Record<string, BranchWithChildren> = {};
|
||||
const children: Branch[] = [];
|
||||
|
||||
branchData.value?.result.forEach((a) => {
|
||||
if (a.isHeadOffice) arr.push(Object.assign(a, { branch: [] }));
|
||||
else arr.find((b) => b.id === a.headOfficeId)?.branch.push(a);
|
||||
branchData.value?.result.forEach((v) => {
|
||||
if (v.isHeadOffice) map[v.id] = Object.assign(v, { branch: [] });
|
||||
else children.push(v);
|
||||
});
|
||||
|
||||
return arr;
|
||||
children.forEach((v) => {
|
||||
if (v.headOfficeId && map[v.headOfficeId]) {
|
||||
map[v.headOfficeId].branch.push(v);
|
||||
}
|
||||
});
|
||||
|
||||
return Object.values(map);
|
||||
});
|
||||
|
||||
async function calculateStats() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue