From f188bb931d5583e79fb1d85267f53544d1fec2eb Mon Sep 17 00:00:00 2001 From: Net Date: Mon, 9 Sep 2024 11:59:51 +0700 Subject: [PATCH] refactor: edit layout columns --- src/pages/01_branch-management/MainPage.vue | 110 ++++++++++---------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index d9b0ea85..77196df9 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -85,6 +85,28 @@ const columns = [ field: 'name', sortable: true, }, + + { + name: 'taxNo', + align: 'left', + label: 'general.taxNo', + field: 'taxNo', + }, + + { + name: 'branchLabelTel', + align: 'left', + label: 'branch.card.branchLabelTel', + field: 'telephoneNo', + }, + + { + name: 'contactName', + align: 'left', + label: 'general.contactName', + field: 'contactName', + }, + { name: 'branchLabelAddress', align: 'left', @@ -92,18 +114,6 @@ const columns = [ field: 'address', sortable: true, }, - { - name: 'branchLabelTel', - align: 'left', - label: 'general.telephone', - field: 'telephoneNo', - }, - { - name: 'branchLabelType', - align: 'left', - label: 'general.type', - field: 'isHeadOffice', - }, ] satisfies QTableProps['columns']; const modal = ref(false); @@ -267,31 +277,26 @@ const beforeBranch = ref<{ id: string; code: string }>({ code: '', }); +const modeView = ref(false); const inputSearch = ref(''); -const fieldDisplay = ref< - ( - | 'branchLabelName' - | 'branchLabelAddress' - | 'branchLabelTel' - | 'branchLabelType' - | 'orderNumber' - )[] ->([ - 'orderNumber', - 'branchLabelName', - 'branchLabelTel', - 'branchLabelAddress', - 'branchLabelType', -]); -const fieldSelected = ref< - ( - | 'orderNumber' - | 'branchLabelName' - | 'branchLabelAddress' - | 'branchLabelTel' - | 'branchLabelType' - )[] ->(fieldDisplay.value); + +const fieldDisplay = computed(() => { + return columns + .filter((v) => { + return !( + modeView.value === true && + (v.name.includes('branchLabelName') || v.name.includes('orderNumber')) + ); + }) + .map((v) => v.name); +}); + +const fieldSelected = ref([...fieldDisplay.value]); + +watch(modeView, () => { + fieldSelected.value = [...fieldDisplay.value]; +}); + const fieldSelectedBranch = ref<{ label: string; value: string; @@ -309,8 +314,6 @@ const stats = ref< }[] >([]); -const modeView = ref(false); - const splitterModel = ref(25); const defaultFormData = { @@ -1255,21 +1258,25 @@ watch(currentHq, () => { + + + {{ props.row.taxNo }} + + + + {{ props.row.contact[0]?.telephoneNo || '-' }} + + + + {{ props.row.contactName }} + + {{ props.row.address }} - - {{ props.row.contact[0]?.telephoneNo || '-' }} - - - {{ - props.row.isHeadOffice - ? $t('branch.card.branchHQLabel') - : $t('branch.card.branchLabel') - }} - + {{ console.log(props.row) }} { $i18n.locale === 'eng' ? props.row.nameEN : props.row.name, + taxNo: props.row.taxNo, branchLabelTel: props.row.contact .map((c: BranchContact) => c.telephoneNo) .join(','), + contactName: props.row.contactName, branchLabelAddress: $i18n.locale === 'eng' ? `${props.row.addressEN || ''} ${props.row.subDistrict?.nameEN || ''} ${props.row.district?.nameEN || ''} ${props.row.province?.nameEN || ''}` : `${props.row.address || ''} ${props.row.subDistrict?.name || ''} ${props.row.district?.name || ''} ${props.row.province?.name || ''}`, - branchLabelType: $t( - props.row.isHeadOffice - ? 'branch.card.branchHQLabel' - : 'branch.card.branchLabel', - ), branchImgUrl: `/branch/${props.row.id}/branch-image`, }" :field-selected="fieldSelected"