pop up จัดลำดับการแสดงผล
This commit is contained in:
parent
950b958a2e
commit
3eb1a41bdb
3 changed files with 51 additions and 65 deletions
|
|
@ -212,16 +212,25 @@ async function onClickDel(type: number, id: string) {
|
|||
messageError($q, err);
|
||||
})
|
||||
.finally(async () => {
|
||||
props.fetchDataTree?.();
|
||||
hideLoader();
|
||||
props.fetchDataTree?.();
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onClickSort(type: number, id: string) {
|
||||
async function onClickSort(id: string) {
|
||||
modalSortAgency.value = true;
|
||||
level.value = type;
|
||||
if (type === 0) {
|
||||
if (id) {
|
||||
breakLoop.value = false;
|
||||
|
||||
const orgId = id;
|
||||
|
||||
for (let index = 0; index < nodes.value.length; index++) {
|
||||
const data = nodes.value[index];
|
||||
searchAndReplace(data, orgId);
|
||||
if (breakLoop.value) break;
|
||||
}
|
||||
} else {
|
||||
const dataList = nodes.value;
|
||||
const dataMap = dataList.map((item: any) => ({
|
||||
orgTreeId: item.orgTreeId,
|
||||
|
|
@ -232,38 +241,17 @@ function onClickSort(type: number, id: string) {
|
|||
}));
|
||||
|
||||
dataSort.value = dataMap;
|
||||
} else if (type === 1) {
|
||||
const dataList = nodes.value;
|
||||
const dataMap = dataList.map((item: any) => ({
|
||||
orgTreeId: item.orgTreeId,
|
||||
orgRevisionId: item.orgRevisionId,
|
||||
children: item.children,
|
||||
}));
|
||||
const dataChild = dataMap
|
||||
.filter((item: any) => item.orgTreeId === id)
|
||||
.reduce((acc: any, item: any) => {
|
||||
return acc.concat(
|
||||
item.children.map((child: any) => ({
|
||||
orgRootId: child.orgRootId,
|
||||
orgTreeId: child.orgTreeId,
|
||||
orgLevel: child.orgLevel,
|
||||
orgTreeName: child.orgTreeName,
|
||||
orgTreeShortName: child.orgTreeShortName,
|
||||
orgRevisionId: child.orgRevisionId,
|
||||
}))
|
||||
);
|
||||
}, []);
|
||||
dataSort.value = dataChild;
|
||||
} else if (type === 2) {
|
||||
|
||||
const dataList = nodes.value;
|
||||
const dataMap = dataList.map((item: any) => ({
|
||||
orgTreeId: item.orgTreeId,
|
||||
children: item.children,
|
||||
}))
|
||||
|
||||
console.log(dataMap)
|
||||
}
|
||||
|
||||
function searchAndReplace(data: any, id: string) {
|
||||
if (data.orgTreeId === id) {
|
||||
dataSort.value = data.children;
|
||||
breakLoop.value = true;
|
||||
} else if (data.children) {
|
||||
for (const child of data.children) {
|
||||
searchAndReplace(child, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
watch(
|
||||
|
|
@ -381,7 +369,7 @@ onMounted(async () => {});
|
|||
: item.type === 'DEL'
|
||||
? onClickDel(prop.node.orgLevel, prop.node.orgTreeId)
|
||||
: item.type === 'SORT'
|
||||
? onClickSort(prop.node.orgLevel, prop.node.orgRootId)
|
||||
? onClickSort(prop.node.orgRootId)
|
||||
: null
|
||||
"
|
||||
>
|
||||
|
|
@ -509,7 +497,6 @@ onMounted(async () => {});
|
|||
<DialogSortAgency
|
||||
v-model:sort-agency="modalSortAgency"
|
||||
v-model:data="dataSort"
|
||||
v-model:type="level"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue