From 391c4168a4f6a531aaa2a913c83df4f264d8f439 Mon Sep 17 00:00:00 2001
From: admin <15939171744@163.com>
Date: 星期二, 06 八月 2024 19:54:55 +0800
Subject: [PATCH] -打印bug修改

---
 jcdm-ui/package.json                                |    1 
 jcdm-ui/src/views/main/kb/stationTerminal/index.vue |  107 +++++++++++++++++++++++++++++++++--------------------
 jcdm-ui/src/main.js                                 |    2 +
 3 files changed, 70 insertions(+), 40 deletions(-)

diff --git a/jcdm-ui/package.json b/jcdm-ui/package.json
index 887cea5..0c32cf7 100644
--- a/jcdm-ui/package.json
+++ b/jcdm-ui/package.json
@@ -57,6 +57,7 @@
     "vue-count-to": "1.0.13",
     "vue-cropper": "0.5.5",
     "vue-meta": "2.4.0",
+    "vue-print-nb": "^1.7.5",
     "vue-router": "3.4.9",
     "vuedraggable": "2.24.3",
     "vuex": "3.6.0"
diff --git a/jcdm-ui/src/main.js b/jcdm-ui/src/main.js
index aea3622..4c2d886 100644
--- a/jcdm-ui/src/main.js
+++ b/jcdm-ui/src/main.js
@@ -38,6 +38,7 @@
 // 瀛楀吀鏁版嵁缁勪欢
 import DictData from '@/components/DictData'
 import './router/directives.js';
+import Print from 'vue-print-nb';
 
 // 鍏ㄥ眬鏂规硶鎸傝浇
 Vue.prototype.getDicts = getDicts
@@ -62,6 +63,7 @@
 Vue.use(directive)
 Vue.use(plugins)
 Vue.use(VueMeta)
