Переглянути джерело

fix:包装打印焦点自动获取,三秒后内容自动清空

lucky 1 місяць тому
батько
коміт
d8a950b16e

+ 1 - 0
zkqy-framework/src/main/java/com/zkqy/framework/config/SecurityConfig.java

@@ -144,6 +144,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
      */
     @Override
     protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+
         auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
     }
 }

+ 44 - 0
zkqy-ui/src/api/amichi/reportingProcessBinding/reportingProcessBinding.js

@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 查询工序绑定半成品汇报信息列表
+export function listReportingProcessBinding(query) {
+  return request({
+    url: '/amichi/reportingProcessBinding/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询工序绑定半成品汇报信息详细
+export function getReportingProcessBinding(id) {
+  return request({
+    url: '/amichi/reportingProcessBinding/' + id,
+    method: 'get'
+  })
+}
+
+// 新增工序绑定半成品汇报信息
+export function addReportingProcessBinding(data) {
+  return request({
+    url: '/amichi/reportingProcessBinding',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改工序绑定半成品汇报信息
+export function updateReportingProcessBinding(data) {
+  return request({
+    url: '/amichi/reportingProcessBinding',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除工序绑定半成品汇报信息
+export function delReportingProcessBinding(id) {
+  return request({
+    url: '/amichi/reportingProcessBinding/' + id,
+    method: 'delete'
+  })
+}

+ 0 - 7
zkqy-ui/src/router/index.js

@@ -101,13 +101,6 @@ export const constantRoutes = [
     },
     hidden: true
   },
-  {
-    path: '/procedureList/erplist/index',
-    component: () => {
-      return import('@/views/amichi/procedureList/erplist/index.vue')
-    },
-    hidden: true
-  },
   {
     path: '/amichi/dialogCompments/customizedVersion/processDisplay',
     component: () => {

+ 339 - 0
zkqy-ui/src/views/amichi/procedureList/erplist/index2.vue

@@ -0,0 +1,339 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
+      <el-form-item label="半成品名称" prop="productName">
+        <el-input
+          v-model="queryParams.productName"
+          placeholder="请输入半成品名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="工序名称" prop="processName">
+        <el-input
+          v-model="queryParams.processName"
+          placeholder="请输入工序名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="0 启用 1禁用" prop="isEnabled">
+        <el-select v-model="queryParams.isEnabled" placeholder="请选择">
+          <el-option
+            v-for="item in options"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value">
+          </el-option>
+        </el-select>
+      </el-form-item>
+
+      <el-form-item>
+        <el-button type="primary" 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-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['amichi:reportingProcessBinding:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['amichi:reportingProcessBinding:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['amichi:reportingProcessBinding:remove']"
+        >删除</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['amichi:reportingProcessBinding:export']"
+        >导出</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-back"
+          size="mini"
+          @click="fhsy"
+        >返回上一页</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" style="margin-top: 20px":data="reportingProcessBindingList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <!--<el-table-column label="主键自增" align="center" prop="id" />-->
+      <el-table-column label="半成品名称" align="center" prop="productName" />
+      <el-table-column label="工序名称" align="center" prop="processName" />
+      <!--<el-table-column label="创建者id" align="center" prop="createById" />-->
+      <!--<el-table-column label="修改者id" align="center" prop="updateById" />-->
+      <el-table-column label="备注信息" align="center" prop="remark" />
+      <el-table-column label="状态111" align="center" prop="isEnabled" >
+        <template  v-slot="scope">
+          <dict-tag  :options="dict.type.bcpbdzt" :value="scope.row.isEnabled"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-dropdown @command="(command)=>{handleCommand(command, scope.row)}">
+            <el-button type="warning">
+              操作<i class="el-icon-arrow-down el-icon--right"></i>
+            </el-button>
+            <el-dropdown-menu slot="dropdown">
+              <el-dropdown-item  icon="el-icon-edit"  command="handleUpdate">修改</el-dropdown-item>
+              <el-dropdown-item  icon="el-icon-delete" command="handleDelete">删除</el-dropdown-item>
+            </el-dropdown-menu>
+          </el-dropdown>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <!-- 添加或修改工序绑定半成品汇报信息对话框 -->
+    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="半成品名称" prop="productName">
+          <el-input v-model="form.productName" placeholder="请输入半成品名称" />
+        </el-form-item>
+        <el-form-item label="0 启用 1禁用" prop="isEnabled">
+          <el-select v-model="form.isEnabled" placeholder="请选择">
+            <el-option
+              v-for="item in options"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value">
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="备注信息" prop="remark">
+          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listReportingProcessBinding, getReportingProcessBinding, delReportingProcessBinding, addReportingProcessBinding, updateReportingProcessBinding } from "@/api/amichi/reportingProcessBinding/reportingProcessBinding.js";
+
+export default {
+  name: "ReportingProcessBinding",
+  dicts: ["bcpbdzt"],
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      options: [{
+        value: '0',
+        label: '启用'
+      }, {
+        value: '1',
+        label: '禁用'
+      }],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 工序绑定半成品汇报信息表格数据
+      reportingProcessBindingList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        productName: null,
+        processId: null,
+        isEnabled: null,
+        createById: null,
+        updateById: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        productName: [
+          { required: true, message: "半成品名称不能为空", trigger: "blur" }
+        ],
+        processId: [
+          { required: true, message: "工序id不能为空", trigger: "blur" }
+        ],
+      }
+    };
+  },
+  created() {
+    this.form.processId=this.$route.query.id;
+    console.log(this.form)
+    this.queryParams.processId =this.$route.query.id;
+    this.getList();
+  },
+  methods: {
+    //下拉菜单点击事件
+    handleCommand(command, row) {
+      switch (command) {
+        case "handleUpdate":
+          this.handleUpdate(row)
+          break;
+        case "handleDelete":
+          this.handleDelete(row)
+          break;
+        default:
+          break;
+      }
+    },
+    fhsy(){
+      console.log("ddddde")
+      this.$router.back();
+    },
+    /** 查询工序绑定半成品汇报信息列表 */
+    getList() {
+      this.loading = true;
+      listReportingProcessBinding(this.queryParams).then(response => {
+        this.reportingProcessBindingList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        productName: null,
+        processId: null,
+        isEnabled: null,
+        createById: null,
+        createBy: null,
+        createTime: null,
+        updateById: null,
+        updateBy: null,
+        updateTime: null,
+        remark: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.form.processId=this.$route.query.id;
+      this.open = true;
+      this.title = "新增";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const id = row.id || this.ids
+      getReportingProcessBinding(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改";
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.form.id != null) {
+            updateReportingProcessBinding(this.form).then(response => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addReportingProcessBinding(this.form).then(response => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$modal.confirm('是否确认删除工序绑定半成品汇报信息编号为"' + ids + '"的数据项?').then(function() {
+        return delReportingProcessBinding(ids);
+      }).then(() => {
+        this.getList();
+        this.$modal.msgSuccess("删除成功");
+      }).catch(() => {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      this.download('amichi/reportingProcessBinding/export', {
+        ...this.queryParams
+      }, `reportingProcessBinding_${new Date().getTime()}.xlsx`)
+    }
+  }
+};
+</script>

+ 16 - 0
zkqy-ui/src/views/amichi/procedureList/list/index.vue

@@ -84,6 +84,7 @@
               <el-dropdown-item  icon="el-icon-edit"  command="handleUpdate">修改</el-dropdown-item>
               <el-dropdown-item  icon="el-icon-delete" command="handleDelete">删除</el-dropdown-item>
               <el-dropdown-item  icon="el-icon-edit" command="gxbd">ERP工序绑定</el-dropdown-item>
+              <el-dropdown-item  icon="el-icon-edit" command="gxhbbd">ERP工序汇报绑定</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown>
         </template>
@@ -207,10 +208,25 @@ export default {
         case "gxbd":
           this.gxbd(row)
           break;
+        case "gxhbbd":
+          this.gxhbbd(row)
+          break;
         default:
           break;
       }
     },
+    gxhbbd(row){
+      //
+      console.log("abc");
+      console.log("erp工序绑定")
+      //完整写法
+      this.$router.push({
+        path: '/amichi/basic/jcsj/procedureList/erplist/index2',
+        query: {
+          "id": row.id,
+        }
+      });
+    },
     gxbd(row){
       console.log("erp工序绑定")
       //完整写法

+ 28 - 12
zkqy-ui/src/views/amichi/qualityinspectioninformation/bp_inspection/QualityStatement.vue

@@ -107,8 +107,8 @@ export default {
     return {
       loading:false,
       tableData: [
-
       ],
+      intervalId: null, // 用于存储定时器的 ID
       isScrolling: false, // 控制是否滚动的开关
       scrollData: [], // 用于滚动的数据
       timer: null,
@@ -236,23 +236,25 @@ export default {
       this.masterInfo.manufacturingProcess="白胚检验";
       getQualityinspectioninformationOne(this.masterInfo).then(response => {
         this.masterInfo = response.data;
-      });
-
-      this.loading=true
-      listInspection({"fid":this.masterInfo.id,"isEnablePaging":"false"}).then(response => {
-        this.tableData = response.rows;
-        this.loading = false;
-        this.$nextTick(() => {
-          this.isScrolling=true;
-          this.displayRows=10;
-          this.handleScrollChange();
+        this.loading=true
+        listInspection({"fid":this.masterInfo.id,"isEnablePaging":"false"}).then(response => {
+          this.tableData = response.rows;
+          this.loading = false;
+          this.$nextTick(() => {
+            this.isScrolling=true;
+            this.displayRows=10;
+            this.handleScrollChange();
+          });
         });
       });
+
+
     }
   },
   created () {
     // 移除这里的初始化,改为在开关打开时初始化
     this.masterInfo.id =this.$route.query.id;
+    //如果点击id就取id
     if(this.masterInfo.id==null||this.masterInfo.id==""){
       console.log("为空");
       this.masterInfo.id=="0000"
@@ -260,10 +262,24 @@ export default {
     this.checkMasterInfo();
   },
   mounted () {
-    // 移除这里的自动开始滚动
+    // 在组件挂载时启动定时器
+    this.intervalId = setInterval(() => {
+      // 移除这里的初始化,改为在开关打开时初始化
+      this.masterInfo.id =this.$route.query.id;
+      //如果点击id就取id
+      if(this.masterInfo.id==null||this.masterInfo.id==""){
+        console.log("为空");
+        this.masterInfo.id=="0000"
+      }
+      this.checkMasterInfo();
+    }, 60 * 60 * 5000); // 每隔 1 小时(60 分钟)调用一次
   },
   beforeDestroy () {
     this.stopScroll()
+    // 在组件销毁前清除定时器,防止内存泄漏
+    if (this.intervalId) {
+      clearInterval(this.intervalId);
+    }
   }
 }
 </script>

+ 25 - 9
zkqy-ui/src/views/amichi/qualityinspectioninformation/bp_leavefactory/QualityStatement.vue

@@ -109,6 +109,7 @@ export default {
       tableData: [
 
       ],
+      intervalId:null,
       isScrolling: false, // 控制是否滚动的开关
       scrollData: [], // 用于滚动的数据
       timer: null,
@@ -235,17 +236,18 @@ export default {
       this.masterInfo.manufacturingProcess="出厂检验";
       getQualityinspectioninformationOne(this.masterInfo).then(response => {
         this.masterInfo = response.data;
-      });
-      this.loading=true
-      listBpleavefactory({"fid":this.masterInfo.id,"isEnablePaging":"false"}).then(response => {
-        this.tableData = response.rows;
-        this.loading = false;
-        this.$nextTick(() => {
-          this.isScrolling=true;
-          this.displayRows=10;
-          this.handleScrollChange();
+        this.loading=true
+        listBpleavefactory({"fid":this.masterInfo.id,"isEnablePaging":"false"}).then(response => {
+          this.tableData = response.rows;
+          this.loading = false;
+          this.$nextTick(() => {
+            this.isScrolling=true;
+            this.displayRows=10;
+            this.handleScrollChange();
+          });
         });
       });
+
     }
   },
   created () {
@@ -259,9 +261,23 @@ export default {
   },
   mounted () {
     // 移除这里的自动开始滚动
+    // 在组件挂载时启动定时器
+    this.intervalId = setInterval(() => {
+      // 移除这里的初始化,改为在开关打开时初始化
+      this.masterInfo.id =this.$route.query.id;
+      if(this.masterInfo.id==null||this.masterInfo.id==""){
+        console.log("为空");
+        this.masterInfo.id=="0000"
+      }
+      this.checkMasterInfo();
+    }, 60 * 60 * 1000); // 每隔 1 小时(60 分钟)调用一次
   },
   beforeDestroy () {
     this.stopScroll()
+    // 在组件销毁前清除定时器,防止内存泄漏
+    if (this.intervalId) {
+      clearInterval(this.intervalId);
+    }
   }
 }
 </script>

+ 29 - 15
zkqy-ui/src/views/amichi/qualityinspectioninformation/jl_inspection/QualityStatement.vue

@@ -7,7 +7,7 @@
         <img src="@/assets/qy/image.png" alt="公司logo">
       </div>
       <div class="company-title">铨一电源科技有限公司</div>
-      <h2 class="report-title">进 料 质 量 月 报 表</h2>
+      <h2 class="report-title">进 料1 质 量 月 报 表</h2>
       <div class="report-info">
         <span style="font-size: 18px">{{ masterInfo.reportDate }} </span>
       </div>
@@ -108,6 +108,7 @@ export default {
       tableData: [
 
       ],
+      intervalId:null,
       isScrolling: true, // 控制是否滚动的开关
       scrollData: [], // 用于滚动的数据
       timer: null,
@@ -227,23 +228,21 @@ export default {
     checkMasterInfo () {
       this.masterInfo.isEnablePaging=false;
       this.masterInfo.manufacturingProcess="来料检验";
-      // getQualityinspectioninformation(this.masterInfo).then(response => {
-      //   this.masterInfo = response.data;
-      // });
+
       getQualityinspectioninformationOne(this.masterInfo).then(response => {
         this.masterInfo = response.data;
-      });
-      this.loading=true
-      listInspection({"fid":this.masterInfo.id,"isEnablePaging":"false"}).then(response => {
-        this.tableData = response.rows;
-        this.loading = false;
-        this.$nextTick(() => {
-          this.isScrolling=true;
-          this.displayRows=10;
-          this.handleScrollChange();
+        this.loading=true
+        listInspection({"fid":this.masterInfo.id,"isEnablePaging":"false"}).then(response => {
+          this.tableData = response.rows;
+          this.loading = false;
+          this.$nextTick(() => {
+            this.isScrolling=true;
+            this.displayRows=10;
+            this.handleScrollChange();
+          });
         });
-
       });
+
     }
   },
   created () {
@@ -256,10 +255,25 @@ export default {
      this.checkMasterInfo();
   },
   mounted () {
-    // 移除这里的自动开始滚动
+    // 在组件挂载时启动定时器
+    this.intervalId = setInterval(() => {
+      // 移除这里的初始化,改为在开关打开时初始化
+      this.masterInfo.id =this.$route.query.id;
+      if(this.masterInfo.id==null||this.masterInfo.id==""){
+        console.log("为空");
+        this.masterInfo.id=="0000"
+      }
+      this.checkMasterInfo();
+    }, 60 * 60 * 1000); // 每隔 1 小时(60 分钟)调用一次
   },
   beforeDestroy () {
     this.stopScroll()
+
+      // 在组件销毁前清除定时器,防止内存泄漏
+      if (this.intervalId) {
+        clearInterval(this.intervalId);
+      }
+
   }
 }
 </script>

+ 2 - 2
zkqy-ui/src/views/bussiness/processMange.vue

@@ -578,7 +578,7 @@ export default {
         });
       }
       else {
-        //当前流程数据---->formKey 例如:Notes
+        //当前流程数据---->formKey 例如:Note  不管 怎样他都是需要fromkkey
         //查询当前组件的表单结构信息
         let pageNameObj={"pageName":row.benTaskNodeFormKey}
         //查询到的html结构信息
@@ -588,7 +588,7 @@ export default {
         const options = {
           moduleCache: {
             vue: Vue,
-            '@/api/bpmprocess/runDialogApi/index/c': {submitNodeForm} // 注册 API 模块
+            '@/api/bpmprocess/runDialogApi/index': {submitNodeForm} // 注册 API 模块
           },
           async getFile () {
             return res.fileStr

+ 41 - 7
zkqy-ui/src/views/orderMange/codeListManage/printIndex.vue

@@ -206,8 +206,9 @@
               label-width="80px"
               :inline="false"
               size="normal"
-              :disabled="isDisabled || isStartReadNum"
+
             >
+              <!--:disabled="isDisabled || isStartReadNum"-->
               <el-col :span="8">
                 <el-form-item prop="packaging" label="包装">
                   <el-select
@@ -321,11 +322,13 @@
                   <el-input-number
                     v-model="form.canisterNum"
                     size="mini"
+                    ref="inputNumber"
                     label=""
                     :min="1"
                     :step="1"
                     :controls="true"
                     controls-position="both"
+                    @input.native="handleInput"
                   >
                   </el-input-number>
                 </el-form-item>
@@ -522,6 +525,7 @@ import moment from "moment";
 
 export default {
   name: "ProductCodeList",
+
   dicts: [
     "packaging_type",
     "port",
@@ -756,6 +760,7 @@ export default {
       this.excuteType = 1;
       this.printHandler();
     }
+
   },
   beforeDestroy() {
     this.closeWebSocket();
@@ -767,6 +772,18 @@ export default {
   },
 
   methods: {
+    handleInput(value) {
+      console.log("触发了")
+      const currentTime = Date.now(); // 当前时间戳
+      // 如果 lastInputTime 存在,并且时间差超过 3 秒,则清空输入框
+      if (this.lastInputTime && currentTime - this.lastInputTime > 3000) {
+        console.log("三秒之后触发了")
+        this.form.canisterNum = null; // 清空输入框
+      }
+
+      // 更新 lastInputTime 为当前时间
+      this.lastInputTime = currentTime;
+    },
     // 总码单打印回调
     async summeryPrintHandler() {
       console.log("this.tableData", this.tableData);
@@ -959,6 +976,17 @@ export default {
         }
 
         this.initWebSocket();
+
+        // 使用 $refs 获取组件实例
+        const inputNumberComponent = this.$refs.inputNumber;
+        if (inputNumberComponent) {
+          // 访问内部的输入框元素并调用 focus 方法
+          const inputElement = inputNumberComponent.$el.querySelector('input');
+          if (inputElement) {
+            inputElement.focus();
+          }
+        }
+
       }
     },
     async initWebSocket() {
@@ -977,7 +1005,6 @@ export default {
       let frequency = getConfigValue("frequency", 30);
       let minimumWeight = getConfigValue("minimumWeight", 5);
       let antishake = getConfigValue("antishake", 3);
-
       const wsUrl = `ws:${process.env.VUE_APP_BASE_WS_API}/currentWeight`;
       this.websocket = new WebSocket(wsUrl);
       this.websocket.addEventListener("open", (event) => {
@@ -991,18 +1018,20 @@ export default {
 
       this.websocket.addEventListener("message", async (event) => {
         if (!this.printAuto) return;
-
+        console.log("hmc后端自动打印逻辑1")
         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();
+          console.log("hmc后端自动打印逻辑2")
           shouldPrint = false; // 重量为0时,重置打印标志
           return;
         }
 
         if (weight <= minimumWeight) {
+          console.log("hmc后端自动打印逻辑3")
           this.resetWeightStatus();
           shouldPrint = false; // 重量未满足打印条件,重置打印标志
           this.confirmPrinting = true;
@@ -1010,6 +1039,7 @@ export default {
         }
 
         if (initialWeight === null) {
+          console.log("hmc后端自动打印逻辑4")
           initialWeight = weight;
           shouldPrint = true; // 第一次有效重量,允许打印
           return;
@@ -1017,26 +1047,30 @@ export default {
 
         const weightDifference = Math.abs(weight - initialWeight);
         if (weightDifference > weightChangeThreshold) {
+          console.log("hmc后端自动打印逻辑5")
           initialWeight = weight;
           this.waiting = 0; // 重量有显著变化,重置等待计数并允许打印
           shouldPrint = true;
         } else {
+          console.log("打印逻辑7",this.waiting == frequency,shouldPrint,this.confirmPrinting);
           this.waiting++;
+          console.log( this.waiting,frequency)
           if (
-            this.waiting == frequency &&
-            shouldPrint &&
-            this.confirmPrinting
+            this.waiting == frequency && shouldPrint && this.confirmPrinting
           ) {
             // 只有在应该打印且等待计数达标时才打印qwe
             this.waiting = 0;
             this.confirmPrinting = false;
+            console.log("hmc后端自动打印逻辑6")
             shouldPrint = false; // 打印后禁止下一次打印,直到重量再次变化
             const isValidate = await this.validateAndPrint(weight);
           }
         }
       });
 
-      this.websocket.addEventListener("on", (e) => {});
+      this.websocket.addEventListener("on", (e) => {
+
+      });
       this.websocket.addEventListener("error", (event) => {
         this.$message.error("WebSocket错误,请重试");
       });

+ 2027 - 0
zkqy-ui/src/views/orderMange/codeListManage/printIndex2.vue

@@ -0,0 +1,2027 @@
+<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>
+                <el-button
+                  type="info"
+                  plain
+                  size="mini"
+                  @click="continuePrintHandler"
+                  >接 续
+                </el-button>
+              </div>
+              <el-button
+                :disabled="tableData.length == 0"
+                type="danger"
+                plain
+                size="mini"
+                @click="summeryPrintHandler"
+                >总码单
+              </el-button>
+              <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"
+            height="450"
+            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="productionLineNo"
+              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, scope.row)"
+                  >删除
+                </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"
+                    filterable
+                    size="mini"
+                    @change="machineToolChange"
+                  >
+                    <el-option
+                      v-for="(item, index) in lineOptions"
+                      :key="index"
+                      :label="item.productionLineName"
+                      :value="item.id"
+                    >
+                      <span class="discribe" style="float: left">{{
+                        item.productionLineName
+                      }}</span>
+                      <span
+                        style="float: right; color: #8492a6; font-size: 13px"
+                        >{{ item.productionLineDepartment }}</span
+                      >
+                    </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" 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"
+                    filterable
+                    size="mini"
+                    @change="levelChangeHandler"
+                  >
+                    <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="canisterWeight" label="筒重">
+                  <el-select
+                    v-model="form.canisterWeight"
+                    clearable
+                    filterable
+                    size="mini"
+                    allow-create
+                    default-first-option
+                  >
+                    <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"
+                    ref="inputNumber"
+                    label=""
+                    :min="1"
+                    :step="1"
+                    @input="handleInput"
+                    :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"
+                    allow-create
+                    default-first-option
+                  >
+                    <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="foreignTradeNumber" label="外贸号">
+                  <el-input-number
+                    v-model="form.foreignTradeNumber"
+                    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="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"
+            ></el-input>
+            <!--:disabled="isDisabled || isStartReadNum"-->
+            <!-- <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,
+  removeProductCodeASInventory,
+  listBySaleProductID,
+} from "@/api/codeListManage/productCodeList";
+import codeListPrint from "@/utils/print/codeListPrint";
+import { getServerPrintData } from "@/utils/print/printUtils";
+import { v4 as uuidv4 } from "uuid";
+import moment from "moment";
+
+export default {
+  name: "ProductCodeList",
+  dicts: [
+    "packaging_type",
+    "port",
+    "coding_list_format",
+    "direction_of_twist",
+    "automatic_printing",
+  ],
+  data() {
+    return {
+      lastInputTime: null, // 记录上一次输入的时间戳
+      summertId: "", //总码单id
+      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: {
+        machineToolNo: "", //机台编号
+        // 表单参数
+        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: "productNo",
+          label: "编号",
+        },
+        {
+          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, // 等待次数 不论时间
+      confirmPrinting: false, // 确认打印
+      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,
+    },
+    "dict.type.packaging_type": {
+      handler(newValue, oldValue) {
+        if (newValue?.length > 0 && this.excuteType == 1) {
+          this.form.packaging = newValue[0].value;
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+    "dict.type.coding_list_format": {
+      handler(newValue, oldValue) {
+        if (newValue?.length > 0 && this.excuteType == 1) {
+          this.form.printFormat = newValue[0].value;
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
+  mounted() {
+    this.summertId = new Date().getTime();
+    let { excuteType, qrCode } = this.$route.query;
+    if (excuteType == 2) {
+      //修改
+      this.handleUpdate(qrCode);
+    } else if (excuteType == 3) {
+      //补码
+      this.supplementCode(qrCode);
+    } else {
+      // 正常打印
+      this.excuteType = 1;
+      this.printHandler();
+    }
+  },
+  beforeDestroy() {
+    this.closeWebSocket();
+  },
+  computed: {
+    isDisabled() {
+      return this.excuteType != 1;
+    },
+  },
+
+  methods: {
+    handleInput(value) {
+      const currentTime = Date.now(); // 当前时间戳
+      // 如果 lastInputTime 存在,并且时间差超过 3 秒,则清空输入框
+      if (this.lastInputTime && currentTime - this.lastInputTime > 3000) {
+        this.form.canisterNum = null; // 清空输入框
+      }
+      // 更新 lastInputTime 为当前时间
+      this.lastInputTime = currentTime;
+    },
+    // 总码单打印回调
+    async summeryPrintHandler() {
+      console.log("this.tableData", this.tableData);
+      console.log("this.currentRow", this.currentRow);
+      // return;
+      let payload = { qrCodeVal: "", mapList: [], remark: "无", printType: "" };
+      let firstRowData = JSON.parse(JSON.stringify(this.tableData[0])); //以第一条数据为基础
+      let sumObj = {
+        canisterNum: 0, //筒数
+        grossWeight: 0, //毛重
+        suttle: 0, //净重
+      }; //需要累加的数据
+      this.tableData.forEach((item) => {
+        sumObj.canisterNum += Number(item.canisterNum) || 0;
+        sumObj.grossWeight += Number(item.grossWeight) || 0;
+        sumObj.suttle += Number(item.suttle) || 0;
+      });
+      sumObj.canisterNum = sumObj.canisterNum.toFixed(0);
+      sumObj.grossWeight = sumObj.grossWeight.toFixed(2);
+      sumObj.suttle = sumObj.suttle.toFixed(2);
+      // 添加产品信息
+      sumObj.productName = this.currentRow.productName;
+      sumObj.lotNum = this.currentRow.lotNum;
+      sumObj.productColor = this.currentRow.productColor;
+      sumObj.productColour = this.currentRow.productColor;
+      sumObj.saleProductId = this.currentRow.id;
+      sumObj.productSpecifications = this.currentRow.productSpecifications;
+      sumObj.directionOfTwistLabel =
+        this.dict.type.direction_of_twist.find(
+          (item) => item.value == this.currentRow.directionOfTwist
+        )?.label || " "; //捻向
+
+      Object.assign(firstRowData, sumObj);
+      // let timeStemp = new Date().getTime();
+      firstRowData.id = this.summertId;
+      firstRowData.otherStates = 1;
+      firstRowData.printFormat = "6"; //打印类型为总码单
+      firstRowData.boxSumNum = this.tableData.length; //箱子总数
+      firstRowData.boxNum = this.tableData.length; //箱子总数
+      console.log("firstRowData", firstRowData)
+      firstRowData.machineToolNo = this.lineOptions.find(
+        (item) => item.id == this.form.machineTool
+      ).productionLineNo;
+      firstRowData.qrCodeId = uuidv4().slice(0, 8); //生成总码单自己的qrCodeId
+      this.printTableData = [firstRowData];
+      // 保存打印数据
+      let payLoad = {
+        ...firstRowData,
+      };
+
+      let res = await productCodeList(payLoad);
+      if (res.code !== 200) {
+        this.$message.error("网络异常请稍后再试");
+        return;
+      }
+      let msg = this.isEdit ? "编辑" : "新增";
+      if (res.code == 200) {
+        // 后端打印
+         await this.newPrintHandler();
+         this.tableData = [];
+         this.$message.success(`总码单打印成功!`);
+        // 前端打印
+        //codeListPrint(this.printTableData, "printDom");
+
+        // 更新总码单id
+        this.summertId = new Date().getTime(); //总码单id重新生成
+      } else {
+        this.$message.error(`${msg}箱单失败`);
+      }
+    },
+    // 接续回调
+    async continuePrintHandler() {
+      try {
+        let { machineTool, workShifts, levels } = this.form;
+        if (!this.currentRow || !this.currentRow.lotNum) {
+          this.$message.error("请选择产品");
+          return;
+        }
+        let payload = {
+          isEnablePaging: false,
+          machineTool,
+          workShifts,
+          levels,
+          lotNum: this.currentRow.lotNum,
+          saleProductId: this.currentRow.id,
+        };
+        let res = await listBySaleProductID(payload);
+        if (res.code == 200) {
+          console.log(res);
+          this.tableData = res.rows.map((item) => {
+            let productionLineNo = this.lineOptions.find(
+              (i) => i.id == item.machineTool
+            )?.productionLineNo;
+            return {
+              ...item,
+              productionLineNo,
+            };
+          });
+
+          if (res.rows.length > 0) {
+            let lastRow = res.rows[res.rows.length - 1];
+            this.summertId = lastRow.parentCode; //取最后一条数据的总码单code为当前总码单code
+            this.qrCode = lastRow.qrCode;
+            let {
+              packaging,
+              machineTool,
+              workShifts,
+              productionDate,
+              levels,
+              foreignTradeNumber,
+              canisterWeight,
+              canisterNum,
+              boxWeight,
+              tubeColor,
+              printFormat,
+              grossWeight,
+              remark,
+            } = lastRow;
+            Object.assign(this.form, {
+              packaging,
+              machineTool,
+              workShifts,
+              productionDate,
+              levels,
+              foreignTradeNumber,
+              canisterWeight,
+              canisterNum,
+              boxWeight,
+              tubeColor,
+              printFormat,
+              grossWeight,
+              remark,
+            });
+          }
+          this.$message.success("接续完成,请继续打印");
+        } else {
+          this.$message.error(res.msg);
+        }
+      } catch (error) {
+        console.log(error);
+        this.$message.error("网络异常");
+      }
+    },
+    // 等级改变回调
+    async levelChangeHandler() {
+      // return;
+      // 等级发生变化,重新获取码单号
+      this.tableData = []; //清空打印记录
+      let res = await getQrCode();
+      this.summertId = new Date().getTime(); //总码单id重新生成
+      if (res.code == 200) {
+        this.qrCode = res.msg;
+      } else {
+        this.$message.error(res.msg);
+      }
+    },
+    // 机台改变回调
+    machineToolChange(id) {
+      if (id) {
+        this.form.machineToolNo = this.lineOptions.find(
+          (item) => item.id == id
+        ).productionLineNo;
+      }
+      this.getAllBatchData(id);
+    },
+    // 打印按钮回调
+    async printBtnHandler() {
+      let res = await this.validateAndPrint();
+      if (!res) {
+        // this.$message.error("请完善数据");
+      }
+    },
+    async readStateChange() {
+      if (this.isStartReadNum) {
+        //正在读
+        this.closeWebSocket();
+        this.isStartReadNum = false;
+        this.waiting = 0; //
+        this.$message.success("已关闭读数");
+      } else {
+        // 开启读数时 先获取码单号
+        if (this.tableData.length == 0) {
+          //左侧表单为空时才获取码单号
+          let res = await getQrCode();
+          if (res.code == 200) {
+            this.qrCode = res.msg;
+          } else {
+            this.$message.error(res.msg);
+          }
+        }
+
+        this.initWebSocket();
+
+        // 使用 $refs 获取组件实例
+        const inputNumberComponent = this.$refs.inputNumber;
+        if (inputNumberComponent) {
+          // 访问内部的输入框元素并调用 focus 方法
+          const inputElement = inputNumberComponent.$el.querySelector('input');
+          if (inputElement) {
+            inputElement.focus();
+          }
+        }
+      }
+    },
+    async initWebSocket() {
+      // let res = await this.addIsValidate();
+      // if (!res) {
+      //   this.$message.warning("请完善表单数据");
+      //   return;
+      // }
+      const getConfigValue = (label, defaultValue) => {
+        let value = this.dict.type.automatic_printing.find(
+          (item) => item.label === label
+        )?.value;
+        return value !== undefined ? value : defaultValue;
+      };
+
+      let frequency = getConfigValue("frequency", 30);
+      let minimumWeight = getConfigValue("minimumWeight", 5);
+      let antishake = getConfigValue("antishake", 3);
+
+      const wsUrl = `ws:${process.env.VUE_APP_BASE_WS_API}/currentWeight`;
+      this.websocket = new WebSocket(wsUrl);
+      this.websocket.addEventListener("open", (event) => {
+        this.isStartReadNum = true;
+        this.$message.success("已开启读数");
+      });
+
+      let initialWeight = null; // 初始化基准重量
+      const weightChangeThreshold = antishake; // 定义重量变化阈值
+      let shouldPrint = false; // 用于控制是否应该打印
+
+      this.websocket.addEventListener("message", async (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; // 重量未满足打印条件,重置打印标志
+          this.confirmPrinting = true;
+          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.confirmPrinting
+          ) {
+            // 只有在应该打印且等待计数达标时才打印qwe
+            this.waiting = 0;
+            this.confirmPrinting = false;
+            shouldPrint = false; // 打印后禁止下一次打印,直到重量再次变化
+            const isValidate = await this.validateAndPrint(weight);
+          }
+        }
+      });
+
+      this.websocket.addEventListener("on", (e) => {});
+      this.websocket.addEventListener("error", (event) => {
+        this.$message.error("WebSocket错误,请重试");
+      });
+
+      this.websocket.addEventListener("close", () => {});
+    },
+    // 用于重置与重量相关的状态
+    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) {
+      this.nowWeight = val;
+    },
+    // 开始设置新的重量
+    async setWeight(weight) {
+      let newData = {};
+      let {
+        machineTool,
+        packaging,
+        boxWeight,
+        canisterWeight,
+        canisterNum,
+        grossWeight,
+        suttle, //净重
+        workShifts, //班次
+        tubeColor,
+        productionDate,
+        printFormat,
+        levels,
+        remark,
+        machineToolNo,
+      } = this.form;
+
+      let {
+        productName,
+        productSpecifications,
+        productColor,
+        lotNum,
+        directionOfTwist,
+        productId,
+        productNo,
+      } = this.currentRow;
+
+      let directionOfTwistLabel =
+        this.dict.type.direction_of_twist.find(
+          (item) => item.value == directionOfTwist
+        )?.label || " ";
+
+      newData = {
+        productionLineNo: this.lineOptions.find(
+          (i) => i.id == this.form.machineTool
+        )?.productionLineNo,
+        // qrCode: this.getBoxOrderNum(), //箱单号
+        packaging, //包装方式 1:车丝 2:小包装  3:大包装
+        qrCode: this.qrCode, //箱单号
+        levels,
+        productNo,
+        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,
+        qrCodeId: uuidv4().slice(0, 8),
+      };
+      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) => {
+            this.$message.warning("请完善表单数据");
+            resolve(false);
+          }
+        );
+      });
+    },
+    // 新的后端打印逻辑
+    async newPrintHandler() {
+      let printRow = this.printTableData[0];
+      // console.log(printRow,"色号A数据")
+      // return;
+      let payload = { qrCodeVal: "", mapList: [], remark: "无", printType: "" };
+      let {
+        id, //id
+        qrCode, //箱单号
+        canisterNum, //筒数
+        grossWeight, //毛重
+        suttle, //净重
+        remark, //备注
+        printFormat,
+        qrCodeId,
+        otherStates,
+      } = printRow;
+
+      let temp =id + "@" + qrCodeId + "@" + canisterNum + "@" + suttle + "@" + grossWeight + "@" +
+        qrCode;
+      if (otherStates == 1) {
+        temp += "@" + 1; //总码单标识
+      }
+
+      console.log("二维码数据", temp);
+      payload.qrCodeVal = temp;
+      payload.remark = "产品编号:"+printRow.productNo;//原注解字段更改为产品编号字段
+     // console.log(printRow,"dddddd");
+      payload.mapList = getServerPrintData(printRow);
+      switch (printFormat) {
+        case "3": //英文码单
+          payload.printType = "export";
+          break;
+        case "4": //新思维
+          payload.printType = "normal";
+          break;
+        case "5": //无净重码单(同3)
+          payload.printType = "normal";
+          break;
+        case "6": //总码单
+          payload.printType = "assembleNormal";
+          break;
+      }
+      try {
+        let res = await AutoPrinting(payload);
+        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) {
+        this.$message.error(error);
+      }
+    },
+
+    closeWebSocket() {
+      if (
+        this.websocket !== null &&
+        this.websocket.readyState !== WebSocket.CLOSED
+      ) {
+        this.websocket.close();
+      }
+    },
+    // 毛重改变回调
+    changeGrossWeight(row) {
+      //箱重   毛重    筒重 筒数
+      let { boxWeight, grossWeight, canisterWeight, canisterNum } = row;
+      if (!Number(grossWeight)) {
+        row.suttle = 0;
+        return;
+      }
+      //求净重
+      row.suttle = (
+        Number(grossWeight) -
+        Number(boxWeight) -
+        Number(canisterWeight) * Number(canisterNum)
+      ).toFixed(2);
+    },
+    // 删除表格一条数据回调
+    async handleDeleteOne(index, row) {
+      this.$modal
+        .confirm("是否确认该条打印记录?")
+        .then(function () {
+          return removeProductCodeASInventory(row);
+        })
+        .then(() => {
+          this.tableData.splice(index, 1);
+          this.$modal.msgSuccess("删除成功");
+        })
+        .catch(() => {
+          this.$modal.msgSuccess("取消操作");
+        });
+    },
+    // 确认保存修改一条数据
+    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 {
+          this.$message.error(`${msg}失败`);
+        }
+      } catch (error) {}
+    },
+    // 确认打印回调
+    printConfirmHandler(printData) {
+      // if (this.tableData.length == 0) {
+      //   this.$message.warning("请添加打印的数据");
+      //   return;
+      // }
+
+      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]);
+      // }
+      // 后端打印
+      this.newPrintHandler();
+    },
+    // 获取机台选项数据
+    async getLineOptionLsit() {
+      let payLoad = {
+        isEnablePaging: false,
+      };
+      try {
+        let res = await getLineOptionLsit(payLoad);
+        if (res.code == 200) {
+          this.lineOptions = res.rows;
+          if (this.lineOptions.length > 0 && this.excuteType == 1) {
+            this.form.machineTool = this.lineOptions[0].id;
+            this.machineToolChange(this.form.machineTool);
+          }
+        } else {
+        }
+      } catch (error) {}
+    },
+    // 补码打印回调
+    handleSuppleOne(row) {
+      console.log(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];
+            let timeStemp = new Date().getTime();
+            this.printTableData = [rowData];
+            this.printTableData[0].id = timeStemp;
+
+            // 先打印
+                //求净重
+                this.changeGrossWeight(this.printTableData[0]);
+            // console.log("rowData",rowData)
+            // return;
+            // 后保存数据
+            let payLoad = {
+              ...this.form,
+              id: timeStemp, //前端生成id
+              qrCodeId: rowData.qrCodeId,
+              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,
+              saleProductId: this.currentRow.id,
+              // 总码单相关数据  start
+              otherStates: 0,
+              parentCode: this.summertId,
+              // 总码单相关数据  end
+              directionOfTwist: this.currentRow.directionOfTwist, //捻向
+            };
+            console.log()
+            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);
+            if (res.code !== 200) {
+              this.$message.error("网络异常请稍后再试");
+              return;
+            }
+            let msg = this.isEdit ? "编辑" : "新增";
+            console.log("dddd",msg)
+            if (res.code == 200) {
+              console.log("dddd")
+              // 后端打印
+               await this.newPrintHandler();
+              // 前端打印
+              //codeListPrint(this.printTableData, "printDom");
+              // if (this.excuteType == 1) {
+              //   this.tableData.push(this.printTableData[0]);
+              // }
+            } else {
+              this.$message.error(`${msg}箱单失败`);
+            }
+          } catch (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 {
+              this.$message.error(`${msg}箱单失败`);
+            }
+          } catch (error) {}
+        }
+      });
+    },
+    // 选择一个打印
+    chooseOneToPrint() {
+      this.chooseState = !this.chooseState; //开启选择状态
+      if (this.chooseState) {
+        this.$message.info("请选择打印的箱单");
+      } else {
+        this.$message.info("退出批箱单状态");
+      }
+    },
+    supplementCodeHandler() {
+      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;
+          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 {
+          return false;
+        }
+      });
+    },
+    // 计算净重
+    getSuttle() {
+      let { boxWeight, canisterWeight, canisterNum } = this.form;
+      return (Number(boxWeight) - canisterWeight * canisterNum).toFixed(2);
+    },
+    // 表格点击回调
+    async handleCurrentChange(val) {
+      if (!val) return;
+      if (this.isStartReadNum || this.excuteType != 1) {
+        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.summertId = new Date().getTime(); //总码单id重新生成
+      }
+      this.currentRow = val;
+      // this.continuePrintHandler(); //产品选择后,自动执行接续逻辑
+    },
+    // 获取码单号
+    async getQrCodeHandle() {
+      let res = await getQrCode();
+      if (res.code == 200) {
+        this.qrCode = res.msg;
+      } else {
+        this.$message.error(res.msg);
+      }
+    },
+    // 选择打印数据回调
+    handlePrintOneChange(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,
+                    saleProductId: this.currentRow.id, //货品id
+                    directionOfTwistLabel:
+                      this.currentRow.directionOfTwistLabel, //捻向
+                  };
+                  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);
+                  if (res.code !== 200) {
+                    this.$message.error("网络异常请稍后再试");
+                    return;
+                  }
+                  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 {
+                    this.$message.error(`${msg}箱单失败`);
+                  }
+                } catch (error) {}
+              }
+            });
+          }
+        },
+      });
+    },
+    // 获取所有批次数据
+    async getAllBatchData(id) {
+      try {
+        let payload = { machineTool: id };
+        let res = await finishedProductList(payload);
+        if (res.code == 200) {
+          this.batchData = res.data;
+          this.batchTableData = res.data;
+        } else {
+        }
+      } catch (error) {}
+    },
+    // 批号查询接口
+    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 || {};
+          // 初始化默认值
+          if (
+            this.dropDownData.work_shifts?.length > 0 &&
+            this.excuteType == 1
+          ) {
+            this.form.workShifts = this.dropDownData.work_shifts[0].codeName;
+          }
+          if (this.dropDownData.level?.length > 0 && this.excuteType == 1) {
+            this.form.levels = this.dropDownData.level[0].codeName;
+          }
+          if (
+            this.dropDownData.drum_weight?.length > 0 &&
+            this.excuteType == 1
+          ) {
+            this.form.canisterWeight =
+              this.dropDownData.drum_weight[0].codeName;
+          }
+          if (
+            this.dropDownData.box_weight?.length > 0 &&
+            this.excuteType == 1
+          ) {
+            this.form.boxWeight = this.dropDownData.box_weight[0].codeName;
+          }
+          if (
+            this.dropDownData.tube_color?.length > 0 &&
+            this.excuteType == 1
+          ) {
+            this.form.tubeColor = this.dropDownData.tube_color[0].codeName;
+          }
+        } else {
+          this.$message.error("网络异常!");
+        }
+      } 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();
+
+      this.form.productionDate = new Date();
+
+      await this.getAllBatchData(); //获取所有产品数据
+      await this.getLineOptionLsit(); //获取机台选项数据
+      await this.getSelectOptions();
+      this.printShow = true;
+    },
+    /** 修改按钮操作 */
+    handleUpdate(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(this.form.machineTool); //获取所有产品数据
+          await this.getLineOptionLsit(); //获取机台选项数据
+          await this.getSelectOptions();
+          this.initProductData();
+          this.printShow = true;
+        } else {
+        }
+      });
+    },
+    // 补码回调
+    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(this.form.machineTool); //获取所有产品数据
+        await this.getLineOptionLsit(); //获取机台选项数据
+        await this.getSelectOptions();
+        this.initProductData();
+        this.printShow = true;
+      });
+    },
+
+    // 初始化产品相关数据
+    initProductData() {
+      this.batchNum = this.form.lotNum;
+      // this.batchNumChange();
+      console.log(this.batchData);
+      this.batchTableData = this.batchData.filter(
+        (item) => item.productId == this.tableData[0].productId
+      );
+      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>