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

二维码列表和入库单打印工具函数

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

+ 1 - 0
zkqy-ui/package.json

@@ -78,6 +78,7 @@
     "monaco-editor": "^0.30.1",
     "monaco-editor-webpack-plugin": "^6.0.0",
     "nprogress": "0.2.0",
+    "qrcodejs2": "^0.0.2",
     "quill": "1.3.7",
     "screenfull": "5.0.2",
     "sortablejs": "1.10.2",

+ 61 - 0
zkqy-ui/src/utils/print/qrCodeList.js

@@ -0,0 +1,61 @@
+import moment from 'moment'
+import QRCode from 'qrcodejs2'
+import { v4 as uuidv4 } from "uuid";
+
+function qrCodeList(data, domId) {
+  const NUM = 3
+  let tempData = {
+    goodsName: '货品名称',
+    specifications: '规格'
+  }
+  let goodsname = "名称:" + tempData.goodsName;
+  let specifications = "规格:" + tempData.specifications;
+  let goodstime = "生产日期:" + moment(new Date()).format('YYYY-MM-DD');
+  let printContent = `<div><table><tr><td >`;
+  for (var i = 0; i < NUM; i++) {
+    printContent +=
+      `<div style="width: 840px; height:100px;background-color: skyblue;"><div id="HT` +
+      i +
+      `" style="float: left;margin-top: 15px; border-right: 10px white solid"></div>`;
+    printContent +=
+      `<div id="LJJ` +
+      i +
+      `" style="float: left;margin-top: 5px;">
+                <h1><strong>${goodsname}</strong></h1>
+                <h1><strong>${specifications}</strong></h1>
+              </div></div>
+              <div style="clear: both"></div>`;
+  }
+  printContent += `</td></tr></table></div>`;
+  document.body.innerHTML = document.getElementById(domId).innerHTML = printContent;
+  for (var i = 0; i < NUM; i++) {
+    for (let j = 0; j < 1; j++) {
+      new QRCode(document.getElementById("HT" + i), {
+        text:
+          sleep(1) +
+          "no=" +
+          tempData.goodsno +
+          "no=" +
+          uuidv4(),
+        width: 120,
+        height: 120,
+        colorDark: "#000000",
+        colorLight: "#ffffff",
+        correctLevel: QRCode.CorrectLevel.H,
+      });
+    }
+  }
+  window.print(); //打印
+  window.location.reload();
+  this.getGoods();
+  return false;
+}
+// 延迟
+function sleep(ms) {
+  var unixtime_ms = new Date().getTime();
+  while (new Date().getTime() < unixtime_ms + ms) { }
+  return "";
+}
+
+
+export default qrCodeList

+ 139 - 0
zkqy-ui/src/utils/print/receiptDocuments.js

@@ -0,0 +1,139 @@
+function receiptDocuments(data, domId) {
+  let yy = new Date().getFullYear();
+  let mm = new Date().getMonth() + 1;
+  let dd = new Date().getDate();
+  let printContent = `<div style="width: 818px;position: relative;">
+    <span style="position: absolute;right: 0;top:60px;writing-mode:vertical-lr;transform: translateX(110%);">一联存根(白)
+      二联客户(红)
+      三联记账(蓝)</span>
+    <div style="width: 818px;position: relative;text-align: center;">
+      <h1 style="display: inline;"><span style="text-decoration: underline;">中科擎云</span>有限公司入库单</h1>
+      <span style="position: absolute; right: 0;bottom: 0;font-size: 20px;">No:<span
+          style="color: red;">0006211</span></span>
+    </div>
+    <div style="width: 818px;position: relative;">
+      <span style="margin-left: 20px;">单位:<span style="margin-left: 5px;">中科擎云智能技术有限公司</span></span>
+      <span style="position: absolute;right: 20px;"><span>${yy}</span>年<span>${mm}</span>月<span>${dd}</span>日</span>
+    </div>
+    <table style="width: 818px;height:100px;border-collapse:collapse;" border="1">
+      <tr style="text-align: center">
+        <td>物资名称</td>
+        <td>单位</td>
+        <td>规格及代号</td>
+        <td>数量</td>
+        <td>单价</td>
+        <td>金额</td>
+        <td>备注</td>
+      </tr>`;
+  let tempData = [
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+    {
+      goodsName: '物资名称',
+      unit: '单位',
+      specification: '规格及代号',
+      quantity: '数量',
+      price: '单价',
+      amount: '金额',
+      remark: '备注'
+    },
+  ]
+  for (let i = 0; i < tempData.length; i++) {
+    printContent += `<tr style="text-align: center">
+      <td>${tempData[i].goodsName + `${i + 1}`}</td>
+      <td>${tempData[i].unit}</td>
+      <td>${tempData[i].specification}</td>
+      <td>${tempData[i].quantity}</td>
+      <td>${tempData[i].price}</td>
+      <td>${tempData[i].amount}</td>
+      <td>${tempData[i].remark}</td>
+      </tr>`
+  }
+  printContent += `<td colspan="7">&nbsp;&nbsp;用 途 <span
+          style="margin-left: 10px;text-wrap: wrap;">内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊内容啊啊啊啊啊啊</span>
+      </td>
+      </tr>
+    </table>
+    <div style="width: 100%;display: flex;justify-content: space-around;margin-top: 5px;">
+      <span style="width: 30%;">批准:</span>
+      <span style="width: 30%;">交料人:</span>
+      <span style="width: 30%;">仓管员:</span>
+    </div>
+  </div>`
+  document.body.innerHTML = document.getElementById(domId).innerHTML = printContent;
+  window.print(); //打印
+  window.location.reload();
+  return false;
+
+}
+export default receiptDocuments