Bläddra i källkod

拆分码单管理

lph 1 år sedan
förälder
incheckning
bf93adcf3d

+ 110 - 94
zkqy-ui/src/views/orderMange/codeListManage/index.vue

@@ -48,16 +48,16 @@
             icon="el-icon-search"
             size="mini"
             @click="handleQuery"
-          >搜索
+            >搜索
           </el-button>
           <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
-          >重置
+            >重置
           </el-button>
         </el-form-item>
       </el-form>
 
       <el-row :gutter="10" class="mb8">
-        <el-col :span="1.5">
+        <!-- <el-col :span="1.5">
           <el-button
             type="primary"
             plain
@@ -65,9 +65,9 @@
             size="mini"
             @click="printHandler"
             v-hasPermi="['system:productCodeList:add']"
-          >打印
+            >打印
           </el-button>
-        </el-col>
+        </el-col> -->
         <!-- <el-col :span="1.5">
           <el-button
             type="success"
@@ -89,7 +89,7 @@
             :disabled="multiple"
             @click="handleDelete"
             v-hasPermi="['system:productCodeList:remove']"
-          >删除
+            >删除
           </el-button>
         </el-col>
         <el-col :span="1.5">
@@ -100,7 +100,7 @@
             size="mini"
             @click="handleExport"
             v-hasPermi="['system:productCodeList:export']"
-          >导出
+            >导出
           </el-button>
         </el-col>
         <right-toolbar
@@ -114,22 +114,22 @@
         :data="productCodeListList"
         @selection-change="handleSelectionChange"
       >
-        <el-table-column type="selection" width="55" align="center"/>
-        <el-table-column label="码单号" align="center" prop="qrCode"/>
-        <el-table-column label="品名" align="center" prop="productName"/>
+        <el-table-column type="selection" width="55" align="center" />
+        <el-table-column label="码单号" align="center" prop="qrCode" />
+        <el-table-column label="品名" align="center" prop="productName" />
         <el-table-column
           label="规格"
           align="center"
           prop="productSpecifications"
         />
-        <el-table-column label="批号" align="center" prop="lotNum"/>
-        <el-table-column label="色泽" align="center" prop="productColor"/>
+        <el-table-column label="批号" align="center" prop="lotNum" />
+        <el-table-column label="色泽" align="center" prop="productColor" />
         <!-- <el-table-column label="货品编号" align="center" prop="productId" /> -->
-        <el-table-column label="等级" align="center" prop="levels"/>
-        <el-table-column label="筒数" align="center" prop="totalCanisterNum"/>
-        <el-table-column label="箱数" align="center" prop="totalBoxNum"/>
-        <el-table-column label="净重" align="center" prop="totalSuttle"/>
-        <el-table-column label="备注" align="center" prop="remark"/>
+        <el-table-column label="等级" align="center" prop="levels" />
+        <el-table-column label="筒数" align="center" prop="totalCanisterNum" />
+        <el-table-column label="箱数" align="center" prop="totalBoxNum" />
+        <el-table-column label="净重" align="center" prop="totalSuttle" />
+        <el-table-column label="备注" align="center" prop="remark" />
         <el-table-column
           label="操作"
           align="center"
@@ -148,7 +148,7 @@
                     icon="el-icon-edit"
                     @click="handleUpdate(scope.row)"
                     v-hasPermi="['system:productCodeList:edit']"
-                  >修改
+                    >修改
                   </el-button>
                 </el-dropdown-item>
                 <el-dropdown-item>
@@ -157,7 +157,7 @@
                     type="text"
                     icon="el-icon-circle-plus-outline"
                     @click="supplementCode(scope.row)"
-                  >补码
+                    >补码
                   </el-button>
                 </el-dropdown-item>
                 <el-dropdown-item>
@@ -167,7 +167,7 @@
                     icon="el-icon-delete"
                     @click="handleDelete(scope.row)"
                     v-hasPermi="['system:productCodeList:remove']"
-                  >删除
+                    >删除
                   </el-button>
                 </el-dropdown-item>
               </el-dropdown-menu>
@@ -193,25 +193,25 @@
       >
         <el-form ref="form" :model="form" :rules="rules" label-width="80px">
           <el-form-item label="码单号" prop="qrCode">
-            <el-input v-model="form.qrCode" placeholder="请输入码单号"/>
+            <el-input v-model="form.qrCode" placeholder="请输入码单号" />
           </el-form-item>
           <el-form-item label="批号" prop="lotNum">
-            <el-input v-model="form.lotNum" placeholder="请输入批号"/>
+            <el-input v-model="form.lotNum" placeholder="请输入批号" />
           </el-form-item>
           <el-form-item label="货品编号" prop="productId">
-            <el-input v-model="form.productId" placeholder="请输入货品编号"/>
+            <el-input v-model="form.productId" placeholder="请输入货品编号" />
           </el-form-item>
           <el-form-item label="等级" prop="levels">
-            <el-input v-model="form.levels" placeholder="请输入等级"/>
+            <el-input v-model="form.levels" placeholder="请输入等级" />
           </el-form-item>
           <el-form-item label="筒数" prop="canisterNum">
-            <el-input v-model="form.canisterNum" placeholder="请输入筒数"/>
+            <el-input v-model="form.canisterNum" placeholder="请输入筒数" />
           </el-form-item>
           <el-form-item label="箱数" prop="boxNum">
-            <el-input v-model="form.boxNum" placeholder="请输入箱数"/>
+            <el-input v-model="form.boxNum" placeholder="请输入箱数" />
           </el-form-item>
           <el-form-item label="净重" prop="suttle">
-            <el-input v-model="form.suttle" placeholder="请输入净重"/>
+            <el-input v-model="form.suttle" placeholder="请输入净重" />
           </el-form-item>
           <el-form-item label="生产日期" prop="productionDate">
             <el-date-picker
@@ -224,16 +224,16 @@
             </el-date-picker>
           </el-form-item>
           <el-form-item label="机台" prop="machineTool">
-            <el-input v-model="form.machineTool" placeholder="请输入机台"/>
+            <el-input v-model="form.machineTool" placeholder="请输入机台" />
           </el-form-item>
           <el-form-item label="毛重" prop="grossWeight">
-            <el-input v-model="form.grossWeight" placeholder="请输入毛重"/>
+            <el-input v-model="form.grossWeight" placeholder="请输入毛重" />
           </el-form-item>
           <el-form-item label="包装" prop="packaging">
-            <el-input v-model="form.packaging" placeholder="请输入包装"/>
+            <el-input v-model="form.packaging" placeholder="请输入包装" />
           </el-form-item>
           <el-form-item label="班次" prop="workShifts">
-            <el-input v-model="form.workShifts" placeholder="请输入班次"/>
+            <el-input v-model="form.workShifts" placeholder="请输入班次" />
           </el-form-item>
           <el-form-item label="外贸号" prop="foreignTradeNumber">
             <el-input
@@ -242,22 +242,22 @@
             />
           </el-form-item>
           <el-form-item label="筒重" prop="canisterWeight">
-            <el-input v-model="form.canisterWeight" placeholder="请输入筒重"/>
+            <el-input v-model="form.canisterWeight" placeholder="请输入筒重" />
           </el-form-item>
           <el-form-item label="箱重/车重" prop="boxWeight">
-            <el-input v-model="form.boxWeight" placeholder="请输入箱重/车重"/>
+            <el-input v-model="form.boxWeight" placeholder="请输入箱重/车重" />
           </el-form-item>
           <el-form-item label="管色" prop="tubeColor">
-            <el-input v-model="form.tubeColor" placeholder="请输入管色"/>
+            <el-input v-model="form.tubeColor" placeholder="请输入管色" />
           </el-form-item>
           <el-form-item label="端口" prop="comPort">
-            <el-input v-model="form.comPort" placeholder="请输入端口"/>
+            <el-input v-model="form.comPort" placeholder="请输入端口" />
           </el-form-item>
           <el-form-item label="打印格式" prop="printFormat">
-            <el-input v-model="form.printFormat" placeholder="请输入打印格式"/>
+            <el-input v-model="form.printFormat" placeholder="请输入打印格式" />
           </el-form-item>
           <el-form-item label="库位" prop="storageLocation">
-            <el-input v-model="form.storageLocation" placeholder="请输入库位"/>
+            <el-input v-model="form.storageLocation" placeholder="请输入库位" />
           </el-form-item>
           <el-form-item label="区域编号" prop="warehouseregionId">
             <el-input
@@ -273,7 +273,7 @@
             />
           </el-form-item>
           <el-form-item label="删除标志" prop="delFlag">
-            <el-input v-model="form.delFlag" placeholder="请输入删除标志"/>
+            <el-input v-model="form.delFlag" placeholder="请输入删除标志" />
           </el-form-item>
           <el-form-item label="创建者编号" prop="createById">
             <el-input
@@ -316,7 +316,7 @@
                     type="primary"
                     size="mini"
                     @click="updateOrderData"
-                  >保存修改
+                    >保存修改
                   </el-button>
                   <!-- <el-button
                     :disabled="tableData.length != 1"
@@ -341,14 +341,14 @@
                   >
                   </el-switch>
                   <el-button type="primary" size="mini" @click="readStateChange"
-                  >{{ isStartReadNum ? "停止读数" : "开始读数" }}
+                    >{{ isStartReadNum ? "停止读数" : "开始读数" }}
                   </el-button>
                   <el-button
                     v-show="!printAuto"
                     type="success"
                     size="mini"
                     @click="printBtnHandler"
-                  >打印
+                    >打印
                   </el-button>
                 </div>
                 <div class="weightWrap" v-show="excuteType == 1">
@@ -426,7 +426,7 @@
                     size="mini"
                     :disabled="chooseState"
                     @click="handleSaveOne(scope.row)"
-                  >保存修改
+                    >保存修改
                   </el-button>
                   <el-button
                     v-else-if="excuteType == 3"
@@ -434,7 +434,7 @@
                     size="mini"
                     :disabled="chooseState"
                     @click="handleSuppleOne(scope.row)"
-                  >打印
+                    >打印
                   </el-button>
 
                   <el-button
@@ -443,7 +443,7 @@
                     size="mini"
                     :disabled="chooseState"
                     @click="handleDeleteOne(scope.$index)"
-                  >删除
+                    >删除
                   </el-button>
                 </template>
               </el-table-column>
@@ -790,8 +790,8 @@ import {
   getPrintDataNew,
 } from "@/api/codeListManage/productCodeList";
 import codeListPrint from "@/utils/print/codeListPrint";
