fix: แก้ลูก ใน รายละเอียดไม่ได้
This commit is contained in:
parent
3cddefd965
commit
8030e3cac1
1 changed files with 33 additions and 10 deletions
|
|
@ -222,32 +222,45 @@ function clearData() {
|
|||
profileFile.value = undefined;
|
||||
}
|
||||
|
||||
function triggerView(
|
||||
async function triggerView(
|
||||
id: string,
|
||||
typeBranch: 'headOffice' | 'subBranch',
|
||||
code?: string,
|
||||
) {
|
||||
fetchBranchById(id);
|
||||
await fetchBranchById(id);
|
||||
if (id && code && typeBranch === 'headOffice') {
|
||||
formTypeBranch.value = 'headOffice';
|
||||
codeHq.value = {
|
||||
id: id,
|
||||
code: code,
|
||||
};
|
||||
}
|
||||
if (typeBranch === 'subBranch' && id && code) {
|
||||
formTypeBranch.value = 'subBranch';
|
||||
codeHq.value = {
|
||||
id: id,
|
||||
code: code,
|
||||
};
|
||||
}
|
||||
|
||||
const currentRecord = branchData.value.result.find((x) => x.id === id);
|
||||
|
||||
if (!currentRecord) return;
|
||||
|
||||
const currentRecordHead = branchData.value.result.find(
|
||||
(x) => x.id === currentRecord.headOfficeId,
|
||||
);
|
||||
|
||||
if (currentRecordHead) {
|
||||
codeHq.value.code = currentRecordHead.code;
|
||||
}
|
||||
|
||||
formTypeBranch.value = typeBranch;
|
||||
formType.value = 'view';
|
||||
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
function drawerEdit() {
|
||||
formType.value = 'edit';
|
||||
prevFormData.value = {
|
||||
...formData.value,
|
||||
};
|
||||
}
|
||||
|
||||
async function undo() {
|
||||
formType.value = 'view';
|
||||
formData.value = prevFormData.value;
|
||||
|
|
@ -271,6 +284,13 @@ function triggerCreate(type: string, id?: string, code?: string) {
|
|||
openDialog();
|
||||
}
|
||||
|
||||
function drawerEdit() {
|
||||
formType.value = 'edit';
|
||||
prevFormData.value = {
|
||||
...formData.value,
|
||||
};
|
||||
}
|
||||
|
||||
async function triggerEdit(type: string, id: string, code?: string) {
|
||||
await fetchBranchById(id);
|
||||
|
||||
|
|
@ -329,6 +349,7 @@ function triggerDelete(id: string) {
|
|||
async function onSubmit() {
|
||||
if (formType.value === 'edit') {
|
||||
if (modalDrawer.value) {
|
||||
const { status, ...payload } = formData.value;
|
||||
dialog({
|
||||
color: 'primary',
|
||||
icon: 'mdi-pencil-outline',
|
||||
|
|
@ -340,7 +361,9 @@ async function onSubmit() {
|
|||
const { status, ...payload } = formData.value;
|
||||
await branchStore.editById(
|
||||
codeHq.value.id,
|
||||
payload,
|
||||
{
|
||||
...payload,
|
||||
},
|
||||
profileFile.value,
|
||||
profileFileImg.value,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue