diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index 144a085e..881c87a3 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -7,11 +7,21 @@ 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'; +import FormDialog from 'src/components/FormDialog.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 openBranchDrawer = ref(true); const inputSelectBranch = ref('ทั้งหมด'); const inputFilter = ref('คอลัมน์'); @@ -26,6 +36,39 @@ const optionsFilter: string[] = [ 'สถานะ', ]; +const formData = ref({ + hqId: '', + branchId: '', + tel: '', + gender: '', + email: '', + addressL: { + address: '', + province: '', + district: '', + subDistrict: '', + zip: '', + }, + addressEng: { + address: '', + province: '', + district: '', + subDistrict: '', + zip: '', + }, +}); + +const selected = ref(''); + +const headOfficeCode = ref(''); +const headOfficeName = ref(''); +const taxIDNumber = ref(''); +const nameHeadOfficeEN = ref(''); +const inputPhone = ref(''); +const inputIdLine = ref(''); +const inputPhonHeadOffice = ref(''); +const inputEmailHeadOffice = ref(''); + const expanded = ref([]); const rows: { @@ -67,47 +110,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 +139,41 @@ const branchStat = ref< }, ]); -onMounted(() => { - BranchStore.fetchById('9ff3521b-0669-4812-bb25-7f1961956c8e'); - console.log(BranchStore.data); +const treeData = ref([]); + +function openDialog() { + console.log('openDialog'); + + modal.value = true; +} + +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', + ); + } });