Explorar el Código

执行人工号校验

quwangxin hace 2 años
padre
commit
290f9fbdb9

+ 1 - 0
src/components/print/OrderPrint.vue

@@ -825,6 +825,7 @@
       height: $heihgt;
       border-right: $border;
       border-bottom: $border;
+      padding-left: 10px;
     }
     .code {
       line-height: 2 * $heihgt;

+ 44 - 65
src/utils/pdf.js

@@ -1,77 +1,56 @@
 import html2canvas from 'html2canvas';
 import jsPDF from 'jspdf';
 
-const ratio = 2.5; //放大 兼容低分辨率屏幕清晰度
-let pdf = null;
-export const downloadPDF = (page, direction) => {
+const ratio = 1; //放大 兼容低分辨率屏幕清晰度
+
+const margin = 10; //边距
+// A4宽高
+const a4Width = 595.28;
+const a4Height = 841.89;
+// let pdf = null;
+export const downloadPDF = (page, fileName = '工单') => {
   // direction : 方向
   return new Promise((resolve, reject) => {
-    let canvasList = [];
-    async function fn () {
-      await html2canvas(page, { scale: ratio }).then(function (canvas) {
-        canvasList.push(canvas);
-      });
-      canvasList.forEach((n) => {
-        canvas2PDF(n, direction);
-      });
-      pdf.save('条码.pdf');
+    html2canvas(page, { scale: ratio }).then(function (canvas) {
+      var contentWidth = canvas.width;
+      var contentHeight = canvas.height;
+
+      //一页pdf显示html页面生成的canvas高度;
+      var pageHeight = (contentWidth / a4Width) * a4Height;
+      //未生成pdf的html页面高度
+      var leftHeight = contentHeight;
+      //页面偏移
+      var position = 10;
+      //a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高
+      var imgWidth = a4Width - margin * 2;
+      var imgHeight = (imgWidth / contentWidth) * contentHeight;
+
+      var pageData = canvas.toDataURL('image/jpeg', 1.0);
+
+      var pdf = new jsPDF('', 'pt', 'a4');
+
+      //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89)
+      //当内容未超过pdf一页显示的范围,无需分页
+      if (leftHeight < pageHeight) {
+        pdf.addImage(pageData, 'JPEG', margin, position, imgWidth, imgHeight);
+      } else {
+        while (leftHeight > 0) {
+          pdf.addImage(pageData, 'JPEG', margin, position, imgWidth, imgHeight);
+          leftHeight -= pageHeight;
+          position -= a4Height;
+          //避免添加空白页
+          if (leftHeight > 0) {
+            pdf.addPage();
+          }
+        }
+      }
+
+      pdf.save(`${fileName}.pdf`);
       const blob = pdf.output('blob');
       var blob_url = URL.createObjectURL(blob);
       window.open(blob_url);
       pdf = null;
       resolve();
-    }
-    fn();
+    });
   });
 };
-
-const canvas2PDF = (canvas, direction = 'l') => {
-  // direction : 方向
-  let contentWidth = canvas.width;
-  let contentHeight = canvas.height;
-  let imgWidth = prasePxToCm(contentWidth);
-  let imgHeight = prasePxToCm(contentHeight);
-  // 第一个参数: l:横向  p:纵向
-  // 第二个参数:测量单位("pt","mm", "cm", "m", "in" or "px")
-  if (!pdf) {
-    pdf = new jsPDF(direction, 'cm', [imgWidth, imgHeight]);
-    pdf.addImage(
-      canvas.toDataURL('image/jpeg', 1.0),
-      'JPEG',
-      0,
-      0,
-      imgWidth,
-      imgHeight
-    );
-  } else {
-    pdf.addPage();
-    pdf.addImage(
-      canvas.toDataURL('image/jpeg', 1.0),
-      'JPEG',
-      0,
-      0,
-      imgWidth,
-      imgHeight
-    );
-  }
-};
-function prasePxToCm (px) {
-  var targetEleWidth = 1,
-    cm;
-  var createEle = document.createElement('input');
-  var body = document.getElementsByTagName('body');
-  createEle.setAttribute(
-    'style',
-    'width:1cm !important;height:1cm !important;border-width:0px !important;padding:0px !important;margin:10px !important;'
-  );
-  createEle.id = 'elementId_' + new Date().getTime();
-  createEle.type = 'hidden';
-  body[0].appendChild(createEle);
-  var targetEle = document.getElementById(createEle.id);
-  targetEleWidth = window
-    .getComputedStyle(targetEle)
-    .width.match(/^\d+\.?\d*/)[0];
-  cm = px / targetEleWidth / ratio;
-  targetEle.parentNode.removeChild(targetEle);
-  return cm.toFixed(3);
-}

+ 1 - 1
src/views/produceOrder/components/report/Common.vue

@@ -28,7 +28,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 1
src/views/produceOrder/components/report/Drying.vue

@@ -29,7 +29,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 1
src/views/produceOrder/components/report/Extrusion.vue

@@ -24,7 +24,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 1
src/views/produceOrder/components/report/Furnace.vue

@@ -18,7 +18,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 1
src/views/produceOrder/components/report/HalfAdded.vue

@@ -28,7 +28,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 1
src/views/produceOrder/components/report/Heating.vue

@@ -28,7 +28,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 1
src/views/produceOrder/components/report/Package.vue

@@ -27,7 +27,7 @@
       <div class="right">
         <el-form-item
           label="执行人工号"
-          prop="executorJobNum"
+          prop="executorId"
           required
           label-width="100px"
           ><personSelectRemote

+ 1 - 4
src/views/produceOrder/components/report/Warehousing.vue

@@ -9,10 +9,7 @@
     <div class="message-box">
       <ul>
         <li> <span class="label">报工次数</span>{{ countMsg.reportNum }}</li>
-        <li>
-          <span class="label">批次数量</span
-          >{{ countMsg.inStoreBatchNum }}PCS</li
-        >
+        <li> <span class="label">批次数量</span>{{ countMsg.reportNum }}</li>
         <li>
           <span class="label">累计入库数量</span
           >{{ countMsg.inStoreNum }}PCS</li

+ 2 - 2
vue.config.js

@@ -31,12 +31,12 @@ module.exports = {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
-        // target: 'http://192.168.3.51:18086', // 测试
+        target: 'http://192.168.3.51:18086', // 测试
 
         // target: 'http://192.168.3.35:8080', // kang杨威
         // target: 'http://192.168.3.25:8080', // 黄峥嵘
         // target: 'http://192.168.3.41:8080', // 何江鹏
-        target: 'http://192.168.3.33:8080', // 谢一平
+        // target: 'http://192.168.3.33:8080', // 谢一平
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {