diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index 144a085e..2810eec2 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -7,10 +7,18 @@ import AppBox from 'components/app/AppBox.vue'; import BtnAddComponent from 'components/01_branch-management/BtnAddComponent.vue'; import TooltipComponent from 'components/TooltipComponent.vue'; import StatCardComponent from 'components/StatCardComponent.vue'; +import CardDetailsComponent from 'src/components/01_branch-management/CardDetailsComponent.vue'; +import DeatailsBranchDrawerComponent from 'src/components/01_branch-management/DeatailsBranchDrawerComponent.vue'; -const BranchStore = useBranchStore(); +import { BranchWithChildren, Branch } from 'src/stores/branch/types'; + +const branchStore = useBranchStore(); const test = ref(''); +const modal = ref(false); + +const showCurrentBaranch = ref(); + const shape = ref(false); const inputSelectBranch = ref('ทั้งหมด'); @@ -67,47 +75,6 @@ const rows: { }, ]; -const simple = ref< - { - label: string; - isHeadOffice?: boolean; - children: { - label: string; - children?: { label: string }[]; - }[]; - }[] ->([ - { - label: 'สำนักงานใหม่ 1', - isHeadOffice: true, - - children: [ - { - label: 'BR1001', - children: [ - { - label: 'BU2001', - }, - ], - }, - { label: 'Bui1001' }, - ], - }, - - { - label: 'สำนักงานใหม่ 2', - isHeadOffice: true, - children: [ - { - label: 'Bc1001', - }, - { - label: 'Ba1001', - }, - ], - }, -]); - const branchStat = ref< { amount: number; @@ -137,9 +104,39 @@ const branchStat = ref< }, ]); +const treeData = ref([]); + onMounted(() => { BranchStore.fetchById('9ff3521b-0669-4812-bb25-7f1961956c8e'); console.log(BranchStore.data); + +async function getTree() { + const result = await branchStore.fetchList({ + tree: true, + }); + + if (result) { + treeData.value = result.result; + } +} + +async function fetchBranch(id: string) { + if (typeof branchStore.fetchById(id) === 'object') { + showCurrentBaranch.value = await branchStore.fetchById(id); + } +} + +onMounted(async () => { + getTree(); + + if ( + typeof branchStore.fetchById('bfff119e-079d-4b56-9699-0466ade4b517') === + 'object' + ) { + showCurrentBaranch.value = await branchStore.fetchById( + 'bfff119e-079d-4b56-9699-0466ade4b517', + ); + } });