From 94c0a729da1b88ab4a0067f1e14a00264e0447cf Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期一, 15 十二月 2025 17:04:05 +0800
Subject: [PATCH] bom管理中空胶计算调整
---
north-glass-erp/northglass-erp/src/views/sd/bom/OrderBOM.vue | 163 +++++++++++++++++++++++++++++++++++++----------------
1 files changed, 113 insertions(+), 50 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/views/sd/bom/OrderBOM.vue b/north-glass-erp/northglass-erp/src/views/sd/bom/OrderBOM.vue
index a47ed5e..7ecad75 100644
--- a/north-glass-erp/northglass-erp/src/views/sd/bom/OrderBOM.vue
+++ b/north-glass-erp/northglass-erp/src/views/sd/bom/OrderBOM.vue
@@ -48,6 +48,10 @@
let orderBomData =ref({
productName:[]
})
+let bomSum = ref({
+ sumData:[],
+ sumDatilsData:[]
+})
let orderBomDetails = ref(null)
@@ -474,6 +478,9 @@
selectOrderList()
}
+//鎬讳环
+const totalPriceSum = ref()
+
//椤甸潰璺宠浆鏇存柊鎴栬�呭垹闄よ鍗�
const getTableRow = (row,type) => {
switch (type) {
@@ -482,39 +489,92 @@
request.post(`/BomData/getOrderBomData/${row.orderId}`,).then((res) => {
if (res.code == 200 ) {
orderBomData.value.productName =res.data.data
- // orderBomData.value.productName = orderBomData.value.productName.map(item => {
- // const parts = item.product_name.split(/[*+]/)
- // parts.push("鍏跺畠")
- // return {
- // ...item,
- // product_parts: parts
- // }
- // })
-
+ bomSum.value.sumData = res.data.sumData
+ bomSum.value.sumDatilsData =res.data.sumDataDatils
request.post(`/BomData/getBomDataProduct`,orderBomData.value).then((res) => {
if (res.code == 200 ) {
orderBomDetails.value=res.data.data
orderBomData.value.productName.forEach((product, i) => {
const details = orderBomDetails.value[i]?.data || []
+ const perimeter = Number(product.perimeter || 0)
+
+ // hollow锛氶噸绠� consume銆乵aterialPric
+ details.forEach(d => {
+ if (d.detail_type === 'hollow') {
+ const glueDepth = Number(d.glueDepth || 0)
+ const thickness = Number(d.thickness || 0)
+ const price = Number(d.price || 0)
+
+ // consume 淇濇寔涓烘暟瀛�
+ const consume = (glueDepth / 100) * (thickness / 100) * perimeter
+ d.consume = Number(consume.toFixed(2)) // 闇�瑕佷繚鐣�2浣嶅氨杞洖 number
+
+ // materialPric 涔熶繚鎸佷负鏁板瓧
+ d.materialPric = Number((d.consume * price).toFixed(2))
+ }
+ })
// 鐢熸垚 parts
const parts = product.product_name.split(/[*+]/)
parts.push("鍏跺畠")
product.product_parts = parts.map((p, idx) => {
- // 鎵惧嚭鎵�鏈� product_layer == idx+1 鐨� detail
- const assignedDetails = details.filter(d => d.product_layer === idx + 1)
+ const assignedDetails = details.filter(d => Number(d.product_layer) === idx + 1)
+ return { name: p, details: assignedDetails }
+ })
- return {
- name: p,
- details: assignedDetails
+ // 姣忎釜 product 鐨勬�讳环锛堜繚璇佹暟瀛楃浉鍔狅級
+ product.totalPrice = details.reduce(
+ (sum, d) => sum + Number(d.materialPric || 0),
+ 0
+ )
+ })
+
+ // 鎴愬搧鍚堣锛氫粠 details 姹囨��
+ const totalMap = new Map()
+
+ orderBomDetails.value.forEach(block => {
+ const details = block?.data || []
+ details.forEach(d => {
+ const consume = Number(d.consume || 0)
+ const price = Number(d.price || 0)
+ const key = `${Number(d.material_id)}|${String(d.detail_type || '')}|${price}`
+
+ if (!totalMap.has(key)) {
+ totalMap.set(key, {
+ material_id: d.material_id,
+ material: d.material,
+ detail_type: d.detail_type,
+ price,
+ unit: d.unit,
+ type: d.type,
+ consume: 0,
+ materialPrice: 0
+ })
}
+
+ const row = totalMap.get(key)
+ row.consume += consume
})
})
+
+ const totalSumDatilsData = Array.from(totalMap.values()).map(r => ({
+ ...r,
+ consume: Number(r.consume.toFixed(2)),
+ materialPrice: Number(r.materialPrice.toFixed(2))
+ }))
+
+ bomSum.value.sumDatilsData = totalSumDatilsData
+
+ // 姹囨�绘�婚噾棰�
+ totalPriceSum.value = orderBomData.value.productName.reduce(
+ (sum, p) => sum + Number(p.totalPrice || 0),
+ 0
+ )
+
dialogTableVisible.value = true
}
})
- console.log(orderBomData.value.productName)
}
})
@@ -582,6 +642,7 @@
return row.timeOut
}
}
+
</script>
@@ -701,39 +762,34 @@
:close-on-click-modal="false"
:close-on-press-escape="false"
>
- <el-card style="max-width: 480px;margin-left: 45px">
+ <el-card style="max-width: 480px;margin-left: 45px;margin-top: 20px">
+ <!-- header -->
<template #header>
<div class="card-header">
<span style="font-weight: bold">鎴愬搧鍚堣</span>
-      
- <span>闈㈢Н锛�1312.48銕�</span>
-      
- <span>鏁伴噺锛�200</span>
-      
- <span>鍛ㄩ暱锛�5325.7m</span>
+
+ <span>闈㈢Н锛歿{ bomSum.sumData[0].area.toFixed(2) }}銕�</span>
+
+ <span>鏁伴噺锛歿{ bomSum.sumData[0].quantity }}</span>
+
+ <span>鍛ㄩ暱锛歿{ bomSum.sumData[0].perimeter.toFixed(2) }}m</span>
</div>
</template>
- <el-row >
- <el-col :span="8">6mm瓒呯櫧锛�</el-col>
- <el-col :span="8">3149.72銕�</el-col>
+
+ <!-- body -->
+ <el-row
+ v-for="(mat, idx) in bomSum.sumDatilsData"
+ :key="idx"
+ style="text-align: left; margin-bottom: 6px"
+ >
+ <el-col :span="8">{{ mat.material }}锛�</el-col>
+ <el-col :span="8">{{ mat.consume }}銕�</el-col>
</el-row>
- <el-row>
- <el-col :span="8">8mm瓒呯櫧锛�</el-col>
- <el-col :span="8">787.72銕�</el-col>
- </el-row>
- <el-row>
- <el-col :span="8">閾濇锛�</el-col>
- <el-col :span="8">2662.85m</el-col>
- </el-row>
- <el-row>
- <el-col :span="8">0.76PVB锛�</el-col>
- <el-col :span="8">1706.22銕�</el-col>
- </el-row>
- <el-row>
- <el-col :span="8">鍏朵粬锛�</el-col>
- <el-col :span="8">5</el-col>
- </el-row>
- <template #footer>鍚堣xxx鍏�</template>
+
+ <!-- footer -->
+ <template #footer>
+ 鍚堣 楼{{ totalPriceSum }}
+ </template>
</el-card>
<el-card
@@ -750,18 +806,25 @@
<span>鏁伴噺锛歿{ item.quantity }}</span>
- <span>鍛ㄩ暱锛歿{ item.perimeter }}</span>
+ <span>鍛ㄩ暱锛歿{ Number(item.perimeter).toFixed(2) }}</span>
</div>
</template>
<!-- body -->
- <el-row v-for="(part, index) in item.product_parts" :key="index" style="text-align: left">
- <el-col :span="8">{{ part.name }}锛�</el-col>
- <el-col :span="16">
- <div v-for="(d, j) in part.details" :key="j">
- {{ d.material }} 楼{{ d.materialPric}}
- </div>
- <hr>
+ <el-row
+ v-for="(part, index) in item.product_parts"
+ :key="index"
+ style="text-align: left; margin-bottom: 6px"
+ >
+ <el-col :span="24">
+
+ <el-row v-for="(d, j) in part.details"
+ :key="j"
+ style="text-align: left">
+ <el-col :span="8">{{ d.material }}</el-col>
+ <el-col :span="8">{{ d.consume }}{{d.unit}}</el-col>
+ </el-row>
+<!-- <hr v-if="part.details.length > 0" />-->
</el-col>
</el-row>
--
Gitblit v1.8.0