廖井涛
4 天以前 4955996ab044bc275ac78da3543b9d9f5ad7f8d9
north-glass-erp/northglass-erp/src/views/sd/bom/OrderBOM.vue
@@ -48,6 +48,12 @@
let orderBomData =ref({
  productName:[]
})
let bomSum = ref({
  sumData:[],
  sumDatilsData:[]
})
let orderBomDetails = ref(null)
const xGrid = ref()
const gridOptions = reactive({
@@ -335,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
@@ -480,17 +486,37 @@
        request.post(`/BomData/getOrderBomData/${row.orderId}`,).then((res) => {
          if (res.code == 200 ) {
            orderBomData.value.productName =res.data.data
            console.log(orderBomData.value.productName)
            bomSum.value.sumData = res.data.sumData
            bomSum.value.sumDatilsData  =res.data.sumDataDatils
            request.post(`/BomData/getBomDataProduct`,orderBomData.value).then((res) => {
              if (res.code == 200 ) {
                console.log(res.data.data)
                orderBomDetails.value=res.data.data
                orderBomData.value.productName.forEach((product, i) => {
                  const details = orderBomDetails.value[i]?.data || []
                  // 生成 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)
                    return {
                      name: p,
                      details: assignedDetails
                    }
                  })
                  // 计算总价
                  product.totalPrice = details.reduce((sum, d) => sum + (d.materialPric || 0) , 0)
                })
                dialogTableVisible.value = true
              }
            })
          }
        })
        dialogTableVisible.value = true
      }
@@ -555,6 +581,10 @@
  }
}
//总价
const totalPrice = computed(() => {
  return bomSum.value.sumDatilsData.reduce((sum, d) => sum + d.materialPrice, 0)
})
</script>
<template>
@@ -673,101 +703,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>
          合计 ¥{{ totalPrice }}
        </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>