+Vue.use(Print);
 DictData.install()
 
 /**
diff --git a/jcdm-ui/src/views/main/kb/stationTerminal/index.vue b/jcdm-ui/src/views/main/kb/stationTerminal/index.vue
index b83c9ac..a8b1c55 100644
--- a/jcdm-ui/src/views/main/kb/stationTerminal/index.vue
+++ b/jcdm-ui/src/views/main/kb/stationTerminal/index.vue
@@ -91,42 +91,44 @@
                <div ref="canvasWrapper" id="canvasWrapper3" style="display: flex;justify-content: center;"></div>
                <p style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;">{{packCode}}</p>
              </div>
-             <el-button @click="print">鎵撳嵃</el-button>
+<!--             <el-button @click="print">鎵撳嵃</el-button>-->
              <el-button @click="test1">鐢熸垚浜岀淮鐮�</el-button>
            </div>
          </el-row>
 
          <el-row v-show="offlineFlag" style="margin-top: 20px">
-           <el-button @click="print1" type="primary">鎵撳嵃涓夎仈鐮�</el-button>
+           <el-button id="print" v-print="'#printMe'" type="primary">鎵撳嵃涓夎仈鐮�</el-button>
            <el-button style="display: none" @click="test1">鐢熸垚浜岀淮鐮�</el-button>
-           <el-button style="display: none" @click="test2">鐢熸垚浜岀淮鐮�</el-button>
-           <div>
-             <div style="display: none" id="printMe">
+           <el-button style="display: none" @click="test2">鐢熸垚
+             <span style="font-size: 10px;margin-left: 52px">MADE IN CHINA</span><br>
+             <br>
+             <br>浜岀淮鐮�</el-button>
+           <div style="display: none">
+             <div  id="printMe">
                <br>
-               <p style="margin-left: 43px">{{printInfoData.partNumber}}</p>
-               <p style="margin-left: 43px">{{printInfoData.hardwareVersion}}</p>
-               <p style="margin-left: 43px">{{printInfoData.softwareVersion}}</p>
+               <p style="margin-left: 53px">{{printInfoData.partNumber}}</p>
+               <p style="margin-left: 53px">{{printInfoData.hardwareVersion}}</p>
+               <p style="margin-left: 53px">{{printInfoData.softwareVersion}}</p>
                <br>
                <br>
-               <!--                  <span style="font-size: 30px;font-weight: bold;margin-left: 40px;">GEELY</span><br>-->
-               <img style="width: 140px;height: 20px;margin-left: 25px" :src="require('@/assets/images/a8963a24920640508e96150a053fc41.png')">
-               <span style="margin-left: 60px">{{printInfoData.printModel}}</span><br>
-               <span style="margin-left: 63px">{{printInfoData.supplierCode}}</span><br>
-               <span style="margin-left: 40px">{{printInfoData.partNumber}}</span><br>
-               <span style="font-size: 10px;margin-left: 17px;">{{headContent.sfcCode}}</span><br>
-               <span style="font-size: 10px;margin-left: 52px">MADE IN CHINA</span><br>
+               <br>
+               <br>
+               <img style="width: 140px;height: 20px;margin-left: 30px" :src="require('@/assets/images/a8963a24920640508e96150a053fc41.png')"/>
+               <span style="margin-left: 72px">{{printInfoData.printModel}}</span><br>
+               <span style="margin-left: 75px">{{printInfoData.supplierCode}}</span><br>
+               <span style="margin-left: 52px">{{printInfoData.partNumber}}</span><br>
+               <span style="font-size: 10px;margin-left: 29px;">{{headContent.sfcCode}}</span><br>
                <br>
                <br>
                <br>
                <div ref="canvasWrapper" id="canvasWrapper1" style="display: flex;justify-content: center;margin-top: -27px;"></div>
-               <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 9px">P{{printInfoData.partNumber}}#T{{headContent.sfcCode}}#V{{printInfoData.supplierCode}}#S{{printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>
-               <!--                  <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 9px">P{{printInfoData.partNumber}}#T{{text1}}#V{{printInfoData.supplierCode}}#S{{// printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>-->
+               <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 20px">P{{printInfoData.partNumber}}#T{{headContent.sfcCode}}#V{{printInfoData.supplierCode}}#S{{printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>
                <br>
                <br>
                <div ref="canvasWrapper" id="canvasWrapper2" style="display: flex;justify-content: center;margin-top: -27px"></div>
-               <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 9px">P{{printInfoData.partNumber}}#T{{headContent.sfcCode}}#V{{printInfoData.supplierCode}}#S{{printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>
-               <!--                  <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 9px">P{{printInfoData.partNumber}}#T{{text1}}#V{{printInfoData.supplierCode}}#S{{// printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>-->
+               <span style="font-size: 10px;word-break: break-all;display: flex;justify-content: center;width: 155px;margin-left: 20px">P{{printInfoData.partNumber}}#T{{headContent.sfcCode}}#V{{printInfoData.supplierCode}}#S{{printInfoData.softwareVersion}}#H{{printInfoData.hardwareVersion}}#NBMS#</span>
              </div>
+           </div>
          </el-row>
        </el-card>
 
@@ -327,6 +329,7 @@
   replaceAssemblyCode, checkRecordDataDone, enterWeighing,
 } from "@/api/main/da/paramCollection/paramCollection";
 import QRCode from "qrcodejs2";
+import {listEquipmentArchives} from "@/api/main/em/equipmentArchives/equipmentArchives";
 
 export default {
   name: "stationTerminal",
@@ -395,8 +398,8 @@
       content: '',
       activeName: 'first',
       // url: "ws://192.168.2.248:8080/websocket/message/",
-      // url: "ws://10.103.210.248:8080/websocket/message/",
-      url: "ws://192.168.2.76:8080/websocket/message/",
+      url: "ws://10.103.210.248:8080/websocket/message/",
+      // url: "ws://192.168.2.76:8080/websocket/message/",
       message: "",
       text_content: "",
       ws: null,
@@ -427,8 +430,7 @@
       originalArray: [],
       yzSfcFlag: 1,
       endYz: false,
-      packCode: 'test111',
-
+      packCode: 'test111'
     }
   },
   beforeDestroy() {
@@ -462,7 +464,7 @@
   computed: {
     isDisable() {
       return this.btnType === "danger";
-    },
+    }
   },
   methods: {
 
@@ -504,6 +506,16 @@
     //鎺ユ敹宸ュ崟-------缁撴潫
 
     //涓嬬嚎鎵撳嵃-------寮�濮�
+    initializePrintInfoData(){
+      listEquipmentArchives().then(response => {
+        this.printInfoData.softwareVersion = response.rows[0].equipmentCode
+        this.printInfoData.hardwareVersion = response.rows[0].equipmentName
+        this.printInfoData.supplierCode = response.rows[0].equipmentSpec
+        this.printInfoData.printModel = response.rows[0].equipmentBrand
+        this.printInfoData.partNumber = response.rows[0].equipmentTypeName
+        console.log(response.rows[0])
+      });
+    },
     test1(){
       document.getElementById('canvasWrapper1').innerHTML = '';
       this.$nextTick(() => {
@@ -531,20 +543,30 @@
       )
     },
     print1() {
-      if(this.headContent.sfcCode!==''&&this.headContent.sfcCode!==null){
-        // 鏂板紑椤甸潰鎵撳嵃
-        let newStr = document.getElementById('printMe').innerHTML;
-        const printFrame = document.createElement('iframe');
-        printFrame.style.display = 'none';
-        document.body.appendChild(printFrame);
-        const content = document.getElementById('printMe').innerHTML;
-        printFrame.contentDocument.write(content);
-        printFrame.contentWindow.print();
-        document.body.removeChild(printFrame);
-        return false;
-      }else {
-        this.$message.error('鏈壂鎻忔�绘垚鐮佺姝㈡墦鍗帮紒');
-      }
+      // 浣跨敤鎻掍欢鎵撳嵃鏂瑰紡
+      // this.$print(this.$refs.printMe)
+      // this.initializePrintInfoData()
+      // if(this.headContent.sfcCode){
+      //   //鏂伴〉闈㈡墦鍗�
+      //   // let newStr = document.getElementById('printMe').innerHTML;
+      //   // let newWin = window.open('', '_blank',st);
+      //   // newWin.document.body.innerHTML = newStr;
+      //   // newWin.print();
+      //   // 鏈〉闈㈡墦鍗�
+      //   let newStr = document.getElementById('printMe').innerHTML;
+      //   const printFrame = document.createElement('iframe');
+      //   printFrame.style.display = 'none';
+      //   document.body.appendChild(printFrame);
+      //   const content = document.getElementById('printMe').innerHTML;
+      //   printFrame.contentDocument.write(content);
+      //   printFrame.contentWindow.print();
+      //   console.log(printFrame)
+      //   // document.body.removeChild(printFrame);
+      //   console.log(printFrame)
+      //   return false;
+      // }else {
+      //   this.$message.error('鏈壂鎻忔�绘垚鐮佺姝㈡墦鍗帮紒');
+      // }
     },
     //涓嬬嚎鎵撳嵃-------鎴
     bindcardCode(scanValue){
@@ -693,6 +715,7 @@
     },
     /** 鏌ヨ宸ュ崟鍒楄〃 */
     async getList() {
+      this.initializePrintInfoData()
       await listProductionOrde(this.queryParams).then(response => {
         let rowsData = response.rows[0];
         console.log(rowsData)
@@ -798,11 +821,15 @@
       this.ws = new WebSocket(wsuri);
       const self = this;
       this.ws.onopen = function (event) {
-        this.$message('websocket杩炴帴鎴愬姛锛�');
+        self.$message('websocket杩炴帴鎴愬姛锛�');
 
       };
       this.ws.onmessage = function (event) {
-        if (event.data === "IN") {
+        if (event.data === "print") {
+          self.$message('postman璋冪敤鎵撳嵃鏂规硶鎵撳嵃锛�');
+          // self.print1()
+          document.getElementById('print').click();
+        }else if (event.data === "IN") {
           self.cakeLamp.InPlace = 1;
         } else if (event.data === "NG") {
           //缁檖lc鍙戜笅绾夸俊鍙�

--
Gitblit v1.9.3