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