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;
|
profileFile.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerView(
|
async function triggerView(
|
||||||
id: string,
|
id: string,
|
||||||
typeBranch: 'headOffice' | 'subBranch',
|
typeBranch: 'headOffice' | 'subBranch',
|
||||||
code?: string,
|
code?: string,
|
||||||
) {
|
) {
|
||||||
fetchBranchById(id);
|
await fetchBranchById(id);
|
||||||
if (id && code && typeBranch === 'headOffice') {
|
if (id && code && typeBranch === 'headOffice') {
|
||||||
|
formTypeBranch.value = 'headOffice';
|
||||||
|
codeHq.value = {
|
||||||
|
id: id,
|
||||||
|
code: code,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeBranch === 'subBranch' && id && code) {
|
||||||
|
formTypeBranch.value = 'subBranch';
|
||||||
codeHq.value = {
|
codeHq.value = {
|
||||||
id: id,
|
id: id,
|
||||||
code: code,
|
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;
|
formTypeBranch.value = typeBranch;
|
||||||
formType.value = 'view';
|
formType.value = 'view';
|
||||||
|
|
||||||
openDrawer();
|
openDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawerEdit() {
|
|
||||||
formType.value = 'edit';
|
|
||||||
prevFormData.value = {
|
|
||||||
...formData.value,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function undo() {
|
async function undo() {
|
||||||
formType.value = 'view';
|
formType.value = 'view';
|
||||||
formData.value = prevFormData.value;
|
formData.value = prevFormData.value;
|
||||||
|
|
@ -271,6 +284,13 @@ function triggerCreate(type: string, id?: string, code?: string) {
|
||||||
openDialog();
|
openDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawerEdit() {
|
||||||
|
formType.value = 'edit';
|
||||||
|
prevFormData.value = {
|
||||||
|
...formData.value,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function triggerEdit(type: string, id: string, code?: string) {
|
async function triggerEdit(type: string, id: string, code?: string) {
|
||||||
await fetchBranchById(id);
|
await fetchBranchById(id);
|
||||||
|
|
||||||
|
|
@ -329,6 +349,7 @@ function triggerDelete(id: string) {
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
if (formType.value === 'edit') {
|
if (formType.value === 'edit') {
|
||||||
if (modalDrawer.value) {
|
if (modalDrawer.value) {
|
||||||
|
const { status, ...payload } = formData.value;
|
||||||
dialog({
|
dialog({
|
||||||
color: 'primary',
|
color: 'primary',
|
||||||
icon: 'mdi-pencil-outline',
|
icon: 'mdi-pencil-outline',
|
||||||
|
|
@ -340,7 +361,9 @@ async function onSubmit() {
|
||||||
const { status, ...payload } = formData.value;
|
const { status, ...payload } = formData.value;
|
||||||
await branchStore.editById(
|
await branchStore.editById(
|
||||||
codeHq.value.id,
|
codeHq.value.id,
|
||||||
payload,
|
{
|
||||||
|
...payload,
|
||||||
|
},
|
||||||
profileFile.value,
|
profileFile.value,
|
||||||
profileFileImg.value,
|
profileFileImg.value,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue