Răsfoiți Sursa

箱单打印逻辑处理/箱单数据保存接口

lph 1 an în urmă
părinte
comite
0da36b67cf

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

@@ -64,3 +64,23 @@ export function getOptionLsit() {
     baseURL: process.env.VUE_APP_BASE_API1
   })
 }
+
+// 获取机台选项数据
+export function getLineOptionLsit(query) {
+  return request({
+    url: '/system/line/list',
+    method: 'get',
+    params: query,
+    baseURL: process.env.VUE_APP_BASE_API1
+  })
+}
+
+// 发送打印数据接口
+export function productCodeList(data) {
+  return request({
+    url: '/system/productCodeList',
+    method: 'post',
+    data,
+    baseURL: process.env.VUE_APP_BASE_API1
+  })
+}

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

@@ -0,0 +1,120 @@
+import moment from 'moment'
+import QRCode from 'qrcodejs2'
+import { v4 as uuidv4 } from "uuid";
+
+function codeListPrint(data, domId) {
+  if (data.length == 0) {
+    return
+  }
+  let preHtml = ` <div style="width: 800px;position: relative;">
+
+    <div style="width: 100%;position: relative;text-align: center;">
+      <span style="font-size: 24px;font-weight: 500;">诸暨市新丝维化纤有限公司</span>
+    </div>`
+  let endHtml = `<div style="display: flex;flex-direction: row-reverse;">
+      <span>注:不同批号,请勿混用</span>
+    </div>
+  </div>`
+  let res = ``;
+  let uuidList = [];
+  for (let i = 0; i < data.length; i++) {
+    let item = data[i]
+    let {
+      qrCode,//序号
+      machineTool,//机台
+      boxWeight,//箱重-车重
+      canisterweight,//筒重
+      canisterNum,//筒数
+      grossWeight,//毛重
+      suttle,//净重
+      workShifts,//班次
+      tubecolor,//管色
+      boxOrderNum, //箱号
+      productionDate, //日期
+      printFormat, //格式
+      productName, //产品名
+      productSpecifications, //规格
+      productColor, //色泽
+      lotNum, //批次
+      levels,//等级
+      directionOfTwist,//捻向
+    } = item
+    let theNumber = Number(printFormat) //小包装:1  大包装:2
+    while (theNumber > 0) {
+      let uuid = uuidv4().slice(0, 8);
+      theNumber--;
+      res += preHtml;
+      let qrCodeData = '123456';
+      uuidList.push({
+        id: uuid,
+        qrCodeData: qrCodeData
+      })
+      res += `<div style="width: 100%;display: flex;justify-content: center;margin:5px 0;">
+      <div id="${uuid}" style="width: 120px;height: 120px;"></div>
+    </div>
+    <table style="width: 100%;border-collapse:collapse;" cellpadding="10" border="1">
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">品种</td>
+        <td style="width: 300px;">${productName}</td>
+        <td style="width: 100px;" colspan="1">规格</td>
+        <td style="width: 300px;" colspan="2">${productSpecifications}</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">批号</td>
+        <td style="width: 300px;">${lotNum}</td>
+        <td style="width: 100px;" colspan="1">色号</td>
+        <td style="width: 300px;" colspan="2">${productColor}</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">等级</td>
+        <td style="width: 300px;">${levels}</td>
+        <td style="width: 100px;" colspan="1">箱号</td>
+        <td style="width: 250px;" colspan="1">${boxOrderNum}</td>
+        <td style="width: 50px;" colspan="1">${qrCode}</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">筒数</td>
+        <td style="width: 300px;">${canisterNum}&ensp;&ensp;&ensp;${tubecolor}</td>
+        <td style="width: 100px;" colspan="1">捻向</td>
+        <td style="width: 300px;" colspan="2">${directionOfTwist}</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">班次</td>
+        <td style="width: 300px;">${workShifts}&ensp;&ensp;&ensp;${machineTool}</td>
+        <td style="width: 100px;" colspan="1">日期</td>
+        <td style="width: 300px;" colspan="2">${productionDate}</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">毛重</td>
+        <td style="width: 300px;">${grossWeight}</td>
+        <td style="width: 100px;" colspan="1">净重</td>
+        <td style="width: 300px;font-size: 20px;font-weight: 500;" colspan="2">${suttle}</td>
+      </tr>
+    </table>`
+      res += endHtml;
+    }
+  }
+  document.body.innerHTML = document.getElementById(domId).innerHTML = res;
+  for (var i = 0; i < uuidList.length; i++) {
+    let data = uuidList[i]
+    new QRCode(document.getElementById("" + data.id), {
+      text: sleep(1) + data.qrCodeData,
+      width: 120,
+      height: 120,
+      colorDark: "#000000",
+      colorLight: "#ffffff",
+      correctLevel: QRCode.CorrectLevel.H,
+    });
+  }
+  window.print();//打印
+  // window.location.reload();
+  return false;
+}
+// 延迟
+function sleep(ms) {
+  var unixtime_ms = new Date().getTime();
+  while (new Date().getTime() < unixtime_ms + ms) { }
+  return "";
+}
+
+export default codeListPrint

