feat: เพิ่ม assignFormDataProductService

This commit is contained in:
Net 2024-06-18 15:41:30 +07:00
parent 87f0973186
commit 2f6f9d7f95

View file

@ -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,