From 61bade20139d8b8fde02abe2db9ecd1c21eefa21 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Tue, 22 Oct 2024 11:59:06 +0700 Subject: [PATCH] refactor: add installments type to service --- src/components/04_product-service/WorkNameManagement.vue | 5 ++--- src/pages/04_product-service/MainPage.vue | 8 ++++---- src/stores/product-service/index.ts | 4 +--- src/stores/product-service/types.ts | 8 ++++++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/components/04_product-service/WorkNameManagement.vue b/src/components/04_product-service/WorkNameManagement.vue index 7d66ece0..2bde41ce 100644 --- a/src/components/04_product-service/WorkNameManagement.vue +++ b/src/components/04_product-service/WorkNameManagement.vue @@ -41,7 +41,7 @@ defineExpose({ defineEmits<{ (e: 'delete', id: string, noDialog?: boolean): void; (e: 'edit', id: string, data: { name: string }): void; - (e: 'add', data: { name: string; productId: []; order: number }): void; + (e: 'add', data: { name: string; order: number }): void; }>(); onMounted(async () => { @@ -158,8 +158,7 @@ watch( :disable="isWorkNameEdit()" @click=" () => { - $emit('add', { name: '', productId: [], order: 1 }), - (isAdd = true); + $emit('add', { name: '', order: 1 }), (isAdd = true); } " > diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index c33b1d80..770837d4 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -929,9 +929,9 @@ async function assignFormDataProductService(id: string) { prevService.value.work.push({ name: item.name, attributes: item.attributes, - productId: item.productOnWork.map( - (productOnWorkItem) => productOnWorkItem.product.id, - ), + product: item.productOnWork.map((productOnWorkItem) => ({ + id: productOnWorkItem.product.id, + })), }); }); @@ -1063,7 +1063,7 @@ function assignFormDataProductServiceCreate() { formDataProductService.value.work.push({ name: item.name, attributes: item.attributes, - productId: item.product.map((productItem) => productItem.id), + product: item.product.map((productItem) => ({ id: productItem.id })), }); }); } diff --git a/src/stores/product-service/index.ts b/src/stores/product-service/index.ts index c21cf549..a8aa1a63 100644 --- a/src/stores/product-service/index.ts +++ b/src/stores/product-service/index.ts @@ -385,9 +385,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { async function createWork(data: Partial) { const { ...payload } = data; - const res = await api.post('/work', { - ...payload, - }); + const res = await api.post('/work', payload); if (res && res.status < 400) { await fetchListOfWork(); diff --git a/src/stores/product-service/types.ts b/src/stores/product-service/types.ts index fcc59cbd..ab4717c3 100644 --- a/src/stores/product-service/types.ts +++ b/src/stores/product-service/types.ts @@ -18,6 +18,7 @@ export interface Service { createdBy: CreatedBy; status: Status; attributes: Attributes; + installments: number; detail: string; name: string; code: string; @@ -29,7 +30,6 @@ export interface Service { export interface WorkCreate { attributes: Attributes; - productId: string[]; name: string; order: number; } @@ -50,9 +50,13 @@ export interface Work { export interface ServiceCreate { id?: string; + installments?: number; work: { attributes: Attributes; - productId: string[]; + product: { + id: string; + installmentNo?: number; + }[]; name: string; }[]; attributes: Attributes;