fix(05): node to selected product

This commit is contained in:
puriphatt 2024-10-17 16:48:03 +07:00
parent ad92671fd6
commit 1c3d4388f0
2 changed files with 46 additions and 6 deletions

View file

@ -1,9 +1,13 @@
import { QuotationFull } from 'src/stores/quotations/types';
export type ProductTree = {
type?: string;
id: string;
title: string;
subtitle: string;
detail?: string;
remark?: string;
attributes?: Record<string, any>;
checked: boolean;
opened: boolean;
icon: string;
@ -46,9 +50,12 @@ export function quotationProductTree(
const service = current.service;
ret.push({
type: 'service',
id: service.id,
title: service.name,
subtitle: service.code,
attributes: service.attributes,
detail: service.detail,
opened: service.work.length > 0,
checked: true,
children: service.work.flatMap((work) => {
@ -56,9 +63,12 @@ export function quotationProductTree(
relation: (typeof work)['productOnWork'][number],
): ProductTree[number] => {
return {
type: 'product',
id: relation.product.id,
title: relation.product.name,
subtitle: relation.product.code,
detail: relation.product.detail,
remark: relation.product.remark,
opened: true,
checked: !!list.find(
(v) =>
@ -86,9 +96,11 @@ export function quotationProductTree(
if (!!work.name) {
return {
type: 'work',
id: work.id,
title: work.name,
subtitle: ' ',
attributes: work.attributes,
opened: true,
checked: !!list.find(
(v) => v.service?.id === service.id && v.work?.id === work.id,
@ -108,9 +120,12 @@ export function quotationProductTree(
});
} else {
ret.push({
type: 'product',
id: current.product.id,
title: current.product.name,
subtitle: current.product.code,
detail: current.product.detail,
remark: current.product.remark,
opened: true,
checked: true,
value: {