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 |  261 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 173 insertions(+), 88 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 6c19daa..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
@@ -45,7 +45,15 @@
   dataTotal : 0,
   pageSize : 50
 })
+let orderBomData =ref({
+  productName:[]
+})
+let bomSum = ref({
+  sumData:[],
+  sumDatilsData:[]
+})
 
+let orderBomDetails = ref(null)
 
 const xGrid = ref()
 const gridOptions = reactive({
@@ -119,8 +127,6 @@
   columns:[
     {title: t('basicData.operate'), width: 110, slots: { default: 'button_slot' },fixed:"left",},
     {type: 'seq', title: t('basicData.Number'), width: 80 ,fixed:"left",},
-
-
     {field: 'orderId',width:120,  title: t('order.orderId'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
     {field: 'customerId',width:120,  title: t('customer.customerNumber'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
     {field: 'customerName',width:120,  title: t('customer.customerName'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
@@ -129,6 +135,7 @@
     {field: 'quantity',width:120,  title: t('order.quantity'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
    // {field: 'goodsQuantity',width:120,  title: t('searchOrder.inventoryNum'), sortable: true},
     {field: 'area',width:120,  title: t('order.computeGrossArea'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
+    {field: 'bomPrice',width:120,  title: t('bom.bomPrice'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
     {field: 'money',width:120,  title: t('order.money'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
     {field: 'createTime',width:120,filters:[{ data: '' }],slots: { filter: 'num1_filter' },   title: t('basicData.reportData'), sortable: true},
     {field: 'packType',width:120,  title: t('order.packType'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true},
@@ -171,10 +178,10 @@
         if (columnIndex === 0) {
           return t('basicData.total')
         }
-        const List = ["quantity",'goodsQuantity','area','perimeter','money']
+        const List = ["quantity",'goodsQuantity','area','perimeter','money','bomPrice']
         if (List.includes(column.field)) {
-          //return footSum(data, column.field)
-          return total.value[column.field]
+          return footSum(data, column.field)
+          //return total.value[column.field]
         }
         return ''
       })
@@ -334,9 +341,9 @@
   },
   cellClick({ row }){
     rowClickIndex.value = row
-    xGrid.value.menuConfig.body.options[0][3].children.forEach((item)=>{
-      item.disabled=true
-    })
+    // xGrid.value.menuConfig.body.options[0][3].children.forEach((item)=>{
+    //   item.disabled=true
+    // })
     //鍒ゆ柇鏄惁鍏ュ簱
     if(row.warehousing>0){
       return
@@ -374,6 +381,9 @@
       /*total.dataTotal = res.data.total.dataTotal*1
       total.pageTotal= res.data.total.pageTotal*/
       orderInfo.selectDate = res.data.selectDate
+      res.data.data.forEach((item)=>{
+        item.bomPrice=(item.money/1.3).toFixed(2)
+      })
       orderList.value = deepClone(res.data.data)
       xGrid.value.loadData(orderList.value)
     }else{
@@ -468,11 +478,110 @@
   selectOrderList()
 }
 
+//鎬讳环
+const totalPriceSum = ref()
+
 //椤甸潰璺宠浆鏇存柊鎴栬�呭垹闄よ鍗�
 const getTableRow =  (row,type) => {
   switch (type) {
     case 'edit': {
-      dialogTableVisible.value = true
+      if (row.orderId!="" && row.orderId!=null){
+        request.post(`/BomData/getOrderBomData/${row.orderId}`,).then((res) => {
+          if (res.code == 200 ) {
+            orderBomData.value.productName =res.data.data
+            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) => {
+                    const assignedDetails = details.filter(d => Number(d.product_layer) === idx + 1)
+                    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
+              }
+            })
+          }
+        })
+
+
+      }
+
+
       break
     }
 
@@ -533,6 +642,7 @@
     return row.timeOut
   }
 }
+
 
 </script>
 
@@ -652,101 +762,76 @@
         :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>
-            &nbsp &nbsp &nbsp
-            <span>闈㈢Н锛�1312.48銕�</span>
-            &nbsp &nbsp &nbsp
-            <span>鏁伴噺锛�200</span>
-            &nbsp &nbsp &nbsp
-            <span>鍛ㄩ暱锛�5325.7m</span>
+            &nbsp;&nbsp;&nbsp;
+            <span>闈㈢Н锛歿{ bomSum.sumData[0].area.toFixed(2) }}銕�</span>
+            &nbsp;&nbsp;&nbsp;
+            <span>鏁伴噺锛歿{ bomSum.sumData[0].quantity }}</span>
+            &nbsp;&nbsp;&nbsp;
+            <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 style="max-width: 480px;margin-left: 45px;margin-top: 20px">
+      <el-card
+          v-for="item in orderBomData.productName"
+          :key="item.product_id"
+          style="max-width: 480px;margin-left: 45px;margin-top: 20px"
+      >
+        <!-- header -->
         <template #header>
           <div class="card-header">
-            <span style="font-weight: bold">6mm瓒呯櫧閽㈠寲+12A+6mm瓒呯櫧閽㈠寲+0.76PVB+6mm瓒呯櫧閽㈠寲</span>
-            <br/>
-            <span>闈㈢Н锛�656.24銕�</span>
-            &nbsp &nbsp &nbsp
-            <span>鏁伴噺锛�100</span>
-            &nbsp &nbsp &nbsp
-            <span>鍛ㄩ暱锛�2662.85m</span>
+            <span style="font-weight: bold">{{ item.product_name }}</span>
+            <br />
+            <span>闈㈢Н锛歿{ item.area }}</span>
+            &nbsp;&nbsp;&nbsp;
+            <span>鏁伴噺锛歿{ item.quantity }}</span>
+            &nbsp;&nbsp;&nbsp;
+            <span>鍛ㄩ暱锛歿{ Number(item.perimeter).toFixed(2) }}</span>
           </div>
         </template>
-        <el-row >
-          <el-col :span="8">6mm瓒呯櫧锛�</el-col>
-          <el-col :span="8">2362.464銕�</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">853.11銕�</el-col>
-        </el-row>
-        <el-row>
-          <el-col :span="8">鍏朵粬锛�</el-col>
-          <el-col :span="8">5</el-col>
+
+        <!-- body -->
+        <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>
 
-          <template #footer>鍚堣xxx鍏�</template>
+        <!-- footer -->
+        <template #footer>鍚堣 {{ item.totalPrice }}</template>
       </el-card>
 
-      <el-card style="max-width: 480px;margin-left: 45px;margin-top: 20px">
-        <template #header>
-          <div class="card-header">
-            <span style="font-weight: bold">8mm瓒呯櫧閽㈠寲+0.76PVB+6mm瓒呯櫧閽㈠寲</span>
-            <br/>
-            <span>闈㈢Н锛�656.24銕�</span>
-            &nbsp &nbsp &nbsp
-            <span>鏁伴噺锛�100</span>
-            &nbsp &nbsp &nbsp
-            <span>鍛ㄩ暱锛�2662.85m</span>
-          </div>
-        </template>
-        <el-row >
-          <el-col :span="8">6mm瓒呯櫧锛�</el-col>
-          <el-col :span="8">787.72銕�</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">0.76PVB锛�</el-col>
-          <el-col :span="8">853.11銕�</el-col>
-        </el-row>
-
-                  <template #footer>鍚堣xxx鍏�</template>
-      </el-card>
       <template #footer>
         <div class="dialog-footer">
           <el-button type="primary">杞噰璐崟</el-button>

--
Gitblit v1.8.0