fix: convert product to tree
This commit is contained in:
parent
1cb6414c57
commit
47272f46de
3 changed files with 84 additions and 50 deletions
|
|
@ -189,20 +189,6 @@ const formDataEmployee = ref<
|
|||
const productServiceList = ref<
|
||||
Required<QuotationPayload['productServiceList'][number]>[]
|
||||
>([]);
|
||||
const productServiceTableData = ref<
|
||||
{
|
||||
title: string;
|
||||
product: {
|
||||
amount: number;
|
||||
discount: number;
|
||||
pricePerUnit: number;
|
||||
vat: number;
|
||||
product: Product;
|
||||
service?: Service;
|
||||
work?: Work;
|
||||
}[];
|
||||
}[]
|
||||
>([{ title: '', product: [] }]);
|
||||
|
||||
async function dialogWarning(
|
||||
callback: () => void,
|
||||
|
|
@ -376,26 +362,6 @@ function convertToTable(nodes: Node[]) {
|
|||
});
|
||||
|
||||
productServiceList.value = list;
|
||||
|
||||
const pdList: Node[] = [];
|
||||
const groupByService = nodes
|
||||
.map((n) => {
|
||||
if (n.type === 'type' && n.children) {
|
||||
const products = n.children.flatMap(_recursive).map((v) => v.value);
|
||||
return {
|
||||
title: n.title,
|
||||
product: products,
|
||||
};
|
||||
} else if (n.type === 'product') {
|
||||
pdList.push(n.value);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.filter((t) => t !== null);
|
||||
if (pdList.length > 0) groupByService.push({ title: '', product: pdList });
|
||||
productServiceTableData.value = [];
|
||||
productServiceTableData.value = groupByService;
|
||||
|
||||
pageState.productServiceModal = false;
|
||||
}
|
||||
|
||||
|
|
@ -705,7 +671,6 @@ watch(
|
|||
}))
|
||||
"
|
||||
@delete="toggleDeleteProduct"
|
||||
v-model:groupList="productServiceTableData"
|
||||
v-model:rows="productServiceList"
|
||||
v-model:summary-price="summaryPrice"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue