fix: quotation product count
This commit is contained in:
parent
98e7aff985
commit
89265882d5
1 changed files with 25 additions and 1 deletions
|
|
@ -141,7 +141,7 @@ function toggleDelete(node?: Node) {
|
|||
targetItem &&
|
||||
deleteItem(selectedItems.value, selectedItems.value.indexOf(targetItem));
|
||||
targetNode && deleteItem(nodes.value, nodes.value.indexOf(targetNode));
|
||||
if (node.type === 'type') {
|
||||
if (node.type === 'service') {
|
||||
const countProducts = (node: Node[]) => {
|
||||
let count = 0;
|
||||
|
||||
|
|
@ -365,6 +365,24 @@ function mapNode() {
|
|||
nodes.value = JSON.parse(JSON.stringify(node));
|
||||
pageState.addModal = false;
|
||||
}
|
||||
|
||||
function countCheckedProducts(array: Node[]) {
|
||||
let count = 0;
|
||||
|
||||
for (const item of array) {
|
||||
// Check if both conditions are true
|
||||
if (item.checked && item.type === 'product') {
|
||||
count++;
|
||||
}
|
||||
// Recursively check children if present
|
||||
if (Array.isArray(item.children)) {
|
||||
count += countCheckedProducts(item.children);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => selectedNode.value,
|
||||
(v) => {
|
||||
|
|
@ -563,6 +581,12 @@ watch(
|
|||
$t('general.list', {
|
||||
msg: $t('productService.title'),
|
||||
})
|
||||
}},
|
||||
{{
|
||||
$t('general.selected', {
|
||||
number: countCheckedProducts(nodes),
|
||||
msg: $t('productService.product.product'),
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
<TreeView
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue