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<{
(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);
}
"
>

View file

@ -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 })),
});
});
}

View file

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

View file

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