Browse Source

提交代码

zyf 2 years ago
parent
commit
d4e3ac4bc1
2 changed files with 132 additions and 112 deletions
  1. 81 73
      src/views/index/components/printReceipt.vue
  2. 51 39
      src/views/index/components/printScan.vue

+ 81 - 73
src/views/index/components/printReceipt.vue

@@ -1,5 +1,19 @@
 <template>
   <div class="tableAllDate">
+    <div class="button-box">
+      <el-button
+        type="primary"
+        @click="print1()"
+        v-print="'#pdfDom1'"
+        style="width: 500px;height: 120px;font-size: 100px"
+        id="printReceipt"
+        v-show="false"
+      >
+        <!--class="el-icon-printer"-->
+        <!---->
+        打印
+      </el-button>
+    </div>
     <div id="pdfDom1">
       <div id="pdfDom" v-for="(item, index) in dataList" :key="index">
         <div class="blank"></div>
@@ -200,111 +214,105 @@
 </template>
 
 <script>
-import table from "@/components/DilCommonUI/packages/table/src/table.vue";
+import table from '@/components/DilCommonUI/packages/table/src/table.vue'
 export default {
   components: { table },
-  name: "Login",
+  name: 'Login',
   data() {
     return {
-      orderNumber: "",
-      consignee: "",
-      town: "",
-      consigneeTel: "",
-      sendDate: "",
-      receiptDate: "",
-      consigeeName: "",
-      saleNo: "",
+      orderNumber: '',
+      consignee: '',
+      town: '',
+      consigneeTel: '',
+      sendDate: '',
+      receiptDate: '',
+      consigeeName: '',
+      saleNo: '',
       deliveryOrderMaterialList: [
         {
-          materialName: "",
-          materialSpe: "",
-          materialModel: "",
+          materialName: '',
+          materialSpe: '',
+          materialModel: '',
           materialNumber: 0,
           materialWeight: 0,
-          makeDate: ""
+          makeDate: ''
         }
       ],
-      carrierName: "",
-      province: "",
-      deliveryAddress: "",
-      district: "",
-      capacityNumber: "",
-      shippername: "",
+      carrierName: '',
+      province: '',
+      deliveryAddress: '',
+      district: '',
+      capacityNumber: '',
+      shippername: '',
       year: new Date().getFullYear(),
       month: new Date().getMonth() + 1,
       date: new Date().getDate(),
-      htmlTitle: "客户换票送货单",
-      note: "",
-      dataList: ["1", "2", "3"],
-      timer1: ""
-    };
+      htmlTitle: '客户换票送货单',
+      note: '',
+      dataList: ['1', '2', '3'],
+      timer1: ''
+    }
   },
   created() {
-    this.getDeliveryOrder();
+    this.getDeliveryOrder()
   },
   mounted() {
     /*this.timer1 = setTimeout(this.print,2000);*/
     // 六十秒不操作,自动返回扫码页面
     const timer = setInterval(() => {
-      this.print();
-      this.backScan();
-    }, 2000);
-    this.$once("hook:beforeDestroy", () => {
-      clearInterval(timer);
+
+      this.backScan()
+    }, 30000)
+    this.$once('hook:beforeDestroy', () => {
+      clearInterval(timer)
       /*clearTimeout(this.timer1)*/
-    });
+    })
   },
   methods: {
     getDeliveryOrder() {
-      const that = this;
-      let orderNumber = this.$route.query.orderNumber;
+      let orderNumber = this.$route.query.orderNumber
       this.axios
-        .post("/api/v1/tms/getDeliveryOrder?orderNumber=" + orderNumber)
+        .post('/api/v1/tms/getDeliveryOrder?orderNumber=' + orderNumber)
         .then(res => {
-          console.log(res);
-          this.orderNumber = res.data.orderNumber;
-          this.carrierName = res.data.carrierName;
-          this.capacityNumber = res.data.capacityNumber;
-          this.consigeeName = res.data.consigeeName;
-          this.consignee = res.data.consignee;
-          this.consigneeTel = res.data.consigneeTel;
-          this.sendDate = res.data.sendDate;
-          this.saleNo = res.data.saleNo;
-          console.log(this.saleNo);
-          this.shippername = res.data.shippername;
-          this.province = res.data.province;
-          this.district = res.data.district;
-          this.town = res.data.town;
-          this.deliveryAddress = res.data.deliveryAddress;
-          this.deliveryOrderMaterialList = res.data.deliveryOrderMaterialList;
-          this.note = res.data.note;
-          //that.print1();
-          /*document.body.innerHTML=oldstr*/
-        });
-
-    },
-    print() {
-      console.log("执行了打印");
-      //let newstr = document.getElementById("pdfDom1").innerHTML;
-      //let oldstr = document.body.innerHTML;
-      //document.body.innerHTML = newstr;
-      window.print();
-      /*document.body.innerHTML=oldstr*/
-      //let orderNumber = this.$route.query.orderNumber;
-      this.axios.post("/api/v1/tms/changeNumber?orderNumber=" + orderNumber);
-      this.backScan();
-      console.log("执行了返回")
+          console.log(res)
+          this.orderNumber = res.data.orderNumber
+          this.carrierName = res.data.carrierName
+          this.capacityNumber = res.data.capacityNumber
+          this.consigeeName = res.data.consigeeName
+          this.consignee = res.data.consignee
+          this.consigneeTel = res.data.consigneeTel
+          this.sendDate = res.data.sendDate
+          this.saleNo = res.data.saleNo
+          this.shippername = res.data.shippername
+          this.province = res.data.province
+          this.district = res.data.district
+          this.town = res.data.town
+          this.deliveryAddress = res.data.deliveryAddress
+          this.deliveryOrderMaterialList = res.data.deliveryOrderMaterialList
+          this.note = res.data.note
+          document.getElementById('printReceipt').click()
+        })
     },
+    // print() {
+    //   console.log('调用了吗')
+    //   let newstr = document.getElementById('pdfDom1').innerHTML
+    //   let oldstr = document.body.innerHTML
+    //   document.body.innerHTML = newstr
+    //   window.print()
+    //   /*document.body.innerHTML=oldstr*/
+    //   // let orderNumber = this.$route.query.orderNumber
+    //   // this.axios.post('/api/v1/tms/changeNumber?orderNumber=' + orderNumber)
+    // },
     print1() {
-      let orderNumber = this.$route.query.orderNumber;
-      this.axios.post("/api/v1/tms/changeNumber?orderNumber=" + orderNumber);
-      this.backScan();
+      let orderNumber = this.$route.query.orderNumber
+      this.axios.post('/api/v1/tms/changeNumber?orderNumber=' + orderNumber)
+      this.backScan()
     },
     backScan() {
-      this.$router.go(-1);
+      this.$router.go(-1)
     }
   }
-};
+}
 </script>
 
 <style lang="scss" scoped>

+ 51 - 39
src/views/index/components/printScan.vue

@@ -13,12 +13,15 @@
       >
       </el-input>
       <!--style="display:block;width:120px"-->
-      <div  v-show="false">
+      <div v-show="false">
         手动输入开关:
       </div>
 <!--      <i class="el-icon-full-screen" @click="fullScreen"
       v-show="edit1"></i>-->
 <!--      <el-switch
+=======
+      <i class="el-icon-full-screen" @click="fullScreen" v-show="edit1"></i>
+      <el-switch
         :disabled="!isEdit"
         v-show="false"
       >
@@ -38,22 +41,23 @@
       手机二维码对准下方摄像头<br>
       <i class="el-icon-bottom" style="padding-left: 450px;font-size: 300px;color: red"></i>
       <span style="width: 300px;height: 200px;color: red;margin-left: 50px">zyf:110</span>
+
     </div>
   </div>
 </template>
 <script>
