From 2e72cb3071f295eaa93a26f91bbfaf0065533b86 Mon Sep 17 00:00:00 2001 From: Net Date: Tue, 3 Sep 2024 18:15:45 +0700 Subject: [PATCH] refactor: add virtual --- src/pages/01_branch-management/MainPage.vue | 90 +++++++++++++++++---- 1 file changed, 76 insertions(+), 14 deletions(-) diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index 68d7f669..b2185ed4 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -3,7 +3,7 @@ import { storeToRefs } from 'pinia'; import { ref, onMounted, computed, watch } from 'vue'; import { Icon } from '@iconify/vue'; import { BranchContact } from 'stores/branch-contact/types'; -import { useQuasar } from 'quasar'; +import { colors, useQuasar } from 'quasar'; import { useI18n } from 'vue-i18n'; import type { QTableProps } from 'quasar'; @@ -16,6 +16,7 @@ import { BankBook, } from 'stores/branch/types'; +import ItemCard from 'src/components/ItemCard.vue'; import useUtilsStore, { dialog, baseUrl } from 'stores/utils'; import EmptyAddButton from 'components/AddButton.vue'; import TooltipComponent from 'components/TooltipComponent.vue'; @@ -49,7 +50,19 @@ const apiBaseUrl = import.meta.env.VITE_API_BASE_URL; const $q = useQuasar(); const { t } = useI18n(); const utilsStore = useUtilsStore(); - +const modelCreateTypeBranch = ref(false); +const typeBranchItem = [ + { + icon: 'mdi-home-group', + text: 'Virtual Branch', + color: '#03A9F4', + }, + { + icon: 'mdi-home-group', + text: 'Branch', + color: 'var(--purple-6)', + }, +]; const holdDialog = ref(false); const isSubCreate = ref(false); const columns = [ @@ -292,6 +305,7 @@ const defaultFormData = { provinceId: '', lineId: '', webUrl: '', + virtual: false, }; const formDialogRef = ref(); @@ -359,6 +373,7 @@ async function fetchBranchById(id: string) { lineId: res.lineId, status: res.status, webUrl: res.webUrl, + virtual: res.virtual, }; } } @@ -392,13 +407,17 @@ async function undo() { formData.value = prevFormData.value; } +watch(modal, () => { + if (!modal.value) { + clearData(); + } +}); + function triggerCreate( type: 'headOffice' | 'subBranch', id?: string, code?: string, ) { - clearData(); - formTypeBranch.value = type; if (type === 'headOffice') { @@ -606,15 +625,15 @@ async function onSubmit() { fieldSelectedBranch.value.value = ''; inputSearch.value = ''; currentHq.value = { - id: currentRecord.id, - code: currentRecord.code, + id: currentRecord?.id || '', + code: currentRecord?.code || '', }; beforeBranch.value = { id: '', code: '', }; expandedTree.value = []; - expandedTree.value.push(currentRecord.id); + expandedTree.value.push(currentRecord?.id || ''); } else { dialog({ color: 'info', @@ -786,7 +805,11 @@ watch(currentHq, () => { @@ -820,11 +843,7 @@ watch(currentHq, () => { if (!currentHq.id) { triggerCreate('headOffice'); } else { - triggerCreate( - 'subBranch', - currentHq.id, - currentHq.code, - ); + modelCreateTypeBranch = true; } } " @@ -886,7 +905,16 @@ watch(currentHq, () => { } } " - @create="(v) => triggerCreate('subBranch', v.id, v.code)" + @create=" + (v) => { + currentHq.id = v.id; + currentHq.code = v.code; + + modelCreateTypeBranch = true; + } + + // triggerCreate(v.virtual, 'subBranch', v.id, v.code) + " @view=" (v) => { if (v.isHeadOffice) { @@ -2010,6 +2038,40 @@ watch(currentHq, () => { + + +
+ +
+