no message

This commit is contained in:
setthawutttty 2024-01-31 15:33:22 +07:00
parent 69771682eb
commit 9355b54882
2 changed files with 92 additions and 33 deletions

View file

@ -10,6 +10,7 @@ import type { OrgTree } from "@/modules/02_organizationalNew/interface/response/
/** importComponents*/
import DialogAgency from "@/modules/02_organizationalNew/components/DialogFormAgency.vue";
import DialogStructureDetail from "@/modules/02_organizationalNew/components/StructureDetail.vue";
import DialogSortAgency from "@/modules/02_organizationalNew/components/DialogSortAgency.vue";
/** importStore*/
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
@ -80,7 +81,9 @@ const listAdd = ref<ListMenu[]>([
const nodeTEST = defineModel<OrgTree[]>("nodeTree", { default: [] });
const filter = ref<string>("");
const level = ref<number>(0);
const nodes = ref<Array<OrgTree>>([]);
const dataSort = ref<Array<any>>([]);
const lazy = ref(nodes);
const expanded = ref<Array<any>>([]);
const notFound = ref<string>("ไม่พบข้อมูลที่ค้นหา");
@ -165,6 +168,7 @@ function deleteNode(treeNode: any, organizationId: any): boolean {
return false;
}
const modalSortAgency = ref<boolean>(false);
const dialogAgency = ref<boolean>(false);
const actionType = ref<string>("");
const dataNode = ref<any>();
@ -214,6 +218,54 @@ async function onClickDel(type: number, id: string) {
});
}
function onClickSort(type: number, id: string) {
modalSortAgency.value = true;
level.value = type;
if (type === 0) {
const dataList = nodes.value;
const dataMap = dataList.map((item: any) => ({
orgTreeId: item.orgTreeId,
orgLevel: item.orgLevel,
orgTreeName: item.orgTreeName,
orgTreeShortName: item.orgTreeShortName,
orgRevisionId: item.orgRevisionId,
}));
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)
}
}
watch(
() => nodeTEST.value,
() => {
@ -328,6 +380,8 @@ onMounted(async () => {});
? onClickDetail(prop.node.orgTreeId, prop.node.orgLevel)
: item.type === 'DEL'
? onClickDel(prop.node.orgLevel, prop.node.orgTreeId)
: item.type === 'SORT'
? onClickSort(prop.node.orgLevel, prop.node.orgRootId)
: null
"
>
@ -451,6 +505,12 @@ onMounted(async () => {});
v-model:treeId="treeId"
v-model:orgLevel="orgLevel"
/>
<DialogSortAgency
v-model:sort-agency="modalSortAgency"
v-model:data="dataSort"
v-model:type="level"
/>
</template>
<style scoped></style>