From c51f664bebe83db1770645eca6068156f6a7ba2d Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 3 Oct 2024 15:33:20 +0700 Subject: [PATCH] refactor: quotation form & product service --- src/pages/05_quotation/ProductServiceForm.vue | 46 +++--- src/pages/05_quotation/QuotationForm.vue | 136 ++++++++++-------- 2 files changed, 90 insertions(+), 92 deletions(-) diff --git a/src/pages/05_quotation/ProductServiceForm.vue b/src/pages/05_quotation/ProductServiceForm.vue index 809925db..e36e6068 100644 --- a/src/pages/05_quotation/ProductServiceForm.vue +++ b/src/pages/05_quotation/ProductServiceForm.vue @@ -140,6 +140,7 @@ function mapCard() { attributes: s.attributes, createAt: s.createdAt, selectedImage: s.selectedImage, + raw: s, })) || [], product: productList.value[selectedProductGroup.value]?.map((p) => ({ @@ -154,6 +155,7 @@ function mapCard() { serviceCharge: p.serviceCharge, process: p.process, selectedImage: p.selectedImage, + raw: p, })) || [], }; @@ -165,15 +167,12 @@ function mapNode() { const node = selectedItems.value.map((v: Node) => { if (v.type === 'service') { return { + type: 'type', id: v.id, title: v.name, subtitle: v.code, - detail: v.detail, - attributes: { - additional: v.attributes.additional, - }, + raw: v.raw, opened: v.work.length > 0, - type: 'type', icon: 'mdi-server-outline', bg: 'hsla(var(--orange-5-hsl)/0.1)', fg: 'var(--orange-5)', @@ -182,38 +181,30 @@ function mapNode() { .filter((w: Work) => !w.name) .flatMap((w: Work) => w.productOnWork.map((p) => ({ + type: 'product', id: p.product.id, title: p.product.name, subtitle: p.product.code || ' ', - detail: p.product.detail, - remark: p.product.remark, - price: p.product.price, - agentPrice: p.product.agentPrice, - serviceCharge: p.product.serviceCharge, + raw: p.product, icon: 'mdi-shopping-outline', bg: 'hsla(var(--teal-10-hsl)/0.1)', fg: 'var(--teal-10)', - type: 'product', })), ); const withNameObjects = v.work .filter((w: Work) => w.name) .flatMap((w: Work) => ({ + type: 'work', id: w.id, title: w.name, subtitle: ' ', - attributes: w.attributes, - type: 'work', + raw: w, opened: 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, - price: p.product.price, - agentPrice: p.product.agentPrice, - serviceCharge: p.product.serviceCharge, + raw: p.product, type: 'product', })), })); @@ -225,11 +216,7 @@ function mapNode() { id: v.id, title: v.name, subtitle: v.code, - detail: v.detail, - remark: v.remark, - price: v.price, - agentPrice: v.agentPrice, - serviceCharge: v.serviceCharge, + raw: v.raw, type: 'product', icon: 'mdi-shopping-outline', bg: 'hsla(var(--teal-10-hsl)/0.1)', @@ -525,7 +512,7 @@ watch(
@@ -593,16 +580,17 @@ watch( " class="surface-3 q-pa-md" > - {{ selectedNode[0].remark || '-' }} + {{ selectedNode[0].raw.remark || '-' }}