From 45d912e20aa2520b837150791343e045e285bd59 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:44:13 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E0=B9=82=E0=B8=84=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B8=AB=E0=B8=B2=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/04_product-service/MainPage.vue | 29 +++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index 70f79cd2..a2bf0dab 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -636,11 +636,14 @@ const prevService = ref({ productTypeId: '', }); +const currentService = ref(); + async function assignFormDataProductService(id: string) { const res = await fetchListServiceById(id); if (res) { statusToggle.value = res.status === 'INACTIVE' ? false : true; + currentService.value = JSON.parse(JSON.stringify(res)); prevService.value = { code: res.code, @@ -674,7 +677,7 @@ async function assignFormDataProductService(id: string) { product: item.productOnWork.map((productOnWorkItem) => { return { ...productOnWorkItem.product, - nameEn: '', + nameEn: productOnWorkItem.product.name, }; }), }; @@ -945,6 +948,28 @@ async function fetchSearch() { } } +function cloneData() { + if (!currentService.value) return; + formDataProductService.value = { + ...prevService.value, + attributes: JSON.parse(JSON.stringify(currentService.value.attributes)), + }; + + workItems.value = currentService.value.work.map((item) => { + return { + id: item.id, + name: item.name, + attributes: JSON.parse(JSON.stringify(item.attributes)), + product: item.productOnWork.map((productOnWorkItem) => { + return { + ...productOnWorkItem.product, + nameEn: productOnWorkItem.product.name, + }; + }), + }; + }); +} + onMounted(async () => { calculateStats(); await fetchListGroups(); @@ -2160,7 +2185,7 @@ watch(currentPageService, async () => { :undo=" () => { infoServiceEdit = false; - formDataProductService = { ...prevService }; + cloneData(); statusToggle = prevService.status === 'INACTIVE' ? false : true; flowStore.rotate(); }