-import {getServerPrintData} from "@/utils/print/printUtils";
-import {v4 as uuidv4} from "uuid";
+import { getServerPrintData } from "@/utils/print/printUtils";
+import { v4 as uuidv4 } from "uuid";
 
 export default {
   name: "ProductCodeList",
@@ -862,36 +862,36 @@ export default {
       },
       rules: {
         grossWeight: [
-          {required: true, message: "请输入重量", trigger: "change"},
+          { required: true, message: "请输入重量", trigger: "change" },
         ],
         packaging: [
-          {required: true, message: "请选择包装", trigger: "change"},
+          { required: true, message: "请选择包装", trigger: "change" },
         ],
         machineTool: [
-          {required: true, message: "请选择机台", trigger: "change"},
+          { required: true, message: "请选择机台", trigger: "change" },
         ],
         workShifts: [
-          {required: true, message: "请选择班次", trigger: "change"},
+          { required: true, message: "请选择班次", trigger: "change" },
         ],
         productionDate: [
-          {required: true, message: "请选择生产日期", trigger: "change"},
+          { required: true, message: "请选择生产日期", trigger: "change" },
         ],
-        levels: [{required: true, message: "请选择等级", trigger: "change"}],
+        levels: [{ required: true, message: "请选择等级", trigger: "change" }],
         // foreignTradeNumber: [
         //   { required: true, message: "请输入外贸号", trigger: "blur" },
         // ],
         canisterWeight: [
-          {required: true, message: "请选择筒重", trigger: "change"},
+          { required: true, message: "请选择筒重", trigger: "change" },
         ],
         boxWeight: [
-          {required: true, message: "请选择箱重/车重", trigger: "change"},
+          { required: true, message: "请选择箱重/车重", trigger: "change" },
         ],
         tubeColor: [
-          {required: true, message: "请选择管色", trigger: "change"},
+          { required: true, message: "请选择管色", trigger: "change" },
         ],
-        comPort: [{required: true, message: "请选择端口", trigger: "change"}],
+        comPort: [{ required: true, message: "请选择端口", trigger: "change" }],
         printFormat: [
-          {required: true, message: "请选择格式", trigger: "change"},
+          { required: true, message: "请选择格式", trigger: "change" },
         ],
       },
       dropDownData: {},
@@ -1030,19 +1030,22 @@ export default {
     initWebSocket() {
       // console.log("开始连接ws", process.env.VUE_APP_BASE_WS_API);
       let automatis_printing = this.dict.type.automatic_printing;
-      let frequency = automatis_printing.find( // 等到稳定次数
+      let frequency = automatis_printing.find(
+        // 等到稳定次数
         (item) => item.label == "frequency"
       )?.value;
       if (frequency == undefined) {
         frequency = 30;
       }
-      let minimumWeight = automatis_printing.find( // 打印最小值
+      let minimumWeight = automatis_printing.find(
+        // 打印最小值
         (item) => item.label == "minimumWeight"
       )?.value;
       if (minimumWeight == undefined) {
         minimumWeight = 5;
       }
-      let antishake = automatis_printing.find(  // 防抖
+      let antishake = automatis_printing.find(
+        // 防抖
         (item) => item.label == "antishake"
       )?.value;
       if (antishake == undefined) {
@@ -1280,7 +1283,7 @@ export default {
     // 毛重改变回调
     changeGrossWeight(row) {
       console.log(row);
-      let {boxWeight, grossWeight, canisterWeight, canisterNum} = row;
+      let { boxWeight, grossWeight, canisterWeight, canisterNum } = row;
       if (!Number(grossWeight)) {
         row.suttle = 0;
         return;
@@ -1304,7 +1307,7 @@ export default {
     // 确认保存修改一条数据
     async handleSaveOne(row) {
       try {
-        let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
+        let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
           this.count;
         let rowData = JSON.parse(JSON.stringify(row));
         let payLoad = {
@@ -1386,7 +1389,7 @@ export default {
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           try {
-            let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
+            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
               this.count;
             let rowData = newData.machineTool
               ? JSON.parse(JSON.stringify(newData))
@@ -1443,7 +1446,7 @@ export default {
       this.$refs.form.validate(async (valid) => {
         if (valid) {
           try {
-            let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
+            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
               this.count;
             let rowData = JSON.parse(JSON.stringify(this.tableData[0]));
             this.printTableData = [rowData];
@@ -1587,7 +1590,7 @@ export default {
     },
     // 计算净重
     getSuttle() {
-      let {boxWeight, canisterWeight, canisterNum} = this.form;
+      let { boxWeight, canisterWeight, canisterNum } = this.form;
       return (Number(boxWeight) - canisterWeight * canisterNum).toFixed(2);
     },
     // 表格点击回调
@@ -1630,7 +1633,7 @@ export default {
             this.$refs.form.validate(async (valid) => {
               if (valid) {
                 try {
-                  let {sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight} =
+                  let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
                     this.count;
                   let rowData = JSON.parse(JSON.stringify(row));
                   this.printTableData = [rowData];
@@ -1710,8 +1713,7 @@ export default {
         if (res.code == 200) {
           this.dropDownData = res.data;
         }
-      } catch (error) {
-      }
+      } catch (error) {}
     },
     /** 查询产品码单列表 */
     getList() {
@@ -1804,37 +1806,45 @@ export default {
       console.log(row);
       this.reset();
       const id = row.qrCode;
-      getPrintDataNew(id).then(async (response) => {
-        if (response.code == 200) {
-          this.excuteType = 2;
-          this.form = response.data[0];
-          this.tableData = response.data;
-
-          await this.getAllBatchData(); //获取所有产品数据
-          await this.getLineOptionLsit(); //获取机台选项数据
-          await this.getSelectOptions();
-          this.initProductData();
-          this.printShow = true;
-        } else {
-          console.log(response);
-        }
+      this.$router.push({
+        path: "/baozhuang/codePrint",
+        query: { excuteType: 2, qrCode: id },
       });
+      // getPrintDataNew(id).then(async (response) => {
+      //   if (response.code == 200) {
+      //     this.excuteType = 2;
+      //     this.form = response.data[0];
+      //     this.tableData = response.data;
+
+      //     await this.getAllBatchData(); //获取所有产品数据
+      //     await this.getLineOptionLsit(); //获取机台选项数据
+      //     await this.getSelectOptions();
+      //     this.initProductData();
+      //     this.printShow = true;
+      //   } else {
+      //     console.log(response);
+      //   }
+      // });
     },
     // 补码回调
     supplementCode(row) {
       this.reset();
       const id = row.qrCode;
-      getPrintDataNew(id).then(async (response) => {
-        this.excuteType = 3; //补码
-        this.printAuto = false;
-        this.form = response.data[0];
-        this.tableData = response.data;
-        await this.getAllBatchData(); //获取所有产品数据
-        await this.getLineOptionLsit(); //获取机台选项数据
-        await this.getSelectOptions();
-        this.initProductData();
-        this.printShow = true;
+      this.$router.push({
+        path: "/baozhuang/codePrint",
+        query: { excuteType: 3, qrCode: id },
       });
+      // getPrintDataNew(id).then(async (response) => {
+      //   this.excuteType = 3; //补码
+      //   this.printAuto = false;
+      //   this.form = response.data[0];
+      //   this.tableData = response.data;
+      //   await this.getAllBatchData(); //获取所有产品数据
+      //   await this.getLineOptionLsit(); //获取机台选项数据
+      //   await this.getSelectOptions();
+      //   this.initProductData();
+      //   this.printShow = true;
+      // });
     },
 
     // 初始化产品相关数据
@@ -1911,8 +1921,7 @@ export default {
           this.getList();
           this.$modal.msgSuccess("删除成功");
         })
-        .catch(() => {
-        });
+        .catch(() => {});
     },
     /** 导出按钮操作 */
     handleExport() {
@@ -2002,4 +2011,11 @@ export default {
 ::v-deep .el-input-number--mini {
   width: 99%;
 }
+
+::v-deep .el-table .current-row {
+  background-color: #55e905 !important;
+}
+::v-deep .el-table__body tr.current-row > td.el-table__cell {
+  background-color: #55e905 !important;
+}
 </style>

+ 1716 - 0
zkqy-ui/src/views/orderMange/codeListManage/printIndex.vue

@@ -0,0 +1,1716 @@
+<template>
+  <el-card shadow="always" :body-style="{ padding: '10px' }">
+    <div class="app-container">
+      <div class="main-wrap">
+        <div class="left">
+          <div class="top-area">
+            <div class="btn-list mb10">
+              <!-- <el-button type="primary" size="mini" @click="printConfirmHandler"
+                >打印</el-button
+              > -->
+              <div class="btnWrap" v-show="excuteType == 1">
+                <el-button
+                  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"
+                    >箱单
+                  </el-button>
+                  <el-button
+                    :disabled="tableData.length < 2"
+                    v-if="excuteType == 1"
+                    type="primary"
+                    size="mini"
+                    @click="chooseOneToPrint"
+                    >{{ chooseState ? "退出批箱单" : "批箱单" }}
+                  </el-button> -->
+                <el-switch
+                  class="ml10 mr10"
+                  v-model="printAuto"
+                  active-text="自动打印"
+                  inactive-text="手动打印"
+                >
+                </el-switch>
+                <el-button type="primary" size="mini" @click="readStateChange"
+                  >{{ isStartReadNum ? "停止读数" : "开始读数" }}
+                </el-button>
+                <el-button
+                  v-show="!printAuto"
+                  type="success"
+                  size="mini"
+                  @click="printBtnHandler"
+                  >打印
+                </el-button>
+              </div>
+              <div class="weightWrap" v-show="excuteType == 1">
+                <h1>实时重量:{{ nowWeight }}</h1>
+              </div>
+              <!-- <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">
+                <span>箱单号:{{ orderData.boxNo }}</span>
+              </div>
+              <div class="msg-item ml10">
+                <span>{{ orderData.msg }}</span>
+              </div>
+            </div>
+          </div>
+          <el-table
+            :data="tableData"
+            border
+            stripe
+            style="width: 100%; margin-bottom: 5px"
+            @cell-click="handlePrintOneChange"
+          >
+            <el-table-column
+              type="index"
+              width="50"
+              label="序号"
+            ></el-table-column>
+            <el-table-column prop="machineTool" label="机台"> </el-table-column>
+            <el-table-column
+              prop="boxNum"
+              :label="`${tempStr}号`"
+            ></el-table-column>
+            <el-table-column
+              prop="boxWeight"
+              :label="`${tempStr}重`"
+            ></el-table-column>
+            <el-table-column
+              prop="canisterWeight"
+              label="筒重"
+            ></el-table-column>
+            <el-table-column prop="canisterNum" label="筒数"></el-table-column>
+            <el-table-column prop="grossWeight" label="毛重">
+              <template slot-scope="scope">
+                <el-input
+                  v-if="excuteType == 2"
+                  v-model="scope.row.grossWeight"
+                  @input="changeGrossWeight(scope.row)"
+                  size="mini"
+                  clearable
+                ></el-input>
+                <span v-else>{{ scope.row.grossWeight }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column prop="suttle" label="净重"></el-table-column>
+            <el-table-column prop="workShifts" label="班次"></el-table-column>
+            <el-table-column prop="tubeColor" label="管色"></el-table-column>
+            <el-table-column prop="remark" label="备注"></el-table-column>
+            <el-table-column :fixed="'right'" label="操作">
+              <template slot-scope="scope">
+                <el-button
+                  v-if="excuteType == 2"
+                  type="primary"
+                  size="mini"
+                  :disabled="chooseState"
+                  @click="handleSaveOne(scope.row)"
+                  >保存修改
+                </el-button>
+                <el-button
+                  v-else-if="excuteType == 3"
+                  type="primary"
+                  size="mini"
+                  :disabled="chooseState"
+                  @click="handleSuppleOne(scope.row)"
+                  >打印
+                </el-button>
+
+                <el-button
+                  v-else
+                  type="danger"
+                  size="mini"
+                  :disabled="chooseState"
+                  @click="handleDeleteOne(scope.$index)"
+                  >删除
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <div class="count-area">
+            <div class="count-item">
+              <div class="count-title">
+                <span>合计{{ tempStr }}数:</span>
+              </div>
+              <div class="count-value">
+                <span>{{ count.sumBoxNum }}</span>
+              </div>
+            </div>
+            <div class="count-item">
+              <div class="count-title">
+                <span>合计筒数:</span>
+              </div>
+              <div class="count-value">
+                <span>{{ count.sumCanisterNum }}</span>
+              </div>
+            </div>
+            <div class="count-item">
+              <div class="count-title">
+                <span>合计毛重:</span>
+              </div>
+              <div class="count-value">
+                <span>{{ count.sumGrossWeight }}</span>
+              </div>
+            </div>
+            <div class="count-item">
+              <div class="count-title">
+                <span>合计净重:</span>
+              </div>
+              <div class="count-value">
+                <span>{{ count.sumSuttle }}</span>
+              </div>
+            </div>
+          </div>
+        </div>
+        <div class="right">
+          <el-row :gutter="10">
+            <el-form
+              :model="form"
+              ref="form"
+              :rules="rules"
+              label-width="80px"
+              :inline="false"
+              size="normal"
+              :disabled="isDisabled || isStartReadNum"
+            >
+              <el-col :span="8">
+                <el-form-item prop="packaging" label="包装">
+                  <el-select
+                    v-model="form.packaging"
+                    clearable
+                    filterable
+                    size="mini"
+                    @change="packagingChange"
+                  >
+                    <el-option
+                      v-for="item in dict.type.packaging_type"
+                      :key="item.raw.dictCode"
+                      :label="item.label"
+                      :value="item.value"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="machineTool" label="机台">
+                  <el-select
+                    v-model="form.machineTool"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="(item, index) in lineOptions"
+                      :key="index"
+                      :label="item.productionLineNo"
+                      :value="item.productionLineNo"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="workShifts" label="班次">
+                  <el-select
+                    v-model="form.workShifts"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="item in dropDownData.work_shifts"
+                      :key="item.id"
+                      :label="item.codeName"
+                      :value="item.codeName"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="productionDate" label="日期">
+                  <el-date-picker
+                    v-model="form.productionDate"
+                    type="date"
+                    size="mini"
+                    value-format="yyyy-MM-dd"
+                  >
+                  </el-date-picker>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="levels" label="等级">
+                  <el-select
+                    v-model="form.levels"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="item in dropDownData.level"
+                      :key="item.id"
+                      :label="item.codeName"
+                      :value="item.codeName"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="foreignTradeNumber" label="外贸号">
+                  <el-input
+                    v-model="form.foreignTradeNumber"
+                    size="mini"
+                    clearable
+                  ></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="canisterWeight" label="筒重">
+                  <el-select
+                    v-model="form.canisterWeight"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="item in dropDownData.drum_weight"
+                      :key="item.id"
+                      :label="item.codeName"
+                      :value="item.codeName"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+
+              <el-col :span="8">
+                <el-form-item prop="canisterNum" label="筒数">
+                  <el-input-number
+                    v-model="form.canisterNum"
+                    size="mini"
+                    label=""
+                    :min="1"
+                    :step="1"
+                    :controls="true"
+                    controls-position="both"
+                  >
+                  </el-input-number>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="boxWeight" :label="`${tempStr}重`">
+                  <el-select
+                    v-model="form.boxWeight"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="item in dropDownData.box_weight"
+                      :key="item.id"
+                      :label="item.codeName"
+                      :value="item.codeName"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="tubeColor" label="管色">
+                  <el-select
+                    v-model="form.tubeColor"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="item in dropDownData.tube_color"
+                      :key="item.id"
+                      :label="item.codeName"
+                      :value="item.codeName"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="printFormat" label="格式">
+                  <el-select
+                    v-model="form.printFormat"
+                    clearable
+                    filterable
+                    size="mini"
+                  >
+                    <el-option
+                      v-for="item in dict.type.coding_list_format"
+                      :key="item.raw.dictCode"
+                      :label="item.label"
+                      :value="item.value"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-col>
+              <el-col :span="8">
+                <el-form-item prop="grossWeight" label="毛重">
+                  <el-input
+                    v-model="form.grossWeight"
+                    @input="changeGrossWeightForm"
+                    size="mini"
+                    clearable
+                  ></el-input>
+                </el-form-item>
+                <!-- <el-form-item prop="comPort" label="端口">
+                    <el-select
+                      v-model="form.comPort"
+                      clearable
+                      filterable
+                      size="mini"
+                    >
+                      <el-option
+                        v-for="item in dict.type.port"
+                        :key="item.raw.dictCode"
+                        :label="item.label"
+                        :value="item.value"
+                      >
+                      </el-option>
+                    </el-select>
+                  </el-form-item> -->
+              </el-col>
+
+              <el-col :span="24">
+                <el-form-item prop="remark" label="备注">
+                  <el-input
+                    type="textarea"
+                    :rows="2"
+                    v-model="form.remark"
+                    :show-word-limit="false"
+                    :autosize="{ minRows: 2, maxRows: 4 }"
+                  >
+                  </el-input>
+                </el-form-item>
+              </el-col>
+            </el-form>
+          </el-row>
+          <div class="queryForm">
+            <span class="label">批号过滤 :</span>
+            <el-input
+              v-model="batchNum"
+              placeholder="请输入批号"
+              size="mini"
+              clearable
+              @input="batchNumChange"
+              @keyup.enter.native="batchNumChange"
+              :disabled="isDisabled || isStartReadNum"
+            ></el-input>
+            <!-- <el-button
+                class="ml10"
+                type="primary"
+                size="mini"
+                :disabled="!currentRow.lotNum || isDisabled || printAuto"
+                @click="addProductHandler"
+                >添加
+              </el-button> -->
+          </div>
+          <div class="table-wrap">
+            <el-table
+              ref="proTableRef"
+              :data="batchTableData"
+              border
+              stripe
+              width="100%"
+              max-height="260"
+              highlight-current-row
+              @current-change="handleCurrentChange"
+            >
+              <!-- <el-table-column
+                  type="index"
+                  label="序号"
+                  width="50"
+                ></el-table-column> -->
+              <el-table-column
+                v-for="col in columns"
+                :prop="col.id"
+                :key="col.id"
+                :label="col.label"
+              >
+              </el-table-column>
+            </el-table>
+          </div>
+        </div>
+      </div>
+
+      <div id="printDom" style="width: 160px; height: 160px"></div>
+    </div>
+  </el-card>
+</template>
+
+<script>
+import {
+  listProductCodeList,
+  getProductCodeList,
+  delProductCodeList,
+  addProductCodeList,
+  finishedProductList,
+  getOptionLsit,
+  getLineOptionLsit,
+  productCodeList,
+  getPrintData,
+  updateProductCodeList,
+  getQrCode,
+  AutoPrinting,
+  getPrintDataNew,
+} from "@/api/codeListManage/productCodeList";
+import codeListPrint from "@/utils/print/codeListPrint";
+import { getServerPrintData } from "@/utils/print/printUtils";
+import { v4 as uuidv4 } from "uuid";
+
+export default {
+  name: "ProductCodeList",
+  dicts: [
+    "packaging_type",
+    "port",
+    "coding_list_format",
+    "direction_of_twist",
+    "automatic_printing",
+  ],
+  data() {
+    return {
+      qrCode: "", //码单号
+      isStartReadNum: false, //是否开始读取重量
+      printAuto: true, //是否自动打印
+      timer: null, //定时器
+      nowWeight: 0,
+      websocket: null,
+      // 自定义数据 start
+      printTableData: [], //需要打印的数据
+      chooseState: false, //批箱单打印状态
+      excuteType: false, //1:新增   2:编辑   3:补码
+      lineOptions: [], //机台选项数据
+      orderData: {
+        boxNo: "",
+        msg: "不定重",
+      },
+      tempStr: "箱",
+      printShow: false,
+      uuCode: "",
+      tableData: [
+        // {
+        //   machineTool: "", //机台号
+        //   qrCode: "", //箱号-码单号
+        //   boxWeight: "", //箱重-车重
+        //   canisterWeight: "", //筒重
+        //   canisterNum: "", //筒数
+        //   grossWeight: "", //毛重
+        //   suttle: "", //净重
+        //   workShifts: "", //班次
+        //   tubeColor: "", //管色
+        // },
+      ],
+      // 统计相关数据
+      count: {
+        sumBoxNum: 0, //合计箱数
+        sumCanisterNum: 0, //合计筒数
+        sumSuttle: 0, //合计净重
+        sumGrossWeight: 0, //合计毛重
+      },
+
+      form: {
+        // 表单参数
+        packaging: "", //包装
+        machineTool: "", //机台
+        workShifts: "", //班次
+        productionDate: "", //生产日期
+        levels: "", //等级
+        foreignTradeNumber: "", //外贸号
+        canisterWeight: "", //筒重
+        boxWeight: "", //箱重-车重
+        canisterNum: "", //筒数
+        tubeColor: "", //管色
+        comPort: "", //端口
+        printFormat: "", //格式
+        grossWeight: 0, //毛重
+        remark: "", //备注
+      },
+      rules: {
+        grossWeight: [
+          { required: true, message: "请输入重量", trigger: "change" },
+        ],
+        packaging: [
+          { required: true, message: "请选择包装", trigger: "change" },
+        ],
+        machineTool: [
+          { required: true, message: "请选择机台", trigger: "change" },
+        ],
+        workShifts: [
+          { required: true, message: "请选择班次", trigger: "change" },
+        ],
+        productionDate: [
+          { required: true, message: "请选择生产日期", trigger: "change" },
+        ],
+        levels: [{ required: true, message: "请选择等级", trigger: "change" }],
+        // foreignTradeNumber: [
+        //   { required: true, message: "请输入外贸号", trigger: "blur" },
+        // ],
+        canisterWeight: [
+          { required: true, message: "请选择筒重", trigger: "change" },
+        ],
+        boxWeight: [
+          { required: true, message: "请选择箱重/车重", trigger: "change" },
+        ],
+        tubeColor: [
+          { required: true, message: "请选择管色", trigger: "change" },
+        ],
+        comPort: [{ required: true, message: "请选择端口", trigger: "change" }],
+        printFormat: [
+          { required: true, message: "请选择格式", trigger: "change" },
+        ],
+      },
+      dropDownData: {},
+      batchNum: "", //批号--查询
+      batchData: [], //所有批号数据
+      batchTableData: [], //批号表格数据
+      currentRow: {},
+      columns: [
+        {
+          id: "productName",
+          label: "品名",
+        },
+        {
+          id: "productSpecifications",
+          label: "规格",
+        },
+        {
+          id: "lotNum",
+          label: "批号",
+        },
+        {
+          id: "productColor",
+          label: "色泽",
+        },
+        // {
+        //   id: "productName",
+        //   label: "订单号",
+        // },
+      ],
+      // 自定义数据 end
+
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 产品码单表格数据
+      productCodeListList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        qrCode: null,
+        lotNum: null,
+        productId: null,
+        levels: null,
+        canisterNum: null,
+        boxNum: null,
+        suttle: null,
+      },
+      waiting: 0, // 等待次数 不论时间
+      lastWeight: 0, // 上次得到的重量
+    };
+  },
+  created() {
+    this.getList();
+  },
+  watch: {
+    tableData: {
+      handler(nval) {
+        this.count = {
+          sumBoxNum: 0, //合计箱数
+          sumCanisterNum: 0, //合计筒数
+          sumSuttle: 0, //合计净重
+          sumGrossWeight: 0, //合计毛重
+        };
+        this.count.sumBoxNum = nval.length;
+        for (let i = 0; i < nval.length; i++) {
+          let item = nval[i];
+          if (item.canisterNum) {
+            this.count.sumCanisterNum += Number(item.canisterNum);
+          }
+          if (item.suttle) {
+            this.count.sumSuttle += Number(item.suttle);
+          }
+          if (item.grossWeight) {
+            this.count.sumGrossWeight += Number(item.grossWeight);
+          }
+        }
+        this.count.sumGrossWeight = this.count.sumGrossWeight.toFixed(2);
+        this.count.sumSuttle = this.count.sumSuttle.toFixed(2);
+        this.count.sumCanisterNum = this.count.sumCanisterNum.toFixed(2);
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
+  mounted() {
+    // console.log(this.dict.type.packaging_type);
+    console.log("mounted");
+    let { excuteType, qrCode } = this.$route.query;
+    if (excuteType == 2) {
+      //修改
+      this.handleUpdate(qrCode);
+    } else if (excuteType == 3) {
+      //补码
+      this.supplementCode(qrCode);
+    } else {
+      // 正常打印
+      this.printHandler();
+    }
+  },
+  beforeDestroy() {
+    this.closeWebSocket();
+  },
+  computed: {
+    isDisabled() {
+      return this.excuteType != 1;
+    },
+  },
+
+  methods: {
+    // 打印按钮回调
+    async printBtnHandler() {
+      let res = await this.validateAndPrint();
+      if (!res) {
+        // this.$message.error("请完善数据");
+      }
+    },
+    async readStateChange() {
+      if (this.isStartReadNum) {
+        //正在读
+        this.closeWebSocket();
+        this.isStartReadNum = false;
+        this.$message.success("已关闭读数");
+      } else {
+        // 开启读数时 先获取码单号
+        let res = await getQrCode();
+        if (res.code == 200) {
+          this.qrCode = res.msg;
+        } else {
+          this.$message.error(res.msg);
+        }
+        this.initWebSocket();
+      }
+    },
+    initWebSocket() {
+      // console.log("开始连接ws", process.env.VUE_APP_BASE_WS_API);
+      let automatis_printing = this.dict.type.automatic_printing;
+      let frequency = automatis_printing.find(
+        // 等到稳定次数
+        (item) => item.label == "frequency"
+      )?.value;
+      if (frequency == undefined) {
+        frequency = 30;
+      }
+      let minimumWeight = automatis_printing.find(
+        // 打印最小值
+        (item) => item.label == "minimumWeight"
+      )?.value;
+      if (minimumWeight == undefined) {
+        minimumWeight = 5;
+      }
+      let antishake = automatis_printing.find(
+        // 防抖
+        (item) => item.label == "antishake"
+      )?.value;
+      if (antishake == undefined) {
+        antishake = 3;
+      }
+      const wsUrl = "ws:" + process.env.VUE_APP_BASE_WS_API + "/currentWeight";
+      this.websocket = new WebSocket(wsUrl);
+      this.websocket.addEventListener("open", (event) => {
+        console.log("建立WebSocket连接");
+        this.isStartReadNum = true;
+        this.$message.success("已开启读数");
+      });
+      let initialWeight = null; // 初始化基准重量
+      const weightChangeThreshold = antishake; // 定义重量变化阈值x
+      let shouldPrint = false; // 用于控制是否应该打印
+      this.websocket.addEventListener("message", async (event) => {
+        console.log(event);
+        if (!this.printAuto) return;
+        const weightData = JSON.parse(event.data);
+        const weight = weightData.weight;
+        this.nowWeight = weight;
+        this.form.grossWeight = weight;
+        if (weight === 0.0 || weight === 0) {
+          this.resetWeightStatus();
+          shouldPrint = false; // 重量为0时,重置打印标志
+          return;
+        }
+
+        if (weight <= minimumWeight) {
+          this.resetWeightStatus();
+          shouldPrint = false; // 重量未满足打印条件,重置打印标志
+          return;
+        }
+
+        if (initialWeight === null) {
+          initialWeight = weight;
+          shouldPrint = true; // 第一次有效重量,允许打印
+          return;
+        }
+        const weightDifference = Math.abs(weight - initialWeight);
+        if (weightDifference > weightChangeThreshold) {
+          initialWeight = weight;
+          this.waiting = 0; // 重量有显著变化,重置等待计数并允许打印
+          shouldPrint = true;
+        } else {
+          this.waiting++;
+          if (this.waiting == frequency && shouldPrint) {
+            // 只有在应该打印且等待计数达标时才打印
+            this.waiting = 0;
+            shouldPrint = false; // 打印后禁止下一次打印,直到重量再次变化
+            const isValidate = await this.validateAndPrint(weight);
+          }
+        }
+      });
+
+      this.websocket.addEventListener("on", (e) => {
+        console.log(e, "连接已建立");
+      });
+      this.websocket.addEventListener("error", (event) => {
+        console.error("WebSocket错误:", event);
+        this.$message.error("WebSocket错误,请重试");
+      });
+
+      this.websocket.addEventListener("close", (event) => {
+        console.log("关闭WebSocket连接");
+      });
+    },
+    // 用于重置与重量相关的状态
+    resetWeightStatus() {
+      this.waiting = 0;
+      this.lastWeight = 0;
+    },
+    // 整合验证和打印标签的逻辑
+    async validateAndPrint(weight) {
+      let isValidate = await this.addIsValidate();
+      if (isValidate) {
+        this.setWeight(weight);
+      } else {
+        // this.$message.warning("请完善表单数据");
+      }
+      return isValidate;
+    },
+    // 表单重量改变回调
+    changeGrossWeightForm(val) {
+      // console.log(val);
+      this.nowWeight = val;
+    },
+    // 开始设置新的重量
+    async setWeight(weight) {
+      console.log("设置新的重量", weight);
+      let newData = {};
+      let {
+        machineTool,
+        packaging,
+        boxWeight,
+        canisterWeight,
+        canisterNum,
+        grossWeight,
+        suttle, //净重
+        workShifts, //班次
+        tubeColor,
+        productionDate,
+        printFormat,
+        levels,
+        remark,
+      } = this.form;
+      console.log(this.currentRow);
+      let {
+        productName,
+        productSpecifications,
+        productColor,
+        lotNum,
+        directionOfTwist,
+        productId,
+      } = this.currentRow;
+      let directionOfTwistLabel = this.dict.type.direction_of_twist.find(
+        (item) => item.value == directionOfTwist
+      )?.label;
+
+      newData = {
+        // qrCode: this.getBoxOrderNum(), //箱单号
+        packaging, //包装方式 1:车丝 2:小包装  3:大包装
+        qrCode: this.qrCode, //箱单号
+        levels,
+        machineTool,
+        boxWeight,
+        canisterWeight,
+        canisterNum,
+        workShifts,
+        tubeColor,
+        grossWeight: this.printAuto ? this.nowWeight : grossWeight, //毛重
+        // suttle: this.getSuttle(), //净重
+        suttle: 0, //净重
+        boxNum: this.tableData.length + 1, //序号
+        productionDate, //日期
+        printFormat, //格式
+        productName,
+        productSpecifications,
+        productColor,
+        lotNum,
+        directionOfTwist, //捻向
+        directionOfTwistLabel, //捻向label
+        remark,
+        productId,
+      };
+      this.getOrderData(newData);
+    },
+    // 校验是否可以新增
+    addIsValidate() {
+      return new Promise((resolve, reject) => {
+        if (!this.currentRow.lotNum || this.isDisabled) {
+          this.$message.warning("请选择产品");
+          resolve(false);
+        }
+        this.$refs.form.validate(
+          (valid) => {
+            if (valid) {
+              resolve(true);
+            } else {
+              this.$message.warning("请完善表单数据");
+              resolve(false);
+            }
+          },
+          (error) => {
+            console.log(error);
+            this.$message.warning("请完善表单数据");
+            resolve(false);
+          }
+        );
+      });
+    },
+    // 新的后端打印逻辑
+    async newPrintHandler() {
+      console.log("newPrintHandler");
+      let printRow = this.printTableData[0];
+      let payload = {
+        qrCodeVal: "",
+        mapList: [],
+        remark: "无",
+        printType: "",
+      };
+      let {
+        id, //id
+        qrCode, //序号
+        canisterNum, //筒数
+        grossWeight, //毛重
+        suttle, //净重
+        remark, //备注
+        printFormat,
+      } = printRow;
+      let uuid = uuidv4();
+      let temp =
+        id +
+        "@" +
+        uuid +
+        "@" +
+        canisterNum +
+        "@" +
+        suttle +
+        "@" +
+        grossWeight +
+        "@" +
+        qrCode;
+      // payload.qrCodeVal = encodeURIComponent(temp);
+      payload.qrCodeVal = temp;
+      console.log("二维码数据", temp);
+      payload.remark = remark || "暂无";
+      payload.mapList = getServerPrintData(printRow);
+      payload.printType = printFormat == 3 ? "export" : "normal";
+      try {
+        let res = await AutoPrinting(payload);
+        console.log(res);
+        if (res.code == 200 && res.status == "success") {
+          this.$message.success(res.msg);
+          if (this.excuteType == 1) {
+            this.tableData.push(printRow);
+          }
+        } else {
+          this.$message.error(res.msg);
+        }
+      } catch (error) {
+        console.log(error);
+        this.$message.error(error);
+      }
+    },
+
+    closeWebSocket() {
+      if (
+        this.websocket !== null &&
+        this.websocket.readyState !== WebSocket.CLOSED
+      ) {
+        this.websocket.close();
+      }
+    },
+    // 毛重改变回调
+    changeGrossWeight(row) {
+      console.log(row);
+      let { boxWeight, grossWeight, canisterWeight, canisterNum } = row;
+      if (!Number(grossWeight)) {
+        row.suttle = 0;
+        return;
+      }
+      console.log(
+        Number(grossWeight),
+        Number(boxWeight),
+        Number(canisterWeight) * Number(canisterNum)
+      );
+      row.suttle = (
+        Number(grossWeight) -
+        Number(boxWeight) -
+        Number(canisterWeight) * Number(canisterNum)
+      ).toFixed(2);
+      console.log(row);
+    },
+    // 删除表格一条数据回调
+    handleDeleteOne(index) {
+      this.tableData.splice(index, 1);
+    },
+    // 确认保存修改一条数据
+    async handleSaveOne(row) {
+      try {
+        let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+          this.count;
+        let rowData = JSON.parse(JSON.stringify(row));
+        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);
+      }
+    },
+    // 确认打印回调
+    printConfirmHandler(printData) {
+      // if (this.tableData.length == 0) {
+      //   this.$message.warning("请添加打印的数据");
+      //   return;
+      // }
+
+      console.log("打印", this.printTableData);
+      this.printTableData.forEach((item) => {
+        item.qrCodeData = printData + "-" + item.boxNum;
+      });
+      this.changeGrossWeight(this.printTableData[0]);
+      // 前端打印
+      // codeListPrint(this.printTableData, "printDom");
+
+      // if (this.excuteType == 1) {
+      //   this.tableData.push(this.printTableData[0]);
+      // }
+      // 后端打印
+      // console.log("newPrintHandler");
+      this.newPrintHandler();
+    },
+    // 获取机台选项数据
+    async getLineOptionLsit() {
+      let payLoad = {
+        isEnablePaging: false,
+      };
+      try {
+        let res = await getLineOptionLsit(payLoad);
+        if (res.code == 200) {
+          this.lineOptions = res.rows;
+          console.log(this.lineOptions);
+        } else {
+          console.log(res);
+        }
+      } catch (error) {
+        console.error(error);
+      }
+    },
+    // 补码打印回调
+    handleSuppleOne(row) {
+      this.printTableData = [row];
+      this.printConfirmHandler(row.id);
+    },
+    // 获取箱单数据
+    async getOrderData(newData) {
+      this.$refs.form.validate(async (valid) => {
+        if (valid) {
+          try {
+            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+              this.count;
+            let rowData = newData.machineTool
+              ? JSON.parse(JSON.stringify(newData))
+              : this.tableData[0];
+            console.log(rowData);
+            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,
+              productColour: rowData.productColor,
+            };
+            if (rowData.id) {
+              payLoad.id = rowData.id;
+            }
+            let tempApiFun = productCodeList;
+            if (this.excuteType == 3 || this.excuteType == 2) {
+              //补码||修改
+              this.printConfirmHandler(this.tableData[0].id);
+              return;
+            }
+            this.changeGrossWeight(payLoad);
+            let res = await tempApiFun(payLoad);
+            let msg = this.isEdit ? "编辑" : "新增";
+            if (res.code == 200) {
+              // if (this.excuteType != 1) {
+              //   this.printShow = false;
+              //   this.getList();
+              //   return;
+              // }
+              // this.tableData[0].id = res.data;
+              this.printTableData[0].id = res.data;
+              console.log("printConfirmHandler");
+              this.printConfirmHandler(res.data);
+            } else {
+              console.log(res);
+              this.$message.error(`${msg}箱单失败`);
+            }
+          } catch (error) {
+            console.error(error);
+          }
+        }
+      });
+    },
+    // 保存修改箱单数据
+    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; //开启选择状态
+      if (this.chooseState) {
+        this.$message.info("请选择打印的箱单");
+      } else {
+        this.$message.info("退出批箱单状态");
+      }
+    },
+    supplementCodeHandler() {
+      console.log(this.form.id);
+      this.printConfirmHandler(this.form.id);
+    },
+    // 箱单号生成函数
+    getBoxOrderNum() {
+      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);
+      return year + month + day + timeStamp;
+    },
+    // 包装变化回调
+    packagingChange(val) {
+      if (val == "1") {
+        //车丝
+        this.tempStr = "车";
+      } else {
+        this.tempStr = "箱";
+      }
+    },
+    // 添加按钮回调
+    addProductHandler() {
+      this.$refs.form.validate(async (valid) => {
+        if (valid) {
+          let {
+            machineTool,
+            packaging,
+            boxWeight,
+            canisterWeight,
+            canisterNum,
+            grossWeight,
+            suttle, //净重
+            workShifts, //班次
+            tubeColor,
+            productionDate,
+            printFormat,
+            levels,
+            remark,
+          } = this.form;
+          console.log(this.currentRow);
+          let {
+            productName,
+            productSpecifications,
+            productColor,
+            lotNum,
+            directionOfTwist,
+            productId,
+          } = this.currentRow;
+          let directionOfTwistLabel = this.dict.type.direction_of_twist.find(
+            (item) => item.value == directionOfTwist
+          )?.label;
+          let res = await getQrCode();
+          let qrCode = "";
+          if (res.code == 200) {
+            qrCode = res.msg;
+          } else {
+            this.$message.error(res.msg);
+          }
+          this.tableData.push({
+            // qrCode: this.getBoxOrderNum(), //箱单号
+            packaging, //包装方式 1:车丝 2:小包装  3:大包装
+            qrCode, //箱单号
+            levels,
+            machineTool,
+            boxWeight,
+            canisterWeight,
+            canisterNum,
+            workShifts,
+            tubeColor,
+            grossWeight: this.printAuto ? this.nowWeight : grossWeight, //毛重
+            // suttle: this.getSuttle(), //净重
+            suttle: 0, //净重
+            boxNum: this.tableData.length + 1, //序号
+            productionDate, //日期
+            printFormat, //格式
+            productName,
+            productSpecifications,
+            productColor,
+            lotNum,
+            directionOfTwist, //捻向
+            directionOfTwistLabel, //捻向label
+            remark,
+            productId,
+          });
+        } else {
+          console.log("error submit!!");
+          return false;
+        }
+      });
+    },
+    // 计算净重
+    getSuttle() {
+      let { boxWeight, canisterWeight, canisterNum } = this.form;
+      return (Number(boxWeight) - canisterWeight * canisterNum).toFixed(2);
+    },
+    // 表格点击回调
+    async handleCurrentChange(val) {
+      console.log("row", val);
+      if (!val) return;
+      if (this.isStartReadNum) {
+        this.$refs.proTableRef.setCurrentRow(this.currentRow);
+        return;
+      }
+      if (val.id != this.currentRow.id) {
+        this.tableData = [];
+        // this.$refs.form.resetFields();
+        this.nowWeight = 0;
+        if (!this.printAuto) {
+          // 手动打印  获取码单号
+          this.getQrCodeHandle();
+        }
+      }
+      this.currentRow = val;
+    },
+    // 获取码单号
+    async getQrCodeHandle() {
+      let res = await getQrCode();
+      if (res.code == 200) {
+        this.qrCode = res.msg;
+      } else {
+        this.$message.error(res.msg);
+      }
+    },
+    // 选择打印数据回调
+    handlePrintOneChange(row) {
+      console.log(row);
+      if (!this.chooseState) return;
+      this.$alert("是否确定打印该数据", "确认打印", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        callback: (action) => {
+          if (action === "confirm") {
+            this.$refs.form.validate(async (valid) => {
+              if (valid) {
+                try {
+                  let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+                    this.count;
+                  let rowData = JSON.parse(JSON.stringify(row));
+                  this.printTableData = [rowData];
+                  let payLoad = {
+                    ...this.form,
+                    qrCode: rowData.qrCode,
+                    lotNum: rowData.lotNum,
+                    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 = productCodeList;
+                  if (this.excuteType == 1) {
+                    tempApiFun = productCodeList;
+                  } else if (this.excuteType == 2) {
+                    tempApiFun = updateProductCodeList;
+                  }
+                  this.changeGrossWeight(payLoad);
+                  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;
+                    }
+                    row.id = res.data;
+                    this.printConfirmHandler(res.data);
+                  } else {
+                    console.log(res);
+                    this.$message.error(`${msg}箱单失败`);
+                  }
+                } catch (error) {
+                  console.error(error);
+                }
+              }
+            });
+          }
+        },
+      });
+    },
+    // 获取所有批次数据
+    async getAllBatchData() {
+      try {
+        let res = await finishedProductList();
+        if (res.code == 200) {
+          this.batchData = res.data;
+          this.batchTableData = res.data;
+        } else {
+          console.log(res);
+        }
+      } catch (error) {
+        console.error(res);
+      }
+    },
+    // 批号查询接口
+    batchNumChange() {
+      if (!this.batchNum) {
+        this.batchTableData = this.batchData;
+        return;
+      }
+      this.batchTableData = this.batchData.filter(
+        (item) => item.lotNum && item.lotNum.includes(this.batchNum)
+      );
+    },
+    // 获取下拉数据
+    async getSelectOptions() {
+      try {
+        let res = await getOptionLsit();
+        if (res.code == 200) {
+          this.dropDownData = res.data;
+        }
+      } catch (error) {}
+    },
+    /** 查询产品码单列表 */
+    getList() {
+      this.loading = true;
+      listProductCodeList(this.queryParams).then((response) => {
+        this.productCodeListList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.nowWeight = 0;
+      this.form = {
+        id: null,
+        qrCode: null,
+        lotNum: null,
+        productId: null,
+        levels: null,
+        canisterNum: null,
+        boxNum: null,
+        suttle: null,
+        productionDate: null,
+        machineTool: null,
+        grossWeight: null,
+        packaging: null,
+        workShifts: null,
+        foreignTradeNumber: null,
+        canisterWeight: null,
+        boxWeight: null,
+        tubeColor: null,
+        comPort: null,
+        printFormat: null,
+        packagingType: null,
+        storageLocation: null,
+        warehouseregionId: null,
+        remark: null,
+        delFlag: null,
+        createBy: null,
+        createById: null,
+        createTime: null,
+        updateBy: null,
+        updateById: null,
+        updateTime: null,
+      };
+      this.tableData = [];
+      this.currentRow = {};
+      this.batchNum = "";
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map((item) => item.qrCode);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加产品码单";
+    },
+    // 打印按钮操作
+    async printHandler() {
+      this.excuteType = 1;
+      this.reset();
+
+      await this.getAllBatchData(); //获取所有产品数据
+      await this.getLineOptionLsit(); //获取机台选项数据
+      await this.getSelectOptions();
+      this.printShow = true;
+    },
+    /** 修改按钮操作 */
+    handleUpdate(qrCode) {
+      console.log(qrCode);
+      this.reset();
+      const id = qrCode;
+      getPrintDataNew(id).then(async (response) => {
+        if (response.code == 200) {
+          this.excuteType = 2;
+          this.form = response.data[0];
+          this.tableData = response.data;
+
+          await this.getAllBatchData(); //获取所有产品数据
+          await this.getLineOptionLsit(); //获取机台选项数据
+          await this.getSelectOptions();
+          this.initProductData();
+          this.printShow = true;
+        } else {
+          console.log(response);
+        }
+      });
+    },
+    // 补码回调
+    supplementCode(qrCode) {
+      this.reset();
+      // const id = row.qrCode;
+      const id = qrCode;
+      getPrintDataNew(id).then(async (response) => {
+        this.excuteType = 3; //补码
+        this.printAuto = false;
+        this.form = response.data[0];
+        this.tableData = response.data;
+        await this.getAllBatchData(); //获取所有产品数据
+        await this.getLineOptionLsit(); //获取机台选项数据
+        await this.getSelectOptions();
+        this.initProductData();
+        this.printShow = true;
+      });
+    },
+
+    // 初始化产品相关数据
+    initProductData() {
+      this.batchNum = this.form.lotNum;
+      this.batchNumChange();
+      console.log(this.batchTableData);
+      if (this.batchTableData.length) {
+        let {
+          machineTool,
+          boxWeight,
+          canisterWeight,
+          canisterNum,
+          grossWeight,
+          suttle, //净重
+          workShifts, //班次
+          tubeColor,
+          productionDate,
+          printFormat,
+          levels,
+          remark,
+        } = this.form;
+        let {
+          productName,
+          productSpecifications,
+          productColor,
+          lotNum,
+          directionOfTwist,
+          productId,
+        } = this.batchTableData[0];
+        let directionOfTwistLabel = this.dict.type.direction_of_twist.find(
+          (item) => item.value == directionOfTwist
+        )?.label;
+        this.tableData.forEach((item) => {
+          Object.assign(item, {
+            productName, //品种
+            productSpecifications, //规格
+            productColor, //色号
+            directionOfTwist, //捻向
+            directionOfTwistLabel,
+          });
+        });
+      }
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          if (this.form.id != null) {
+            updateProductCodeList(this.form).then((response) => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addProductCodeList(this.form).then((response) => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.qrCode || this.ids;
+      this.$modal
+        .confirm('是否确认删除产品码单编号为"' + ids + '"的数据项?')
+        .then(function () {
+          return delProductCodeList(ids);
+        })
+        .then(() => {
+          this.getList();
+          this.$modal.msgSuccess("删除成功");
+        })
+        .catch(() => {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.download(
+        "system/productCodeList/export",
+        {
+          ...this.queryParams,
+        },
+        `productCodeList_${new Date().getTime()}.xlsx`
+      );
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.main-wrap {
+  width: 100%;
+  display: flex;
+  justify-content: space-between;
+
+  .left {
+    width: 58%;
+
+    .top-area {
+      display: flex;
+      justify-content: space-between;
+
+      .msg {
+        display: flex;
+        align-items: center;
+        font-size: 16px;
+        font-weight: 700;
+      }
+
+      .btn-list {
+        width: 100%;
+        display: flex;
+        justify-content: space-between;
+      }
+    }
+
+    .count-area {
+      display: flex;
+      flex-wrap: wrap;
+
+      .count-item {
+        display: flex;
+        margin-bottom: 10px;
+        width: 50%;
+      }
+    }
+  }
+
+  .right {
+    width: 40%;
+    // flex: 1;
+    .queryForm {
+      width: 100%;
+      padding: 0 10px;
+      display: flex;
+
+      .label {
+        text-align: right;
+        color: #606266;
+        line-height: 30px;
+        display: block;
+        width: 100px;
+        font-weight: 700;
+        text-decoration: aliceblue;
+        margin-right: 10px;
+      }
+    }
+
+    .table-wrap {
+      margin-top: 5px;
+      width: 100%;
+      overflow-x: scroll;
+    }
+  }
+}
+
+::v-deep .el-date-editor.el-input {
+  width: 100%;
+}
+
+::v-deep .el-input-number--mini {
+  width: 99%;
+}
+
+::v-deep .el-table .current-row {
+  background-color: #55e905 !important;
+}
+::v-deep .el-table__body tr.current-row > td.el-table__cell {
+  background-color: #55e905 !important;
+}
+</style>