From a9650ad1b6ba1b4140211c54695d8d1fcec5f59e Mon Sep 17 00:00:00 2001 From: puriphatt Date: Mon, 7 Oct 2024 10:20:29 +0700 Subject: [PATCH] refactor: delete worker & branch, cus-branch state --- src/components/05_quotation/FormAbout.vue | 24 +++--- src/components/05_quotation/WorkerItem.vue | 4 +- src/pages/05_quotation/QuotationForm.vue | 88 +++++++++++++++++----- 3 files changed, 85 insertions(+), 31 deletions(-) diff --git a/src/components/05_quotation/FormAbout.vue b/src/components/05_quotation/FormAbout.vue index aa02b673..820d93f2 100644 --- a/src/components/05_quotation/FormAbout.vue +++ b/src/components/05_quotation/FormAbout.vue @@ -5,6 +5,8 @@ import useBranchStore from 'src/stores/branch'; import useCustomerStore from 'src/stores/customer'; import SelectInput from '../shared/SelectInput.vue'; import { QSelect } from 'quasar'; +import { Branch } from 'src/stores/branch/types'; +import { CustomerBranch } from 'src/stores/customer/types'; const { locale } = useI18n({ useScope: 'global' }); const branchStore = useBranchStore(); @@ -66,17 +68,20 @@ async function init(val: string, type: 'branch' | 'customer') { }); if (res) { if (type === 'branch') { - branchOption.value = res.result.map((v) => ({ + branchOption.value = (res.result as Branch[]).map((v: Branch) => ({ value: v.id, label: v.name, labelEN: v.nameEN, })); } else if (type === 'customer') { - customerOption.value = res.result.map((v) => ({ - value: v.id, - label: v.registerName || `${v.firstName} ${v.lastName}` || '-', - labelEN: v.registerNameEN || `${v.firstNameEN} ${v.lastNameEN}` || '-', - })); + customerOption.value = (res.result as CustomerBranch[]).map( + (v: CustomerBranch) => ({ + value: v.id, + label: v.registerName || `${v.firstName} ${v.lastName}` || '-', + labelEN: + v.registerNameEN || `${v.firstNameEN} ${v.lastNameEN}` || '-', + }), + ); } } } @@ -89,7 +94,8 @@ onMounted(async () => { watch( () => branchId.value, async (v) => { - if (v && props.onCreate) { + if (v && customerBranchId.value && props.onCreate) { + console.log('form'); customerBranchId.value = ''; } }, @@ -137,7 +143,7 @@ watch( :label="$t('quotation.branch')" :option-label="locale === 'eng' ? 'labelEN' : 'label'" :rules="[(val: string) => !!val || $t('form.error.required')]" - @filter="(val, update) => filter(val, update, 'branch')" + @filter="(val: string, update) => filter(val, update, 'branch')" />