From 7e460156de73171f9660ce48f80703e79f8b478d Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期六, 14 六月 2025 11:48:26 +0800
Subject: [PATCH] 初始化提交

---
 src/views/add_operation/barcode/index.vue |  158 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 155 insertions(+), 3 deletions(-)

diff --git a/src/views/add_operation/barcode/index.vue b/src/views/add_operation/barcode/index.vue
index b78441d..68fa86b 100644
--- a/src/views/add_operation/barcode/index.vue
+++ b/src/views/add_operation/barcode/index.vue
@@ -1,15 +1,167 @@
 <template>
   <div class="barcode">
-    鏉$爜鎵撳嵃
+<!--缁戝畾id鏂规硶-->
+<!-- <div id='box'>
+   <p>鎵撳嵃鍐呭</p>
+</div>
+<div v-print='#box'>鎵撳嵃</div> -->
+<!--缁戝畾瀵硅薄鏂规硶-->
+<div id='printMe'>
+  <vue-barcode
+  :value="value"
+  >涓嶆敮鎸乿ue-barcode</vue-barcode>
+   <div>
+    <div>浜у搧鍚嶇О</div>
+    <div>鏁伴噺</div>
+    <div>鍗曚綅</div>
+   </div>
+   <div>
+    <div>鏃堕棿</div>
+    <div>瑙勬牸</div>
+   </div>
+</div>
+
+<div v-for="(item,index) in table" :key="index">
+  {{item}}
+</div>
+
+<el-button @click="showCode">鐢熸垚鏉″舰鐮�</el-button>
+<el-button v-print='printObj'>鎵撳嵃</el-button>
+<el-input v-show="false" class="input" v-model="value" ref="input"></el-input> 
+
   </div>
 </template>
 
 <script>
-export default {
+   import VueBarcode from 'vue-barcode'
 
+export default{
+   data(){
+      return {
+         printObj:{
+            id: "printMe", // 鎵撳嵃鐨勫尯鍩�
+            // preview: false, // 棰勮宸ュ叿鏄惁鍚敤
+            previewTitle: '鎵撳嵃鏉$爜', // 棰勮椤甸潰鐨勬爣棰�
+            popTitle: '', // 鎵撳嵃椤甸潰鐨勯〉鐪�
+            previewBeforeOpenCallback(vue) {
+              console.log('姝e湪鍔犺浇棰勮绐楀彛')
+            },
+            previewOpenCallback(vue) {
+              console.log('宸茬粡鍔犺浇瀹岄瑙堢獥鍙�')
+            },
+            clickMounted: (vue) => {
+              console.log("瑙﹀彂鐐瑰嚮鎵撳嵃鍥炶皟");
+              vue.isShowPrint = true  //寮规鏄剧ず鏉$爜
+            },
+            beforeOpenCallback(vue) {
+              console.log('鎵撳紑涔嬪墠',vue.barcodeNum)
+            },
+            openCallback (vue) {
+              vue.isShowPrint = false  // 鍏抽棴鏉$爜鏄剧ず寮规
+              console.log('鎵ц浜嗘墦鍗�',vue.barcodeNum)
+            },
+         },
+         value: '',
+         table:[]
+      }
+   },
+   components: { VueBarcode },
+   mounted() {
+    
+    this.makeCode('1234567891234567')
+    this.addScanMonitor()
+   },
+   methods: {
+    // 鐩戝惉鎵弿
+    showCode() {
+      this.makeCode('1234567891234567')
+// window.document.onkeypress=undefined
+    },
+    addScanMonitor() {
+      window.document.onkeypress = e => {
+        console.log(e)
+        if (window.event) { // IE
+          this.nextCode = e.keyCode
+        } else if (e.which) { // Netscape/Firefox/Opera
+          this.nextCode = e.which
+        }
+
+        if (e.which === 13) { // 閿洏鍥炶溅浜嬩欢
+          if (this.code.length < 3) return // 鎵爜鏋殑閫熷害寰堝揩锛屾墜鍔ㄨ緭鍏ョ殑鏃堕棿涓嶄細璁ヽode鐨勯暱搴﹀ぇ浜�2锛屾墍浠ヨ繖閲屼笉浼氬鎵爜鏋湁鏁�
+          console.log('鎵爜缁撴潫,鏉″舰鐮侊細', this.code)
+          this.table.push(this.code)
+          this.scanningForm.scanCode = this.code
+          this.lastCode = ''
+          this.lastTime = ''
+          this.handleSubmitScanning()
+          return
+        }
+
+        this.nextTime = new Date().getTime()
+        if (!this.lastTime && !this.lastCode) {
+          this.code = '' // 娓呯┖涓婃鐨勬潯褰㈢爜
+          // 缁х画鎵弿涓�涓嬫潯鍓嶅叧闂脊绐�
+          // this.handleCloseTipsVisible()
+          this.code += e.key
+          console.log('鎵爜寮�濮�---', this.code)
+        }
+        if (this.lastCode && this.lastTime && this.nextTime - this.lastTime > 500) { // 褰撴壂鐮佸墠鏈塳eypress浜嬩欢鏃�,闃叉棣栧瓧缂哄け
+          this.code = e.key
+          console.log('闃叉棣栧瓧缂哄け銆傘�傘��', this.code)
+        } else if (this.lastCode && this.lastTime) {
+          this.code += e.key
+          console.log('鎵爜涓�傘�傘��', this.code)
+        }
+        this.lastCode = this.nextCode
+        this.lastTime = this.nextTime
+      }
+    },
+    makeCode(msg) {
+      // let obj = {jack: '1212'}
+     this.value = msg
+
+    }
+   }
 }
 </script>
 
-<style>
+<style lang="scss">
 
+  #printMe{
+  // height: 4cm;
+  width: 8cm;
+  display: flex;
+  flex-direction: column;
+  text-align: center;
+  img{
+    display: inline-block;
+    text-align: center;
+    width: 6cm;
+    height: 2cm;
+  }
+  >div{
+    width: 100%;
+    display: flex;
+    >div{
+      flex: 1;
+      // height: 30px;
+      border: 1px solid #ddd;
+    }
+  }
+}
+@media print {
+  @page {
+    size: 8cm 4cm !important;
+    // margin: 0cm;
+    // padding: 0cm;
+    // size: portrait;
+    // border: 1px solid #ddd;
+    
+  }
+  #printMe{
+    display: block;
+    width: 100%;
+      overflow: hidden;
+    }
+  }
 </style>
\ No newline at end of file

--
Gitblit v1.9.3