diff --git a/src/pages/05_quotation/MainPage.vue b/src/pages/05_quotation/MainPage.vue index d9f8502b..2e3ee608 100644 --- a/src/pages/05_quotation/MainPage.vue +++ b/src/pages/05_quotation/MainPage.vue @@ -98,7 +98,7 @@ const { currentMyBranch } = storeToRefs(userBranch); const currentCustomerId = ref(); 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([ - { - 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); - + pageState.currentTab, fetchQuotationList); diff --git a/src/pages/05_quotation/ProductServiceForm.vue b/src/pages/05_quotation/ProductServiceForm.vue index 1d54335e..38b7343f 100644 --- a/src/pages/05_quotation/ProductServiceForm.vue +++ b/src/pages/05_quotation/ProductServiceForm.vue @@ -1,8 +1,21 @@