-import screenfull from "screenfull";
+import screenfull from 'screenfull'
 export default {
   data() {
     return {
       orderNumber: null,
       isEdit: true,
       edit1: true,
-      backgroundImgURL: require("@/assets/saleSelfMachine/backgroundImg.jpg")
-    };
+      backgroundImgURL: require('@/assets/saleSelfMachine/backgroundImg.jpg')
+    }
   },
   created() {
-    this.changfouce();
+    this.changfouce()
   },
   // watch:{
   //    data:"toSaleSelfMachine"
@@ -62,13 +66,13 @@ export default {
     //输入框自动聚焦
     changfouce() {
       this.$nextTick(x => {
-        this.$refs.inputs.focus();
-      });
+        this.$refs.inputs.focus()
+      })
     },
     fullScreen() {
       if (screenfull.isEnabled && !screenfull.isFullscreen) {
-        screenfull.request();
-        this.edit1=false
+        screenfull.request()
+        this.edit1 = false
       }
     },
     /*async querynumber(){
@@ -90,21 +94,21 @@ export default {
       }
     },*/
     async querynumber() {
-      console.log(this.orderNumber);
-      let orderNumber = this.orderNumber;
-      let i = 0;
+      console.log(this.orderNumber)
+      let orderNumber = this.orderNumber
+      let i = 0
       await this.axios
-        .post("/api/v1/tms/queryNumber?orderNumber=" + orderNumber)
+        .post('/api/v1/tms/queryNumber?orderNumber=' + orderNumber)
         .then(res => {
-          console.log("查找出来的数据");
-          console.log(res.data);
-          console.log("-------------------------");
+          console.log('查找出来的数据')
+          console.log(res.data)
+          console.log('-------------------------')
           if (res.data.printnumber == 1) {
-            i = 1;
+            i = 1
           }
-        });
-      console.log(i);
-      return i;
+        })
+      console.log(i)
+      return i
     }
     //失去焦点后自动执行获得焦点事件
     // onInputBlur(){
@@ -118,39 +122,47 @@ export default {
     // }
   },
   mounted() {
-    console.log(screenfull.isFullscreen);
+    console.log(screenfull.isFullscreen)
     // this.changfouce();
     const timer = setInterval(async () => {
       // if(this.$refs.inputs.focus==false){
       //     console.log("false")
-      this.changfouce();
+      this.changfouce()
       //}
-      if (this.orderNumber != null && this.orderNumber.length == 21) {
+      if (
+        this.orderNumber != null &&
+        this.orderNumber != '' &&
+        this.orderNumber.length == 21
+      ) {
         if (
-          this.orderNumber.startsWith("WYSDD") == true ||
-          this.orderNumber.startsWith("wysdd") == true
+          this.orderNumber.startsWith('WYSDD') == true ||
+          this.orderNumber.startsWith('wysdd') == true
         ) {
-          let promise = await this.querynumber(this.orderNumber);
+          let promise = await this.querynumber(this.orderNumber)
           console.log(promise)
-          if (promise==1){
-            this.$message.error("你已经打印过了")
-            this.orderNumber=null
+          if (promise == 1) {
+            this.$message.error('你已经打印过了')
+            this.orderNumber = null
             return
           }
           this.$router.push({
-            path: "/printReceipt?orderNumber=" + this.orderNumber
-          });
+            path: '/printReceipt?orderNumber=' + this.orderNumber
+          })
         }
-      } else if (this.orderNumber.length > 21) {
+      } else if (
+        this.orderNumber != null &&
+        this.orderNumber != '' &&
+        this.orderNumber.length > 21
+      ) {
         //清空输入框,免得一次多个重复订单还无法删除
-        this.orderNumber = null;
+        this.orderNumber = null
       }
-    }, 1000);
-    this.$once("hook:beforeDestroy", () => {
-      clearInterval(timer);
-    });
+    }, 1000)
+    this.$once('hook:beforeDestroy', () => {
+      clearInterval(timer)
+    })
   }
-};
+}
 </script>
 <style lang="scss">
 .saleSelfMachine {
@@ -172,7 +184,7 @@ export default {
     justify-content: center;
     align-items: center;
   }
-  .tip{
+  .tip {
     width: 1800px;
     height: 600px;
     font-size: 100px;