+ 209 - 42
zkqy-ui/src/views/orderMange/codeListManage/index.vue

@@ -138,7 +138,14 @@
     >
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="码单号" align="center" prop="qrCode" />
+      <el-table-column label="品名" align="center" prop="productName" />
+      <el-table-column
+        label="规格"
+        align="center"
+        prop="productSpecifications"
+      />
       <el-table-column label="批号" align="center" prop="lotNum" />
+      <el-table-column label="色泽" align="center" prop="productColor" />
       <el-table-column label="货品编号" align="center" prop="productId" />
       <el-table-column label="等级" align="center" prop="levels" />
       <el-table-column label="筒数" align="center" prop="canisterNum" />
@@ -289,10 +296,14 @@
         <div class="left">
           <div class="top-area">
             <div class="btn-list mb10">
-              <el-button type="primary" size="mini" @click="() => {}"
+              <!-- <el-button type="primary" size="mini" @click="printConfirmHandler"
                 >打印</el-button
-              >
-              <el-button type="primary" size="mini" @click="getOrderData"
+              > -->
+              <el-button
+                :disabled="tableData.length != 1"
+                type="primary"
+                size="mini"
+                @click="getOrderData"
                 >箱单</el-button
               >
             </div>
@@ -326,7 +337,7 @@
               :label="`${tempStr}重`"
             ></el-table-column>
             <el-table-column
-              prop="canisterweight"
+              prop="canisterWeight"
               label="筒重"
             ></el-table-column>
             <el-table-column prop="canisterNum" label="筒数"></el-table-column>
@@ -341,12 +352,23 @@
             </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="tubeColor" label="管色"></el-table-column>
+            <el-table-column prop="remark" label="备注"></el-table-column>
+            <el-table-column label="操作">
+              <template slot-scope="scope">
+                <el-button
+                  type="danger"
+                  size="mini"
+                  @click="handleDeleteOne(scope.$index)"
+                  >删除</el-button
+                >
+              </template>
+            </el-table-column>
           </el-table>
           <div class="count-area">
             <div class="count-item">
               <div class="count-title">
-                <span>合计箱数:</span>
+                <span>合计{{ tempStr }}数:</span>
               </div>
               <div class="count-value">
                 <span>{{ count.sumBoxNum }}</span>
@@ -365,7 +387,7 @@
                 <span>合计毛重:</span>
               </div>
               <div class="count-value">
-                <span>{{ count.sumSuttle }}</span>
+                <span>{{ count.sumGrossWeight }}</span>
               </div>
             </div>
             <div class="count-item">
@@ -373,7 +395,7 @@
                 <span>合计净重:</span>
               </div>
               <div class="count-value">
-                <span>{{ count.sumGrossWeight }}</span>
+                <span>{{ count.sumSuttle }}</span>
               </div>
             </div>
           </div>
@@ -416,10 +438,10 @@
                     size="mini"
                   >
                     <el-option
-                      v-for="item in dropDownData['machine tool']"
-                      :key="item.codeName"
-                      :label="item.codeName"
-                      :value="item.codeName"
+                      v-for="item in lineOptions"
+                      :key="item.productionLineNo"
+                      :label="item.productionLineNo"
+                      :value="item.productionLineNo"
                     >
                     </el-option>
                   </el-select>
@@ -449,6 +471,7 @@
                     v-model="form.productionDate"
                     type="date"
                     size="mini"
+                    value-format="yyyy-MM-dd"
                   >
                   </el-date-picker>
                 </el-form-item>
@@ -481,9 +504,9 @@
                 </el-form-item>
               </el-col>
               <el-col :span="8">
-                <el-form-item prop="canisterweight" label="筒重">
+                <el-form-item prop="canisterWeight" label="筒重">
                   <el-select
-                    v-model="form.canisterweight"
+                    v-model="form.canisterWeight"
                     clearable
                     filterable
                     size="mini"
@@ -532,9 +555,9 @@
                 </el-form-item>
               </el-col>
               <el-col :span="8">
-                <el-form-item prop="tubecolor" label="管色">
+                <el-form-item prop="tubeColor" label="管色">
                   <el-select
-                    v-model="form.tubecolor"
+                    v-model="form.tubeColor"
                     clearable
                     filterable
                     size="mini"
@@ -586,6 +609,18 @@
                   </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">
@@ -613,7 +648,7 @@
               border
               stripe
               width="100%"
-              max-height="300"
+              max-height="260"
               highlight-current-row
               @current-change="handleCurrentChange"
             >
@@ -634,6 +669,7 @@
         <el-button @click="cancel">取 消</el-button>
       </div> -->
     </el-dialog>
+    <div id="printDom" style="width: 160px; height: 160px"></div>
   </div>
 </template>
 
@@ -646,18 +682,22 @@ import {
   updateProductCodeList,
   finishedProductList,
   getOptionLsit,
+  getLineOptionLsit,
+  productCodeList,
 } from "@/api/codeListManage/productCodeList";
-
+import codeListPrint from "@/utils/print/codeListPrint";
+import { async } from "@/components/updateModule/k-form-design/lib/k-form-design.common";
 export default {
   name: "ProductCodeList",
   dicts: ["packaging_type", "port", "coding_list_format"],
   data() {
     return {
+      // 自定义数据 start
+      lineOptions: [], //机台选项数据
       orderData: {
         boxNo: "",
         msg: "不定重",
       },
-      // 自定义数据 start
       tempStr: "箱",
       printShow: false,
       uuCode: "",
@@ -666,12 +706,12 @@ export default {
         //   machineTool: "", //机台号
         //   qrCode: "", //箱号-码单号
         //   boxWeight: "", //箱重-车重
-        //   canisterweight: "", //筒重
+        //   canisterWeight: "", //筒重
         //   canisterNum: "", //筒数
         //   grossWeight: "", //毛重
         //   suttle: "", //净重
         //   workShifts: "", //班次
-        //   tubecolor: "", //管色
+        //   tubeColor: "", //管色
         // },
       ],
       // 统计相关数据
@@ -690,12 +730,13 @@ export default {
         productionDate: "", //生产日期
         levels: "", //等级
         foreignTradeNumber: "", //外贸号
-        canisterweight: "", //筒重
+        canisterWeight: "", //筒重
         boxWeight: "", //箱重-车重
         canisterNum: "", //筒数
-        tubecolor: "", //管色
+        tubeColor: "", //管色
         comPort: "", //端口
         printFormat: "", //格式
+        remark: "", //备注
       },
       rules: {
         packaging: [
@@ -711,16 +752,16 @@ export default {
           { required: true, message: "请选择生产日期", trigger: "change" },
         ],
         levels: [{ required: true, message: "请选择等级", trigger: "change" }],
-        foreignTradeNumber: [
-          { required: true, message: "请输入外贸号", trigger: "blur" },
-        ],
-        canisterweight: [
+        // foreignTradeNumber: [
+        //   { required: true, message: "请输入外贸号", trigger: "blur" },
+        // ],
+        canisterWeight: [
           { required: true, message: "请选择筒重", trigger: "change" },
         ],
         boxWeight: [
           { required: true, message: "请选择箱重/车重", trigger: "change" },
         ],
-        tubecolor: [
+        tubeColor: [
           { required: true, message: "请选择管色", trigger: "change" },
         ],
         comPort: [{ required: true, message: "请选择端口", trigger: "change" }],
@@ -793,9 +834,109 @@ export default {
   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);
+          }
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
+  },
   methods: {
+    // 删除表格一条数据回调
+    handleDeleteOne(index) {
+      this.tableData.splice(index, 1);
+    },
+    // 确认打印回调
+    printConfirmHandler() {
+      if (this.tableData.length == 0) {
+        this.$message.warning("请添加打印的数据");
+        return;
+      }
+
+      console.log("打印", this.tableData);
+      codeListPrint(this.tableData, "printDom");
+    },
+    // 获取机台选项数据
+    async getLineOptionLsit() {
+      let payLoad = {
+        isEnablePaging: false,
+      };
+      try {
+        let res = await getLineOptionLsit(payLoad);
+        if (res.code == 200) {
+          this.lineOptions = res.rows;
+          console.log(this.lineOptions);
+        } else {
+          console.log(res);
+        }
+      } catch (error) {
+        console.error(error);
+      }
+    },
     // 获取箱单数据
-    getOrderData() {
+    async getOrderData() {
+      // let year = (new Date().getFullYear() + "").slice(-2);
+      // let month = new Date().getMonth() + 1;
+      // if (month < 10) {
+      //   month = "0" + month;
+      // }
+      // let day = new Date().getDate();
+      // if (day < 10) {
+      //   day = "0" + day;
+      // }
+      // let timeStamp = (new Date().getTime() + "").slice(-5);
+      // this.orderData.boxNo = year + month + day + timeStamp;
+      this.$refs.form.validate(async (valid) => {
+        if (valid) {
+          try {
+            let { sumBoxNum, sumCanisterNum, sumSuttle, sumGrossWeight } =
+              this.count;
+            let rowData = this.tableData[0];
+            let payLoad = {
+              ...this.form,
+              qrCode: rowData.qrCode,
+              lotNum: rowData.lotNum,
+              boxNum: sumBoxNum,
+              productId: rowData.productId,
+              cartonNumber: sumCanisterNum,
+              suttle: sumSuttle,
+              grossWeight: sumGrossWeight,
+            };
+            let res = await productCodeList(payLoad);
+            if (res.code == 200) {
+              this.$message.success("保存箱单成功");
+            } else {
+              console.log(res);
+              this.$message.error("保存箱单失败");
+            }
+          } catch (error) {
+            console.error(error);
+          }
+        }
+      });
+    },
+    // 箱单号生成函数
+    getBoxOrderNum() {
       let year = (new Date().getFullYear() + "").slice(-2);
       let month = new Date().getMonth() + 1;
       if (month < 10) {
@@ -806,7 +947,7 @@ export default {
         day = "0" + day;
       }
       let timeStamp = (new Date().getTime() + "").slice(-5);
-      this.orderData.boxNo = year + month + day + timeStamp;
+      return year + month + day + timeStamp;
     },
     // 包装变化回调
     packagingChange(val) {
@@ -824,26 +965,47 @@ export default {
           let {
             machineTool,
             boxWeight,
-            canisterweight,
+            canisterWeight,
             canisterNum,
             grossWeight,
             suttle, //净重
             workShifts, //班次
-            tubecolor,
+            tubeColor,
+            productionDate,
+            printFormat,
+            levels,
+            remark,
           } = this.form;
           console.log(this.currentRow);
+          let {
+            productName,
+            productSpecifications,
+            productColor,
+            lotNum,
+            directionOfTwist,
+            productId,
+          } = this.currentRow;
           this.tableData.push({
-            qrCode: this.tableData.length + 1,
+            qrCode: this.getBoxOrderNum(), //箱单号
+            levels,
             machineTool,
             boxWeight,
-            canisterweight,
+            canisterWeight,
             canisterNum,
-            grossWeight,
-            suttle,
             workShifts,
-            tubecolor,
+            tubeColor,
             grossWeight: 0, //毛重
             suttle: this.getSuttle(), //净重
+            myNO: this.tableData.length + 1, //序号
+            productionDate, //日期
+            printFormat, //格式
+            productName,
+            productSpecifications,
+            productColor,
+            lotNum,
+            directionOfTwist, //捻向
+            remark,
+            productId,
           });
         } else {
           console.log("error submit!!");
@@ -853,8 +1015,8 @@ export default {
     },
     // 计算净重
     getSuttle() {
-      let { boxWeight, canisterweight, canisterNum } = this.form;
-      return (Number(boxWeight) - canisterweight * canisterNum).toFixed(2);
+      let { boxWeight, canisterWeight, canisterNum } = this.form;
+      return (Number(boxWeight) - canisterWeight * canisterNum).toFixed(2);
     },
     // 表格点击回调
     handleCurrentChange(val) {
@@ -867,6 +1029,7 @@ export default {
         let res = await finishedProductList();
         if (res.code == 200) {
           this.batchData = res.data;
+          this.batchTableData = res.data;
         } else {
           console.log(res);
         }
@@ -875,11 +1038,14 @@ export default {
       }
     },
     // 批号查询接口
-    batchNumChange(val) {
+    batchNumChange() {
+      if (!this.batchNum) {
+        this.batchTableData = this.batchData;
+        return;
+      }
       this.batchTableData = this.batchData.filter(
-        (item) => item.lotNum && item.lotNum.includes(val)
+        (item) => item.lotNum && item.lotNum.includes(this.batchNum)
       );
-      console.log(this.batchTableData);
     },
     // 获取下拉数据
     async getSelectOptions() {
@@ -966,6 +1132,7 @@ export default {
     async printHandler() {
       this.reset();
       await this.getAllBatchData(); //获取所有产品数据
+      await this.getLineOptionLsit(); //获取机台选项数据
       await this.getSelectOptions();
       this.printShow = true;
     },

+ 64 - 0
zkqy-ui/src/views/orderMange/codeListManage/test.html

@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+</head>
+
+<body>
+  <div style="width: 800px;position: relative;">
+
+    <div style="width: 100%;position: relative;text-align: center;">
+      <span style="font-size: 24px;font-weight: 500;">诸暨市新丝维化纤有限公司</span>
+    </div>
+    <div style="width: 100%;display: flex;justify-content: center;margin:5px 0;">
+      <div style="width: 120px;height: 120px;background-color: aqua;"></div>
+    </div>
+    <table style="width: 100%;border-collapse:collapse;" cellpadding="10" border="1">
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">品种</td>
+        <td style="width: 300px;">BTS高弹单丝轻网</td>
+        <td style="width: 100px;" colspan="1">规格</td>
+        <td style="width: 300px;" colspan="2">100D/36f</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">批号</td>
+        <td style="width: 300px;">23-0</td>
+        <td style="width: 100px;" colspan="1">色号</td>
+        <td style="width: 300px;" colspan="2">001特黑</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">等级</td>
+        <td style="width: 300px;">AA</td>
+        <td style="width: 100px;" colspan="1">箱号</td>
+        <td style="width: 250px;" colspan="1">23092802001</td>
+        <td style="width: 50px;" colspan="1">1</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">筒数</td>
+        <td style="width: 300px;">2&ensp;&ensp;&ensp;纸管</td>
+        <td style="width: 100px;" colspan="1">捻向</td>
+        <td style="width: 300px;" colspan="2"></td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">班次</td>
+        <td style="width: 300px;">扬隆&ensp;&ensp;&ensp;B01</td>
+        <td style="width: 100px;" colspan="1">日期</td>
+        <td style="width: 300px;" colspan="2">2023-09-28</td>
+      </tr>
+      <tr style="text-align: center;">
+        <td style="width: 100px;" colspan="1">毛重</td>
+        <td style="width: 300px;">20.00</td>
+        <td style="width: 100px;" colspan="1">净重</td>
+        <td style="width: 300px;font-size: 20px;font-weight: 500;" colspan="2">18.20</td>
+      </tr>
+    </table>
+    <div style="display: flex;flex-direction: row-reverse;">
+      <span>注:不同批号,请勿混用</span>
+    </div>
+  </div>
+</body>
+
+</html>

+ 4 - 4
zkqy-ui/src/views/tablelist/commonTable/listInfo.vue

@@ -60,13 +60,13 @@
     />
     <el-row :gutter="10" class="mb8">
       <!-- 按钮行 start -->
-      <btn-menu-list
+      <!-- <btn-menu-list
         @topBtnHandler="topBtnHandler"
         :topBtnArr="topBtnArr"
         :selection="selection"
-      ></btn-menu-list>
+      ></btn-menu-list> -->
       <!-- 按钮行 end -->
-      <!-- <el-col :span="1.5">
+      <el-col :span="1.5">
         <el-button
           type="primary"
           plain
@@ -116,7 +116,7 @@
           @click="handleExport"
           >导出
         </el-button>
-      </el-col> -->
+      </el-col>
       <right-toolbar
         :showCount.sync="showCount"
         :showSearch.sync="showSearch"