diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index b32c3d4b..843c8311 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -456,11 +456,23 @@ function assignFormDataGroup(data: ProductGroup) { }; } +const prevService = ref({ + 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 () => { { infoServiceEdit = true; } " - :undo="() => (infoServiceEdit = false)" + :undo=" + () => { + infoServiceEdit = false; + formDataProductService = { ...prevService }; + statusToggle = prevService.status === 'INACTIVE' ? false : true; + } + " :delete-data="() => deleteServiceById()" >