fix: undo
This commit is contained in:
parent
d38d8af2c6
commit
4c4bca12eb
1 changed files with 29 additions and 5 deletions
|
|
@ -456,11 +456,23 @@ function assignFormDataGroup(data: ProductGroup) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prevService = ref<ServiceCreate>({
|
||||||
|
work: [],
|
||||||
|
attributes: {
|
||||||
|
additional: [],
|
||||||
|
},
|
||||||
|
detail: '',
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
});
|
||||||
|
|
||||||
async function assignFormDataProductService(id: string) {
|
async function assignFormDataProductService(id: string) {
|
||||||
const res = await fetchListServiceById(id);
|
const res = await fetchListServiceById(id);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
formDataProductService.value = {
|
statusToggle.value = res.status === 'INACTIVE' ? false : true;
|
||||||
|
|
||||||
|
prevService.value = {
|
||||||
code: res.code,
|
code: res.code,
|
||||||
name: res.name,
|
name: res.name,
|
||||||
detail: res.detail,
|
detail: res.detail,
|
||||||
|
|
@ -469,8 +481,10 @@ async function assignFormDataProductService(id: string) {
|
||||||
status: res.status,
|
status: res.status,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formDataProductService.value = { ...prevService.value };
|
||||||
|
|
||||||
res.work.forEach((item) => {
|
res.work.forEach((item) => {
|
||||||
formDataProductService.value.work.push({
|
prevService.value.work.push({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
attributes: item.attributes,
|
attributes: item.attributes,
|
||||||
productId: item.productOnWork.map(
|
productId: item.productOnWork.map(
|
||||||
|
|
@ -479,6 +493,8 @@ async function assignFormDataProductService(id: string) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
formDataProductService.value.work = prevService.value.work;
|
||||||
|
|
||||||
workItems.value = res.work.map((item) => {
|
workItems.value = res.work.map((item) => {
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
|
|
@ -585,6 +601,9 @@ async function submitService() {
|
||||||
if (dialogServiceEdit.value) {
|
if (dialogServiceEdit.value) {
|
||||||
const res = await editService(currentIdService.value, {
|
const res = await editService(currentIdService.value, {
|
||||||
...formDataProductService.value,
|
...formDataProductService.value,
|
||||||
|
status: statusToggle.value
|
||||||
|
? formDataProductService.value.status
|
||||||
|
: 'INACTIVE',
|
||||||
});
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
await fetchListOfService();
|
await fetchListOfService();
|
||||||
|
|
@ -1458,7 +1477,6 @@ watch(currentStatus, async () => {
|
||||||
@trigger="
|
@trigger="
|
||||||
() => {
|
() => {
|
||||||
dialogProductServiceType = false;
|
dialogProductServiceType = false;
|
||||||
console.log('test');
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
@ -1809,7 +1827,7 @@ watch(currentStatus, async () => {
|
||||||
<!-- edit service -->
|
<!-- edit service -->
|
||||||
<FormDialog
|
<FormDialog
|
||||||
no-address
|
no-address
|
||||||
edit
|
:edit="!(formDataProductService.status === 'INACTIVE')"
|
||||||
:isEdit="infoServiceEdit"
|
:isEdit="infoServiceEdit"
|
||||||
:title="$t('service', { msg: formDataProductService.name })"
|
:title="$t('service', { msg: formDataProductService.name })"
|
||||||
v-model:modal="dialogServiceEdit"
|
v-model:modal="dialogServiceEdit"
|
||||||
|
|
@ -1831,7 +1849,13 @@ watch(currentStatus, async () => {
|
||||||
infoServiceEdit = true;
|
infoServiceEdit = true;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
:undo="() => (infoServiceEdit = false)"
|
:undo="
|
||||||
|
() => {
|
||||||
|
infoServiceEdit = false;
|
||||||
|
formDataProductService = { ...prevService };
|
||||||
|
statusToggle = prevService.status === 'INACTIVE' ? false : true;
|
||||||
|
}
|
||||||
|
"
|
||||||
:delete-data="() => deleteServiceById()"
|
:delete-data="() => deleteServiceById()"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue