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

码单管理修改和补码逻辑修改

lph 1 жил өмнө
parent
commit
ee88c30878

+ 9 - 0
zkqy-ui/src/api/codeListManage/productCodeList.js

@@ -92,6 +92,15 @@ export function getPrintData(id) {
     //baseURL: process.env.VUE_APP_BASE_API1
   })
 }
+// 新的回显数据接口
+export function getPrintDataNew(qrCode) {
+  return request({
+    url: `/system/productCodeList/queryCodeListByQrCode/${qrCode}`,
+    method: 'get',
+    //baseURL: process.env.VUE_APP_BASE_API1
+  })
+}
+
 // 获取箱号编码接口
 export function getQrCode(id) {
   return request({

+ 1 - 0
zkqy-ui/src/utils/print/codeListPrint.js

@@ -115,6 +115,7 @@ function sleep(ms) {
 
 // 打印中文版
 function printCN(uuid, item, res) {
+  console.log('中文', item);
   let {
     qrCode,//序号
     machineTool,//机台

+ 104 - 32
zkqy-ui/src/views/orderMange/codeListManage/index.vue

@@ -25,22 +25,22 @@
             @keyup.enter.native="handleQuery"
           />
         </el-form-item>
-        <el-form-item label="货品编号" prop="productId">
+        <!-- <el-form-item label="货品编号" prop="productId">
           <el-input
             v-model="queryParams.productId"
             placeholder="请输入货品编号"
             clearable
             @keyup.enter.native="handleQuery"
           />
-        </el-form-item>
-        <el-form-item label="等级" prop="levels">
+        </el-form-item> -->
+        <!-- <el-form-item label="等级" prop="levels">
           <el-input
             v-model="queryParams.levels"
             placeholder="请输入等级"
             clearable
             @keyup.enter.native="handleQuery"
           />
-        </el-form-item>
+        </el-form-item> -->
 
         <el-form-item>
           <el-button
@@ -68,7 +68,7 @@
             >打印
           </el-button>
         </el-col>
-        <el-col :span="1.5">
+        <!-- <el-col :span="1.5">
           <el-button
             type="success"
             plain
@@ -79,7 +79,7 @@
             v-hasPermi="['system:productCodeList:edit']"
             >修改
           </el-button>
-        </el-col>
+        </el-col> -->
         <el-col :span="1.5">
           <el-button
             type="danger"
@@ -300,6 +300,7 @@
         :visible.sync="printShow"
         :fullscreen="true"
         append-to-body
+        @close="getList"
       >
         <div class="main-wrap">
           <div class="left">
@@ -308,7 +309,7 @@
                 <!-- <el-button type="primary" size="mini" @click="printConfirmHandler"
                 >打印</el-button
               > -->
-                <div class="btnWrap">
+                <div class="btnWrap" v-show="excuteType == 1">
                   <el-button
                     v-if="excuteType == 2"
                     :disabled="tableData.length != 1"
@@ -350,7 +351,7 @@
                     >打印
                   </el-button>
                 </div>
-                <div class="weightWrap">
+                <div class="weightWrap" v-show="excuteType == 1">
                   <h1>实时重量:{{ nowWeight }}</h1>
                 </div>
                 <!-- <el-button
@@ -402,15 +403,16 @@
                 label="筒数"
               ></el-table-column>
               <el-table-column prop="grossWeight" label="毛重">
-                <!-- <template slot-scope="scope">
+                <template slot-scope="scope">
                   <el-input
-                    :disabled="excuteType == 3"
+                    v-if="excuteType == 2"
                     v-model="scope.row.grossWeight"
                     @input="changeGrossWeight(scope.row)"
                     size="mini"
                     clearable
                   ></el-input>
-                </template> -->
+                  <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>
@@ -419,6 +421,24 @@
               <el-table-column 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"
@@ -706,14 +726,14 @@
                 @keyup.enter.native="batchNumChange"
                 :disabled="isDisabled || isStartReadNum"
               ></el-input>
-              <el-button
+              <!-- <el-button
                 class="ml10"
                 type="primary"
                 size="mini"
                 :disabled="!currentRow.lotNum || isDisabled || printAuto"
                 @click="addProductHandler"
                 >添加
-              </el-button>
+              </el-button> -->
             </div>
             <div class="table-wrap">
               <el-table
@@ -767,6 +787,7 @@ import {
   updateProductCodeList,
   getQrCode,
   AutoPrinting,
+  getPrintDataNew,
 } from "@/api/codeListManage/productCodeList";
 import codeListPrint from "@/utils/print/codeListPrint";
 import { getServerPrintData } from "@/utils/print/printUtils";
@@ -1213,7 +1234,6 @@ export default {
         if (res.code == 200 && res.status == "success") {
           this.$message.success(res.msg);
           if (this.excuteType == 1 && this.printAuto) {
-            this.changeGrossWeight(printRow);
             this.tableData.push(printRow);
           }
         } else {
@@ -1249,6 +1269,42 @@ export default {
     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) {
@@ -1260,11 +1316,16 @@ export default {
       this.printTableData.forEach((item) => {
         item.qrCodeData = printData + "-" + item.boxNum;
       });
+      this.changeGrossWeight(this.printTableData[0]);
       // 前端打印
-      codeListPrint(this.printTableData, "printDom");
+      // codeListPrint(this.printTableData, "printDom");
+
+      // if (this.excuteType == 1) {
+      //   this.tableData.push(this.printTableData[0]);
+      // }
       // 后端打印
       console.log("newPrintHandler");
-      // this.newPrintHandler();
+      this.newPrintHandler();
     },
     // 获取机台选项数据
     async getLineOptionLsit() {
@@ -1283,6 +1344,11 @@ export default {
         console.error(error);
       }
     },
+    // 补码打印回调
+    handleSuppleOne(row) {
+      this.printTableData = [row];
+      this.printConfirmHandler(row.id);
+    },
     // 获取箱单数据
     async getOrderData(newData) {
       this.$refs.form.validate(async (valid) => {
@@ -1317,6 +1383,7 @@ export default {
               this.printConfirmHandler(this.tableData[0].id);
               return;
             }
+            this.changeGrossWeight(payLoad);
             let res = await tempApiFun(payLoad);
             let msg = this.isEdit ? "编辑" : "新增";
             if (res.code == 200) {
@@ -1555,6 +1622,7 @@ export default {
                   } else if (this.excuteType == 2) {
                     tempApiFun = updateProductCodeList;
                   }
+                  this.changeGrossWeight(payLoad);
                   let res = await tempApiFun(payLoad);
                   let msg = this.isEdit ? "编辑" : "新增";
                   if (res.code == 200) {
@@ -1628,6 +1696,7 @@ export default {
     },
     // 表单重置
     reset() {
+      this.nowWeight = 0;
       this.form = {
         id: null,
         qrCode: null,
@@ -1677,7 +1746,7 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map((item) => item.id);
+      this.ids = selection.map((item) => item.qrCode);
       this.single = selection.length !== 1;
       this.multiple = !selection.length;
     },
@@ -1699,13 +1768,14 @@ export default {
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
+      console.log(row);
       this.reset();
-      const id = row.id || this.ids;
-      getPrintData(id).then(async (response) => {
+      const id = row.qrCode;
+      getPrintDataNew(id).then(async (response) => {
         if (response.code == 200) {
           this.excuteType = 2;
-          this.form = response.data;
-          this.tableData = [response.data] || [{}];
+          this.form = response.data[0];
+          this.tableData = response.data;
 
           await this.getAllBatchData(); //获取所有产品数据
           await this.getLineOptionLsit(); //获取机台选项数据
@@ -1720,12 +1790,12 @@ export default {
     // 补码回调
     supplementCode(row) {
       this.reset();
-      const id = row.id || this.ids;
-      getPrintData(id).then(async (response) => {
+      const id = row.qrCode;
+      getPrintDataNew(id).then(async (response) => {
         this.excuteType = 3; //补码
         this.printAuto = false;
-        this.form = response.data;
-        this.tableData = [response.data] || [];
+        this.form = response.data[0];
+        this.tableData = response.data;
         await this.getAllBatchData(); //获取所有产品数据
         await this.getLineOptionLsit(); //获取机台选项数据
         await this.getSelectOptions();
@@ -1765,12 +1835,14 @@ export default {
         let directionOfTwistLabel = this.dict.type.direction_of_twist.find(
           (item) => item.value == directionOfTwist
         )?.label;
-        Object.assign(this.tableData[0], {
-          productName, //品种
-          productSpecifications, //规格
-          productColor, //色号
-          directionOfTwist, //捻向
-          directionOfTwistLabel,
+        this.tableData.forEach((item) => {
+          Object.assign(item, {
+            productName, //品种
+            productSpecifications, //规格
+            productColor, //色号
+            directionOfTwist, //捻向
+            directionOfTwistLabel,
+          });
         });
       }
     },
@@ -1796,7 +1868,7 @@ export default {
     },
     /** 删除按钮操作 */
     handleDelete(row) {
-      const ids = row.id || this.ids;
+      const ids = row.qrCode || this.ids;
       this.$modal
         .confirm('是否确认删除产品码单编号为"' + ids + '"的数据项?')
         .then(function () {