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,