From 2f6f9d7f95a1852c87d5c5acf61169bb7348fa62 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:41:30 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=20assignFormDataProductService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/04_product-service/MainPage.vue | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index d3395c15..39f73043 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -28,6 +28,8 @@ import { ProductCreate, ProductList, ServiceCreate, + Service, + ServiceById, } from 'src/stores/product-service/types'; const productServiceStore = useProductServiceStore(); @@ -47,6 +49,8 @@ const { fetchListProduct, createProduct, + + fetchListServiceById, } = productServiceStore; import ItemCard from 'src/components/ItemCard.vue'; @@ -308,6 +312,30 @@ function assignFormDataGroup(data: ProductGroup) { }; } +async function assignFormDataProductService(id: string) { + const res = await fetchListServiceById(id); + + if (res) { + formDataProductService.value = { + code: res.code, + name: res.name, + detail: res.detail, + attributes: res.attributes, + work: [], + }; + + res.work.forEach((item) => { + formDataProductService.value.work.push({ + name: item.name, + attributes: item.attributes, + productId: item.productOnWork.map( + (productOnWorkItem) => productOnWorkItem.product.id, + ), + }); + }); + } +} + function assignFormDataProduct(data: ProductList) { formDataProduct.value = { productTypeId: data.productTypeId,