fix: สาขา code ไม่มา
This commit is contained in:
parent
807f09da74
commit
dce5b66f79
1 changed files with 18 additions and 8 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue