refactor(05): quotation product service
This commit is contained in:
parent
1fc31f3cc5
commit
c0171a4b0c
2 changed files with 531 additions and 241 deletions
|
|
@ -98,7 +98,7 @@ const { currentMyBranch } = storeToRefs(userBranch);
|
|||
|
||||
const currentCustomerId = ref<string | undefined>();
|
||||
const refreshImageState = ref(false);
|
||||
const emptyCreateDialog = ref(true);
|
||||
const emptyCreateDialog = ref(false);
|
||||
const onCreateImageList = ref<{
|
||||
selectedImage: string;
|
||||
list: { url: string; imgFile: File | null; name: string }[];
|
||||
|
|
@ -120,95 +120,6 @@ const tabFieldRequired = ref<{ [key: string]: (keyof CustomerBranchCreate)[] }>(
|
|||
},
|
||||
);
|
||||
|
||||
const nodes = ref<Node[]>([
|
||||
{
|
||||
title: 'กลุ่มสินค้าและบริการที่ 1',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'group',
|
||||
children: [
|
||||
{
|
||||
title:
|
||||
'บริการค่าบริการและค่าดำเนินงานยื่นแบบคำร้องขอนำเข้า MOU (Demand)',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'type',
|
||||
children: [
|
||||
{
|
||||
title: 'งาน 1',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'work',
|
||||
children: [
|
||||
{
|
||||
title: 'สินค้า 1',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'product',
|
||||
},
|
||||
{
|
||||
title: 'สินค้า 2',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'product',
|
||||
},
|
||||
{
|
||||
title: 'สินค้า 3',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'product',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
title: 'กลุ่มสินค้าและบริการที่ 2',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'group',
|
||||
children: [
|
||||
{
|
||||
title:
|
||||
'บริการค่าบริการและค่าดำเนินงานยื่นแบบคำร้องขอนำเข้า MOU (Demand)',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'type',
|
||||
children: [
|
||||
{
|
||||
title: 'งาน 1',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'work',
|
||||
children: [
|
||||
{
|
||||
title: 'สินค้า 1',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'product',
|
||||
},
|
||||
{
|
||||
title: 'สินค้า 2',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'product',
|
||||
},
|
||||
{
|
||||
title: 'สินค้า 3',
|
||||
subtitle: 'TG01000000001',
|
||||
selected: false,
|
||||
type: 'product',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
const productServiceStore = useProductServiceStore();
|
||||
const router = useRouter();
|
||||
|
||||
|
|
@ -509,78 +420,7 @@ async function getService(id: string, force = false) {
|
|||
}
|
||||
|
||||
function convertToTree() {
|
||||
const node = productGroup.value.map((g) => ({
|
||||
id: g.id,
|
||||
title: g.name,
|
||||
subtitle: g.code,
|
||||
detail: g.detail,
|
||||
remark: g.remark,
|
||||
type: 'group',
|
||||
displayDropIcon: g._count.service + g._count.product !== 0,
|
||||
}));
|
||||
nodes.value = node;
|
||||
}
|
||||
|
||||
async function openProductServiceTree(node: Node, anchestor?: Node[]) {
|
||||
if (node.type === 'group') {
|
||||
const curGroupNode = nodes.value.find((v) => v.id === node.id);
|
||||
await getAllService(node.id);
|
||||
if (!curGroupNode) return;
|
||||
|
||||
curGroupNode.children = serviceList.value[curGroupNode.id]?.map((t) => ({
|
||||
id: t.id,
|
||||
title: t.name,
|
||||
subtitle: t.code,
|
||||
detail: t.detail,
|
||||
type: 'type',
|
||||
displayDropIcon: t.work.length > 0,
|
||||
}));
|
||||
}
|
||||
|
||||
if (node.type === 'type' && anchestor && anchestor[0].children) {
|
||||
const curTypeNode = anchestor[0].children.find((v) => v.id === node.id);
|
||||
const curType = serviceList.value[anchestor[0].id]?.find(
|
||||
(v) => v.id === node.id,
|
||||
);
|
||||
if (!curTypeNode) return;
|
||||
const noNameWork = curType.work
|
||||
.filter((v) => !v.name)
|
||||
.flatMap((v) =>
|
||||
v.productOnWork.map((p) => ({
|
||||
id: p.product.id,
|
||||
title: p.product.name,
|
||||
subtitle: p.product.code,
|
||||
detail: p.product.detail,
|
||||
remark: p.product.remark,
|
||||
type: 'product',
|
||||
icon: 'mdi-shopping-outline',
|
||||
bg: 'hsla(var(--teal-10-hsl)/0.1)',
|
||||
fg: 'var(--teal-10)',
|
||||
})),
|
||||
);
|
||||
const withNameWork = curType.work
|
||||
.filter((v) => v.name)
|
||||
.flatMap((w) => ({
|
||||
id: w.id,
|
||||
title: w.name,
|
||||
subtitle: ' ',
|
||||
attributes: {
|
||||
additional: w.attributes.additional,
|
||||
showTotalPrice: w.attributes.showTotalPrice,
|
||||
},
|
||||
type: 'work',
|
||||
displayDropIcon: w.productOnWork.length > 0,
|
||||
children: w.productOnWork.map((p) => ({
|
||||
id: p.product.id,
|
||||
title: p.product.name,
|
||||
subtitle: p.product.code,
|
||||
detail: p.product.detail,
|
||||
remark: p.product.remark,
|
||||
type: 'product',
|
||||
})),
|
||||
}));
|
||||
curTypeNode.children = noNameWork.concat(withNameWork);
|
||||
}
|
||||
// TODO: convert quotation product service data to tree
|
||||
}
|
||||
|
||||
const quotationStore = useQuotationStore();
|
||||
|
|
@ -1019,7 +859,7 @@ watch(() => pageState.currentTab, fetchQuotationList);
|
|||
</section>
|
||||
</DialogForm>
|
||||
|
||||
<!-- add employee -->
|
||||
<!-- add employee quotation -->
|
||||
<DialogForm
|
||||
:title="$t('general.select', { msg: $t('quotation.employeeList') })"
|
||||
v-model:modal="pageState.employeeModal"
|
||||
|
|
@ -1714,8 +1554,15 @@ watch(() => pageState.currentTab, fetchQuotationList);
|
|||
|
||||
<ProductServiceForm
|
||||
v-model="pageState.productServiceModal"
|
||||
v-model:nodes="nodes"
|
||||
@open="openProductServiceTree"
|
||||
v-model:product-group="productGroup"
|
||||
v-model:product-list="productList"
|
||||
v-model:service-list="serviceList"
|
||||
@select-group="
|
||||
async (id) => {
|
||||
await getAllService(id);
|
||||
await getAllProduct(id);
|
||||
}
|
||||
"
|
||||
></ProductServiceForm>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue