fix: สาขา code ไม่มา

This commit is contained in:
Net 2024-06-28 11:14:58 +07:00
parent 807f09da74
commit dce5b66f79

View file

@ -162,13 +162,13 @@ const formType = ref<'create' | 'edit' | 'delete' | 'view'>('create');
const formTypeBranch = ref<'headOffice' | 'subBranch'>('headOffice');
const currentHq = ref<{ id: string; code: string }>({ id: '', code: '' });
const currentEdit = ref<{ id: string; code: string }>({ id: '', code: '' });
const formData = ref<Omit<BranchCreate, 'qrCodeImage' | 'imageUrl'>>(
structuredClone(defaultFormData),
);
const formData = ref<
Omit<BranchCreate & { codeHeadOffice?: string }, 'qrCodeImage' | 'imageUrl'>
>(structuredClone(defaultFormData));
const prevFormData = ref<Omit<BranchCreate, 'qrCodeImage' | 'imageUrl'>>(
structuredClone(defaultFormData),
);
const prevFormData = ref<
Omit<BranchCreate & { codeHeadOffice?: string }, 'qrCodeImage' | 'imageUrl'>
>(structuredClone(defaultFormData));
const modalDrawer = ref<boolean>(false);
@ -242,6 +242,11 @@ function triggerCreate(
};
}
if (type === 'subBranch' && id && code) {
formData.value.headOfficeId = id;
formData.value.codeHeadOffice = code;
}
formType.value = 'create';
openDialog();
}
@ -333,6 +338,7 @@ async function onSubmit() {
if (formType.value === 'create') {
if (formTypeBranch.value === 'subBranch') {
formData.value.headOfficeId = currentHq.value.id;
delete formData.value['codeHeadOffice'];
}
await branchStore.create({
@ -493,7 +499,11 @@ watch(locale, () => {
if (!currentHq.id) {
triggerCreate('headOffice');
} else {
triggerCreate('subBranch');
triggerCreate(
'subBranch',
currentHq.id,
currentHq.code,
);
}
}
"
@ -879,7 +889,7 @@ watch(locale, () => {
>
<template #information>
<FormBranchInformation
v-model:code="currentHq.code"
v-model:code="formData.codeHeadOffice"
v-model:code-sub-branch="currentEdit.code"
v-model:taxNo="formData.taxNo"
v-model:name="formData.name"