Преглед изворни кода

货号货架扫描自动绑定

panxingxin пре 5 година
родитељ
комит
41ee4f315f

+ 3 - 2
src/app/store-sample-binding/store-sample-binding.page.html

@@ -7,7 +7,8 @@
     <ion-buttons slot="end">
       <ion-button (click)="qrscan()">
         <ion-icon name="qr-scanner"></ion-icon>
-      </ion-button>
+      </ion-button>/
+      <ion-button (click)="clear()">清空</ion-button>
     </ion-buttons>
   </ion-toolbar>
 </ion-header>
@@ -20,7 +21,7 @@
     </ion-item>
     <ion-item>
       <ion-label>货号:</ion-label>
-      <ion-input [(ngModel)]="code" #codeInput></ion-input>
+      <ion-input [(ngModel)]="code" (keyup)="enterCode($event)" #codeInput ></ion-input>
     </ion-item>
   </ion-list>
   <div class="ion-padding">

+ 15 - 0
src/app/store-sample-binding/store-sample-binding.page.ts

@@ -31,6 +31,7 @@ export class StoreSampleBindingPage implements OnInit {
     this.code = ''
   }
 
+  // 绑定
   async binding() {
     let form = {
       shelves: this.shelves,
@@ -46,6 +47,14 @@ export class StoreSampleBindingPage implements OnInit {
     }
   }
 
+  enterCode(e) {
+    let keycode = window.event ? e.keyCode : e.which;
+    if (keycode == 13 && this.shelves) {
+      this.binding()
+      this.codeInput.setFocus();
+    }
+  }
+
   qrscan() {
     this.barcodeScanner.scan().then(barcodeData => {
       if(!this.shelves) {
@@ -57,4 +66,10 @@ export class StoreSampleBindingPage implements OnInit {
       console.log('Error', err);
     });
   }
+
+  clear() {
+    this.shelves = ''
+    this.code = ''
+    this.shelvesInput.setFocus()
+  }
 }