Bladeren bron

码单管理编辑逻辑修改,调整打印数据

lph 1 jaar geleden
bovenliggende
commit
c8352cd99b
2 gewijzigde bestanden met toevoegingen van 95 en 52 verwijderingen
  1. 6 9
      zkqy-ui/src/utils/print/codeListPrint.js
  2. 89 43
      zkqy-ui/src/views/orderMange/codeListManage/index.vue

+ 6 - 9
zkqy-ui/src/utils/print/codeListPrint.js

@@ -39,7 +39,7 @@ function codeListPrint(data, domId) {
       levels,//等级
       directionOfTwist,//捻向
       qrCodeData,
-      boxNumber,//箱号
+      boxNum,//箱号
       packaging
     } = item
     // let theNumber = Number(printFormat) //小包装:1  大包装:2
@@ -77,11 +77,8 @@ function codeListPrint(data, domId) {
   printWindow.document.write('</body></html>');
   // printWindow.document.close();
   // printWindow.document.body.innerHTML = document.getElementById(domId).innerHTML = res;
-  console.log(res);
-  console.log(printWindow.document);
   for (var i = 0; i < uuidList.length; i++) {
     let data = uuidList[i]
-    console.log(data.id);
     new QRCode(printWindow.document.getElementById("" + data.id), {
       text: sleep(2) + data.qrCodeData,
       width: data.size,
@@ -125,7 +122,7 @@ function printCN(uuid, item, res) {
     levels,//等级
     directionOfTwist,//捻向
     qrCodeData,
-    boxNumber,//箱号
+    boxNum,//箱号
     packaging
   } = item
   res += `<div style="width: 100%;display: flex;justify-content: center;margin:5px 0;">
@@ -149,7 +146,7 @@ function printCN(uuid, item, res) {
         <td style="width: 300px;">${levels}</td>
         <td style="width: 100px;" colspan="1">箱号</td>
         <td style="width: 250px;" colspan="1">${qrCode}</td>
-        <td style="width: 50px;" colspan="1">${boxNumber}</td>
+        <td style="width: 50px;" colspan="1">${boxNum}</td>
       </tr>
       <tr style="text-align: center;">
         <td style="width: 100px;" colspan="1">筒数</td>
@@ -161,7 +158,7 @@ function printCN(uuid, item, res) {
         <td style="width: 100px;" colspan="1">班次</td>
         <td style="width: 300px;">${workShifts}&ensp;&ensp;&ensp;${machineTool}</td>
         <td style="width: 100px;" colspan="1">日期</td>
-        <td style="width: 300px;" colspan="2">${productionDate}</td>
+        <td style="width: 300px;" colspan="2">${moment(new Date(productionDate)).format('YYYY-MM-DD')}</td>
       </tr>
       <tr style="text-align: center;">
         <td style="width: 100px;" colspan="1">毛重</td>
@@ -195,7 +192,7 @@ function printEN(uuid, item, res) {
     levels,//等级
     directionOfTwist,//捻向
     qrCodeData,
-    boxNumber,//箱号
+    boxNum,//箱号
     packaging
   } = item
   res += `<div style="width: 800px;position: relative;">
@@ -233,7 +230,7 @@ function printEN(uuid, item, res) {
       </tr>
       <tr style="text-align: center;">
         <td style="width: 100px;" colspan="1">CARTON NO:</td>
-        <td style="width: 700px;" colspan="2">${boxNumber}</td>
+        <td style="width: 700px;" colspan="2">${boxNum}</td>
       </tr>
     </table>
   </div>`

+ 89 - 43
zkqy-ui/src/views/orderMange/codeListManage/index.vue

@@ -297,28 +297,36 @@
                 >打印</el-button
               > -->
               <el-button
-                v-if="!isDisabled"
+                v-if="excuteType == 2"
+                :disabled="tableData.length != 1"
+                type="primary"
+                size="mini"
+                @click="updateOrderData"
+                >保存修改</el-button
+              >
+              <el-button
                 :disabled="tableData.length != 1"
                 type="primary"
                 size="mini"
                 @click="getOrderData"
-                >{{ excuteType == 1 ? "箱单" : "保存修改" }}</el-button
+                >箱单</el-button
               >
               <el-button
                 :disabled="tableData.length < 2"
+                v-if="excuteType == 1"
                 type="primary"
                 size="mini"
                 @click="chooseOneToPrint"
                 >{{ chooseState ? "退出批箱单" : "批箱单" }}</el-button
               >
-              <el-button
+              <!-- <el-button
                 :disabled="tableData.length != 1"
                 type="primary"
                 size="mini"
                 v-if="excuteType == 3"
                 @click="supplementCodeHandler"
                 >补码</el-button
-              >
+              > -->
             </div>
             <div class="msg" v-if="orderData.boxNo">
               <div class="msg-item">
@@ -343,7 +351,7 @@
             ></el-table-column>
             <el-table-column prop="machineTool" label="机台"> </el-table-column>
             <el-table-column
-              prop="boxNumber"
+              prop="boxNum"
               :label="`${tempStr}号`"
             ></el-table-column>
             <el-table-column
@@ -358,7 +366,7 @@
             <el-table-column prop="grossWeight" label="毛重">
               <template slot-scope="scope">
                 <el-input
-                  :disabled="isDisabled"
+                  :disabled="excuteType == 3"
                   v-model="scope.row.grossWeight"
                   @input="changeGrossWeight(scope.row)"
                   size="mini"
@@ -887,7 +895,7 @@ export default {
   },
   computed: {
     isDisabled() {
-      return this.excuteType == 3;
+      return this.excuteType != 1;
     },
   },
   methods: {
@@ -915,7 +923,7 @@ export default {
 
       console.log("打印", this.printTableData);
       this.printTableData.forEach((item) => {
-        item.qrCodeData = printData + "-" + item.boxNumber;
+        item.qrCodeData = printData + "-" + item.boxNum;
       });
       codeListPrint(this.printTableData, "printDom");
     },
@@ -938,17 +946,6 @@ export default {
     },
     // 获取箱单数据
     async getOrderData() {
-      // let year = (new Date().getFullYear() + "").slice(-2);
-      // let month = new Date().getMonth() + 1;
-      // if (month < 10) {
-      //   month = "0" + month;
-      // }
-      // let day = new Date().getDate();
-      // if (day < 10) {
-      //   day = "0" + day;
-      // }
-      // let timeStamp = (new Date().getTime() + "").slice(-5);
-      // this.orderData.boxNo = year + month + day + timeStamp;
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           try {
@@ -961,31 +958,26 @@ export default {
               qrCode: rowData.qrCode,
               lotNum: rowData.lotNum,
               // boxNum: sumBoxNum,
-              boxNum: rowData.boxNumber,
+              boxNum: rowData.boxNum,
               productId: rowData.productId,
               // cartonNumber: rowData.canisterWeight,
               suttle: rowData.suttle,
               grossWeight: rowData.grossWeight,
               productCodeListInfoList: this.tableData,
             };
+            console.log(rowData);
             if (rowData.id) {
               payLoad.id = rowData.id;
             }
             let tempApiFun = productCodeList;
-            if (this.excuteType == 1) {
-              tempApiFun = productCodeList;
-            } else if (this.excuteType == 2) {
-              tempApiFun = updateProductCodeList;
-            }
             let res = await tempApiFun(payLoad);
             let msg = this.isEdit ? "编辑" : "新增";
             if (res.code == 200) {
-              this.$message.success(`${msg}箱单成功`);
-              if (this.excuteType != 1) {
-                this.printShow = false;
-                this.getList();
-                return;
-              }
+              // if (this.excuteType != 1) {
+              //   this.printShow = false;
+              //   this.getList();
+              //   return;
+              // }
               this.tableData[0].id = res.data;
               this.printConfirmHandler(res.data);
             } else {
@@ -998,6 +990,47 @@ export default {
         }
       });
     },
+    // 保存修改箱单数据
+    updateOrderData() {
+      this.$refs.form.validate(async (valid) => {
+        if (valid) {
+          try {
+            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+              this.count;
+            let rowData = JSON.parse(JSON.stringify(this.tableData[0]));
+            this.printTableData = [rowData];
+            let payLoad = {
+              ...this.form,
+              qrCode: rowData.qrCode,
+              lotNum: rowData.lotNum,
+              // boxNum: sumBoxNum,
+              boxNum: rowData.boxNum,
+              productId: rowData.productId,
+              // cartonNumber: rowData.canisterWeight,
+              suttle: rowData.suttle,
+              grossWeight: rowData.grossWeight,
+              productCodeListInfoList: this.tableData,
+            };
+            if (rowData.id) {
+              payLoad.id = rowData.id;
+            }
+            let tempApiFun = updateProductCodeList;
+            let res = await tempApiFun(payLoad);
+            let msg = "编辑";
+            if (res.code == 200) {
+              this.$message.success(`${msg}箱单成功`);
+              this.printShow = false;
+              this.getList();
+            } else {
+              console.log(res);
+              this.$message.error(`${msg}箱单失败`);
+            }
+          } catch (error) {
+            console.error(error);
+          }
+        }
+      });
+    },
     // 选择一个打印
     chooseOneToPrint() {
       this.chooseState = !this.chooseState; //开启选择状态
@@ -1083,7 +1116,7 @@ export default {
             grossWeight: 0, //毛重
             // suttle: this.getSuttle(), //净重
             suttle: 0, //净重
-            boxNumber: this.tableData.length + 1, //序号
+            boxNum: this.tableData.length + 1, //序号
             productionDate, //日期
             printFormat, //格式
             productName,
@@ -1130,7 +1163,7 @@ export default {
                     ...this.form,
                     qrCode: rowData.qrCode,
                     lotNum: rowData.lotNum,
-                    boxNum: rowData.boxNumber,
+                    boxNum: rowData.boxNum,
                     productId: rowData.productId,
                     // cartonNumber: rowData.canisterWeight,
                     suttle: rowData.suttle,
@@ -1289,13 +1322,19 @@ export default {
       this.reset();
       const id = row.id || this.ids;
       getPrintData(id).then(async (response) => {
-        this.excuteType = 2;
-        this.form = response.data;
-        this.tableData = response.data.productCodeListInfoList || [];
-        await this.getAllBatchData(); //获取所有产品数据
-        await this.getLineOptionLsit(); //获取机台选项数据
-        await this.getSelectOptions();
-        this.printShow = true;
+        if (response.code == 200) {
+          this.excuteType = 2;
+          this.form = response.data;
+          this.tableData = [response.data] || [{}];
+
+          await this.getAllBatchData(); //获取所有产品数据
+          await this.getLineOptionLsit(); //获取机台选项数据
+          await this.getSelectOptions();
+          this.initProductData();
+          this.printShow = true;
+        } else {
+          console.log(response);
+        }
       });
     },
     // 补码回调
@@ -1305,7 +1344,7 @@ export default {
       getPrintData(id).then(async (response) => {
         this.excuteType = 3; //补码
         this.form = response.data;
-        this.tableData = response.data.productCodeListInfoList;
+        this.tableData = [response.data] || [];
         await this.getAllBatchData(); //获取所有产品数据
         await this.getLineOptionLsit(); //获取机台选项数据
         await this.getSelectOptions();
@@ -1313,11 +1352,12 @@ export default {
         this.printShow = true;
       });
     },
+
     // 初始化产品相关数据
     initProductData() {
       this.batchNum = this.form.lotNum;
       this.batchNumChange();
-      if (Object.keys(this.currentRow).length) {
+      if (this.batchTableData.length) {
         let {
           machineTool,
           boxWeight,
@@ -1339,7 +1379,13 @@ export default {
           lotNum,
           directionOfTwist,
           productId,
-        } = this.currentRow;
+        } = this.batchTableData[0];
+        Object.assign(this.tableData[0], {
+          productName, //品种
+          productSpecifications, //规格
+          productColor, //色号
+          directionOfTwist, //捻向
+        });
       }
     },
     /** 提交按钮 */