fix: product count & ref delete & fetch worker
This commit is contained in:
parent
62edd051e6
commit
0b83c943c0
2 changed files with 47 additions and 8 deletions
|
|
@ -134,9 +134,33 @@ function toggleDelete(node?: Node) {
|
||||||
selectedItems.value = [];
|
selectedItems.value = [];
|
||||||
} else {
|
} else {
|
||||||
const targetItem = selectedItems.value.find((i) => i.id === node?.id);
|
const targetItem = selectedItems.value.find((i) => i.id === node?.id);
|
||||||
deleteItem(nodes.value, nodes.value.indexOf(node));
|
const targetNode = nodes.value.find((i) => i === node);
|
||||||
|
|
||||||
targetItem &&
|
targetItem &&
|
||||||
deleteItem(selectedItems.value, selectedItems.value.indexOf(targetItem));
|
deleteItem(selectedItems.value, selectedItems.value.indexOf(targetItem));
|
||||||
|
targetNode && deleteItem(nodes.value, nodes.value.indexOf(targetNode));
|
||||||
|
if (node.type === 'type') {
|
||||||
|
const countProducts = (node: Node[]) => {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
node.forEach((item) => {
|
||||||
|
if (item.type === 'product') {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
count += countProducts(item.children);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return count;
|
||||||
|
};
|
||||||
|
const count = node.children && countProducts(node.children);
|
||||||
|
|
||||||
|
if (count) productCount.value = productCount.value - count;
|
||||||
|
} else {
|
||||||
|
productCount.value--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,6 +225,7 @@ function mapNode() {
|
||||||
title: v.name,
|
title: v.name,
|
||||||
subtitle: v.code,
|
subtitle: v.code,
|
||||||
opened: v.work.length > 0,
|
opened: v.work.length > 0,
|
||||||
|
attributes: v.attributes,
|
||||||
checked: true,
|
checked: true,
|
||||||
icon: 'mdi-server-outline',
|
icon: 'mdi-server-outline',
|
||||||
bg: 'hsla(var(--orange-5-hsl)/0.1)',
|
bg: 'hsla(var(--orange-5-hsl)/0.1)',
|
||||||
|
|
@ -216,6 +241,7 @@ function mapNode() {
|
||||||
const pricePerUnit = p.product.vatIncluded
|
const pricePerUnit = p.product.vatIncluded
|
||||||
? precisionRound(price / (1 + (config.value?.vat || 0.07)))
|
? precisionRound(price / (1 + (config.value?.vat || 0.07)))
|
||||||
: price;
|
: price;
|
||||||
|
productCount.value++;
|
||||||
return {
|
return {
|
||||||
type: 'product',
|
type: 'product',
|
||||||
id: p.product.id,
|
id: p.product.id,
|
||||||
|
|
@ -243,9 +269,11 @@ function mapNode() {
|
||||||
const withNameObjects = v.work
|
const withNameObjects = v.work
|
||||||
.filter((w: Work) => w.name)
|
.filter((w: Work) => w.name)
|
||||||
.flatMap((w: Work) => ({
|
.flatMap((w: Work) => ({
|
||||||
|
type: 'work',
|
||||||
id: w.id,
|
id: w.id,
|
||||||
title: w.name,
|
title: w.name,
|
||||||
subtitle: ' ',
|
subtitle: ' ',
|
||||||
|
attributes: w.attributes,
|
||||||
opened: w.productOnWork.length > 0,
|
opened: w.productOnWork.length > 0,
|
||||||
checked: true,
|
checked: true,
|
||||||
children: w.productOnWork.map((p) => {
|
children: w.productOnWork.map((p) => {
|
||||||
|
|
@ -257,6 +285,7 @@ function mapNode() {
|
||||||
: price;
|
: price;
|
||||||
productCount.value++;
|
productCount.value++;
|
||||||
return {
|
return {
|
||||||
|
type: 'product',
|
||||||
id: p.product.id,
|
id: p.product.id,
|
||||||
title: p.product.name,
|
title: p.product.name,
|
||||||
subtitle: p.product.code || ' ',
|
subtitle: p.product.code || ' ',
|
||||||
|
|
@ -284,6 +313,7 @@ function mapNode() {
|
||||||
: price;
|
: price;
|
||||||
productCount.value++;
|
productCount.value++;
|
||||||
return {
|
return {
|
||||||
|
type: 'product',
|
||||||
id: v.id,
|
id: v.id,
|
||||||
title: v.name,
|
title: v.name,
|
||||||
subtitle: v.code,
|
subtitle: v.code,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { storeToRefs } from 'pinia';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
|
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
|
||||||
import { dialogCheckData } from 'stores/utils';
|
import { dialogCheckData } from 'stores/utils';
|
||||||
import { quotationProductTree } from './utils';
|
import { ProductTree, quotationProductTree } from './utils';
|
||||||
|
|
||||||
// NOTE: Import stores
|
// NOTE: Import stores
|
||||||
import { setLocale, dateFormat, calculateAge } from 'src/utils/datetime';
|
import { setLocale, dateFormat, calculateAge } from 'src/utils/datetime';
|
||||||
|
|
@ -544,11 +544,11 @@ watch(
|
||||||
url.searchParams.set('customerBranchId', v);
|
url.searchParams.set('customerBranchId', v);
|
||||||
history.pushState({}, '', url.toString());
|
history.pushState({}, '', url.toString());
|
||||||
|
|
||||||
// if (!v) return;
|
if (!v) return;
|
||||||
// const retEmp = await customerStore.fetchBranchEmployee(v);
|
const retEmp = await customerStore.fetchBranchEmployee(v);
|
||||||
// if (retEmp) {
|
if (retEmp) {
|
||||||
// workerList.value = retEmp.data.result;
|
workerList.value = retEmp.data.result;
|
||||||
// }
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -561,6 +561,15 @@ watch(
|
||||||
history.pushState({}, '', url.toString());
|
history.pushState({}, '', url.toString());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const productServiceNodes = ref<ProductTree>();
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => productServiceList.value,
|
||||||
|
() => {
|
||||||
|
productServiceNodes.value = quotationProductTree(productServiceList.value);
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -942,7 +951,7 @@ watch(
|
||||||
<!-- add product service -->
|
<!-- add product service -->
|
||||||
<ProductServiceForm
|
<ProductServiceForm
|
||||||
v-model="pageState.productServiceModal"
|
v-model="pageState.productServiceModal"
|
||||||
:nodes="quotationProductTree(productServiceList)"
|
v-model:nodes="productServiceNodes"
|
||||||
v-model:product-group="productGroup"
|
v-model:product-group="productGroup"
|
||||||
v-model:product-list="productList"
|
v-model:product-list="productList"
|
||||||
v-model:service-list="serviceList"
|
v-model:service-list="serviceList"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue