refactor: add installments type to service

This commit is contained in:
Methapon Metanipat 2024-10-22 11:59:06 +07:00
parent 5b5e264c27
commit 61bade2013
4 changed files with 13 additions and 12 deletions

View file

@ -41,7 +41,7 @@ defineExpose({
defineEmits<{ defineEmits<{
(e: 'delete', id: string, noDialog?: boolean): void; (e: 'delete', id: string, noDialog?: boolean): void;
(e: 'edit', id: string, data: { name: string }): 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 () => { onMounted(async () => {
@ -158,8 +158,7 @@ watch(
:disable="isWorkNameEdit()" :disable="isWorkNameEdit()"
@click=" @click="
() => { () => {
$emit('add', { name: '', productId: [], order: 1 }), $emit('add', { name: '', order: 1 }), (isAdd = true);
(isAdd = true);
} }
" "
> >

View file

@ -929,9 +929,9 @@ async function assignFormDataProductService(id: string) {
prevService.value.work.push({ prevService.value.work.push({
name: item.name, name: item.name,
attributes: item.attributes, attributes: item.attributes,
productId: item.productOnWork.map( product: item.productOnWork.map((productOnWorkItem) => ({
(productOnWorkItem) => productOnWorkItem.product.id, id: productOnWorkItem.product.id,
), })),
}); });
}); });
@ -1063,7 +1063,7 @@ function assignFormDataProductServiceCreate() {
formDataProductService.value.work.push({ formDataProductService.value.work.push({
name: item.name, name: item.name,
attributes: item.attributes, attributes: item.attributes,
productId: item.product.map((productItem) => productItem.id), product: item.product.map((productItem) => ({ id: productItem.id })),
}); });
}); });
} }

View file

@ -385,9 +385,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
async function createWork(data: Partial<WorkCreate>) { async function createWork(data: Partial<WorkCreate>) {
const { ...payload } = data; const { ...payload } = data;
const res = await api.post<WorkCreate>('/work', { const res = await api.post<WorkCreate>('/work', payload);
...payload,
});
if (res && res.status < 400) { if (res && res.status < 400) {
await fetchListOfWork(); await fetchListOfWork();

View file

@ -18,6 +18,7 @@ export interface Service {
createdBy: CreatedBy; createdBy: CreatedBy;
status: Status; status: Status;
attributes: Attributes; attributes: Attributes;
installments: number;
detail: string; detail: string;
name: string; name: string;
code: string; code: string;
@ -29,7 +30,6 @@ export interface Service {
export interface WorkCreate { export interface WorkCreate {
attributes: Attributes; attributes: Attributes;
productId: string[];
name: string; name: string;
order: number; order: number;
} }
@ -50,9 +50,13 @@ export interface Work {
export interface ServiceCreate { export interface ServiceCreate {
id?: string; id?: string;
installments?: number;
work: { work: {
attributes: Attributes; attributes: Attributes;
productId: string[]; product: {
id: string;
installmentNo?: number;
}[];
name: string; name: string;
}[]; }[];
attributes: Attributes; attributes: Attributes;