Эх сурвалжийг харах

生产备料。增加筛选字段,打印备料单数据调整

lxf 1 жил өмнө
parent
commit
6f9b213a95

+ 48 - 24
src/views/shengde/productionSystem/productionOperation/batching/stay.vue

@@ -121,7 +121,7 @@
       <el-table-column label="BOM品名" prop="nameChinese" align="left" min-width="200" />
       <el-table-column label="BOM品名" prop="nameChinese" align="left" min-width="200" />
       <el-table-column label="SKU品号" prop="productColorCode" width="160" />
       <el-table-column label="SKU品号" prop="productColorCode" width="160" />
       <el-table-column label="SKU品名" prop="productColorName" min-width="200" />
       <el-table-column label="SKU品名" prop="productColorName" min-width="200" />
-      <el-table-column label="尺寸 (长*宽*高)" prop="productColorCode" width="180">
+      <el-table-column label="尺寸 (长*宽*高)" width="180">
         <template slot-scope="scope">
         <template slot-scope="scope">
           <div>{{ scope.row.length }} * {{ scope.row.width }} * {{ scope.row.height }}</div>
           <div>{{ scope.row.length }} * {{ scope.row.width }} * {{ scope.row.height }}</div>
         </template>
         </template>
@@ -177,20 +177,22 @@
         <table border class="table">
         <table border class="table">
           <thead>
           <thead>
             <tr>
             <tr>
-              <td>编号</td>
-              <td>物料品号</td>
-              <td>物料品名</td>
-              <td>数量</td>
-              <td>备注</td>
+              <td style="width: 6%; text-align: center">编号</td>
+              <td style="width: 18%">物料品号</td>
+              <td style="width: 38%">物料品名</td>
+              <td style="width: 18%">SKU品号</td>
+              <td style="width: 10%; text-align: center">数量小计</td>
+              <td style="width: 10%; text-align: center">数量总计</td>
             </tr>
             </tr>
           </thead>
           </thead>
-          <tbody>
-            <tr v-for="(item, index) in printBomList" :key="index">
-              <td style="width: 8%">{{ index + 1 }}</td>
-              <td style="width: 20%">{{ item.specCode }}</td>
-              <td style="width: 35%">{{ item.nameChinese }}</td>
-              <td style="width: 12%">{{ item.quantity }}</td>
-              <td style="width: 25%"></td>
+          <tbody v-for="(item, index) in printBomList" :key="index">
+            <tr v-for="(itemSKU, indexSKU) in item.SKUList" :key="indexSKU">
+              <td :rowspan="item.SKUList.length" v-if="indexSKU === 0" style="text-align: center">{{ index + 1 }}</td>
+              <td :rowspan="item.SKUList.length" v-if="indexSKU === 0">{{ item.specCode }}</td>
+              <td :rowspan="item.SKUList.length" v-if="indexSKU === 0">{{ item.nameChinese }}</td>
+              <td>{{ itemSKU.productColorCode }}</td>
+              <td style="text-align: center">{{ itemSKU.quantity }}</td>
+              <td :rowspan="item.SKUList.length" v-if="indexSKU === 0" style="text-align: center">{{ item.quantity }}</td>
             </tr>
             </tr>
           </tbody>
           </tbody>
         </table>
         </table>
@@ -345,19 +347,41 @@ export default {
     outExcel() {
     outExcel() {
       if (!this.excelList.length > 0) return this.msgInfo('请选择要打印的备料单!')
       if (!this.excelList.length > 0) return this.msgInfo('请选择要打印的备料单!')
       this.printTime = ''
       this.printTime = ''
-      let arr = this.sortOut(this.excelList, 'bomColorId') //根据bom规格id进行数据归类
-      //对相同的bom规格id的数据中的数量进行汇总
-      arr.sort((a, b) => b.sort - a.sort)
-      for (let i = 0; i < arr.length; i++) {
-        const iele = arr[i]
-        let sum = 0
-        for (let j = 0; j < iele.children.length; j++) {
-          const jele = iele.children[j]
-          sum = sum + Number(jele.quantity)
+      let arr = this.excelList.filter((item) => item.dataResource === 1)
+      let demoList = []
+      if (arr && arr.length > 0) {
+        let bomColorList = Array.from(new Set(arr.map((item) => item.bomColorId)))
+        for (let i = 0; i < bomColorList.length; i++) {
+          let list = arr.filter((item) => item.bomColorId === bomColorList[i])
+          let productColorList = Array.from(new Set(list.map((item) => item.productColorId)))
+          let sum = 0
+          let demoListTwo = []
+          for (let j = 0; j < productColorList.length; j++) {
+            let sumTwo = 0
+            let listTwo = list.filter((item) => item.productColorId === productColorList[j])
+            for (let y = 0; y < listTwo.length; y++) {
+              if (listTwo[y].quantity) {
+                sumTwo = Number(parseFloat(Number(sumTwo) + Number(listTwo[y].quantity)).toFixed(0))
+              }
+            }
+            demoListTwo.push({
+              productColorCode: listTwo[0].productColorCode,
+              quantity: sumTwo,
+            })
+            sum = Number(parseFloat(Number(sum) + Number(sumTwo)).toFixed(0))
+          }
+
+          demoList.push({
+            specCode: list[0].specCode,
+            nameChinese: list[0].nameChinese,
+            quantity: sum,
+            SKUList: demoListTwo,
+          })
         }
         }
-        iele.quantity = sum
+      } else {
+        return this.msgInfo('请选择主材进行打印!')
       }
       }
-      this.printBomList = arr
+      this.printBomList = demoList
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.$confirm('确认打印吗?', '警告', {
         this.$confirm('确认打印吗?', '警告', {
           confirmButtonText: '确定',
           confirmButtonText: '确定',