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) {
|
||||
const res = await fetchListServiceById(id);
|
||||
|
||||
if (res) {
|
||||
formDataProductService.value = {
|
||||
statusToggle.value = res.status === 'INACTIVE' ? false : true;
|
||||
|
||||
prevService.value = {
|
||||
code: res.code,
|
||||
name: res.name,
|
||||
detail: res.detail,
|
||||
|
|
@ -469,8 +481,10 @@ async function assignFormDataProductService(id: string) {
|
|||
status: res.status,
|
||||
};
|
||||
|
||||
formDataProductService.value = { ...prevService.value };
|
||||
|
||||
res.work.forEach((item) => {
|
||||
formDataProductService.value.work.push({
|
||||
prevService.value.work.push({
|
||||
name: item.name,
|
||||
attributes: item.attributes,
|
||||
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) => {
|
||||
return {
|
||||
id: item.id,
|
||||
|
|
@ -585,6 +601,9 @@ async function submitService() {
|
|||
if (dialogServiceEdit.value) {
|
||||
const res = await editService(currentIdService.value, {
|
||||
...formDataProductService.value,
|
||||
status: statusToggle.value
|
||||
? formDataProductService.value.status
|
||||
: 'INACTIVE',
|
||||
});
|
||||
if (res) {
|
||||
await fetchListOfService();
|
||||
|
|
@ -1458,7 +1477,6 @@ watch(currentStatus, async () => {
|
|||
@trigger="
|
||||
() => {
|
||||
dialogProductServiceType = false;
|
||||
console.log('test');
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
|
@ -1809,7 +1827,7 @@ watch(currentStatus, async () => {
|
|||
<!-- edit service -->
|
||||
<FormDialog
|
||||
no-address
|
||||
edit
|
||||
:edit="!(formDataProductService.status === 'INACTIVE')"
|
||||
:isEdit="infoServiceEdit"
|
||||
:title="$t('service', { msg: formDataProductService.name })"
|
||||
v-model:modal="dialogServiceEdit"
|
||||
|
|
@ -1831,7 +1849,13 @@ watch(currentStatus, async () => {
|
|||
infoServiceEdit = true;
|
||||
}
|
||||
"
|
||||
:undo="() => (infoServiceEdit = false)"
|
||||
:undo="
|
||||
() => {
|
||||
infoServiceEdit = false;
|
||||
formDataProductService = { ...prevService };
|
||||
statusToggle = prevService.status === 'INACTIVE' ? false : true;
|
||||
}
|
||||
"
|
||||
:delete-data="() => deleteServiceById()"
|
||||
>
|
||||
<template #prepend>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue