From a774fa1afed0e03a2785ef81cd9f522ed0a956da Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:50:43 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B8=A5=E0=B8=9A=20?= =?UTF-8?q?=E0=B8=9A=E0=B8=A3=E0=B8=B4=E0=B8=81=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/04_product-service/MainPage.vue | 145 +++++++++++++++++++--- 1 file changed, 129 insertions(+), 16 deletions(-) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index b5b9ce74..f208f9c5 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -63,6 +63,7 @@ const { fetchListServiceById, createService, deleteService, + editService, } = productServiceStore; import ItemCard from 'src/components/ItemCard.vue'; @@ -92,13 +93,17 @@ const searchTotalProduct = ref(''); const drawerInfo = ref(false); const isEdit = ref(false); + const dialogInputForm = ref(false); const dialogProduct = ref(false); const dialogService = ref(false); const dialogProductEdit = ref(false); +const dialogServiceEdit = ref(false); + const statusToggle = ref(false); const profileSubmit = ref(false); const infoProductEdit = ref(false); +const infoServiceEdit = ref(false); const imageProduct = ref(undefined); const profileUrl = ref(''); @@ -332,6 +337,8 @@ async function deleteServiceById(serviceId?: string) { await deleteService(serviceId ?? currentIdService.value); await fetchListOfService(); + + dialogServiceEdit.value = false; }, cancel: () => {}, }); @@ -430,6 +437,20 @@ async function assignFormDataProductService(id: string) { ), }); }); + + workItems.value = res.work.map((item) => { + return { + id: item.id, + name: item.name, + attributes: item.attributes, + product: item.productOnWork.map((productOnWorkItem) => { + return { + ...productOnWorkItem.product, + nameEn: '', + }; + }), + }; + }); } } @@ -490,11 +511,15 @@ function clearFormService() { work: [], }; + workItems.value = []; selectProduct.value = []; dialogService.value = false; + dialogServiceEdit.value = false; } function assignFormDataProductServiceCreate() { + formDataProductService.value.work = []; + workItems.value.forEach((item) => { formDataProductService.value.work.push({ name: item.name, @@ -506,9 +531,22 @@ function assignFormDataProductServiceCreate() { async function submitService() { assignFormDataProductServiceCreate(); - const res = await createService(formDataProductService.value); - if (res) { - await fetchListOfService(); + formDataProductService.value.image = imageProduct.value; + + if (dialogService.value) { + const res = await createService(formDataProductService.value); + if (res) { + await fetchListOfService(); + } + } + + if (dialogServiceEdit.value) { + const res = await editService(currentIdService.value, { + ...formDataProductService.value, + }); + if (res) { + await fetchListOfService(); + } } clearFormService(); @@ -1126,25 +1164,18 @@ watch(currentStatus, async () => { :created-at="i.createdAt" @menuViewDetail=" () => { - currentIdProduct = i.id; + currentIdService = i.id; + infoServiceEdit = false; assignFormDataProductService(i.id); - dialogProductEdit = true; + dialogServiceEdit = true; } " @menuEdit=" () => { - currentIdProduct = i.id; - infoProductEdit = true; + currentIdService = i.id; + infoServiceEdit = true; assignFormDataProductService(i.id); - dialogProductEdit = true; - } - " - @viewDetail=" - () => { - currentIdProduct = i.id; - infoProductEdit = false; - assignFormDataProductService(i.id); - dialogProductEdit = true; + dialogServiceEdit = true; } " /> @@ -1289,6 +1320,10 @@ watch(currentStatus, async () => { :isAddProduct="!!selectProduct.find((v) => v.id === i.id)" :isSelected="true" :data="i" + :code="i.code" + :price="i.price" + :process="i.process" + :id="i.id" typeProduct="product" :title="i.name" :status="i.status === 'INACTIVE' ? true : false" @@ -1562,6 +1597,84 @@ watch(currentStatus, async () => { > + + + + + + +