Forráskód Böngészése

添加入库单号扫描

panxingxin 5 éve
szülő
commit
33069902f8

+ 2 - 1
src/app/app-routing.module.ts

@@ -24,7 +24,8 @@ const routes: Routes = [
   { path: 'store-qc-scanning', loadChildren: './store-qc-scanning/store-qc-scanning.module#StoreQCScanningPageModule' },
   { path: 'store-sample-pending', loadChildren: './store-sample-pending/store-sample-pending.module#StoreSamplePendingPageModule' },
   { path: 'warehouse-manage-pending', loadChildren: './warehouse-manage-pending/warehouse-manage-pending.module#WarehouseManagePendingPageModule' },
-  { path: 'home', loadChildren: './home/home.module#HomePageModule' }
+  { path: 'home', loadChildren: './home/home.module#HomePageModule' },
+  { path: 'es-apply-scan', loadChildren: './es-apply-scan/es-apply-scan.module#EsApplyScanPageModule' }
   // { path: 'scanning', loadChildren: './scanning/scanning.module#ScanningPageModule', canActivate: [LoginGuardGuard] }
 ];
 @NgModule({

+ 3 - 39
src/app/enter-store/enter-store.page.ts

@@ -42,8 +42,6 @@ export class EnterStorePage implements OnInit {
         this.storeList = JSON.parse(val)
       }
     })
-    // this.getStoreDetail()
-    // console.log('enter-store')
   }
 
   // 进入页面
@@ -107,22 +105,12 @@ export class EnterStorePage implements OnInit {
     this.scanInput.setFocus();
   }
 
-  // async getId() {
-  //   await this.storage.get('pId').then((val) => {
-  //     this.pId = val
-  //     this.entergoodsCode = val
-  //   })
-  //   await this.storage.get('sscId').then((val) => {
-  //     this.sscId = val
-  //   })
-  // }
   // 获取入库单详情
   async getStoreDetail(item?) {
-    // console.log(this.scanCode)
-    // this.keyboard.hide()
     if (item) {
       this.scanCode = item.scanCode
-      this.storeDetailList = item
+      this.storeDetailList = new Array(item)
+      console.log(item)
     } else {
       if (this.scanCode.split('_').length === 2) {
         let filterData = []
@@ -134,12 +122,7 @@ export class EnterStorePage implements OnInit {
           this.storeDetailList = new Array(JSON.parse(data).data)
         }
       }
-      // console.log(this.storeDetailList)
     }
-    // await this.getId()
-    // if(this.pId && this.sscId) {
-    //   this.storeDetailList = await this.userData.getStoreDetail(this.pId,this.sscId)
-    // }
   }
   // 记录数据
   async saveRecord(form: NgForm) {
@@ -159,33 +142,15 @@ export class EnterStorePage implements OnInit {
         this.storeList = this.storeList.concat(this.storeDetailList)
       }
       // 显示记录中的外销合同号
-      // this.scpCodes = []
       for (let i of this.storeList) {
         i.enterCount = Number(i.enterBoxs) * Number(i.scpOutrate)
         i.amount = i.enterCount
         if (!i.scanCode) {
           i.scanCode = this.scanCode
         }
-        // this.scpCodes.push(i.scpCode)
       }
+      this.storage.set('storeList', JSON.stringify(this.storeList))
       this.initialData()
-      // const alert = await this.alertController.create({
-      //   // header: 'Confirm!',
-      //   message: `记录成功,当前记录外销合同${scpCodes}`,
-      //   buttons: [
-      //     {
-      //       text: '确定',
-      //       role: 'cancel',
-      //       cssClass: 'secondary',
-      //       handler: (blah) => {
-      //         _this.clicked = false
-      //         _this.scanCode = ''
-      //         _this.scanInput.setFocus();
-      //       }
-      //     }
-      //   ]
-      // });
-      // await alert.present();
     }
   }
 
@@ -199,7 +164,6 @@ export class EnterStorePage implements OnInit {
     this.initialData()
     this.storeList = []
     this.storage.remove('storeList')
-    // this.scanInput.setFocus();
   }
 
   qrscan() {

+ 26 - 0
src/app/es-apply-scan/es-apply-scan.module.ts

@@ -0,0 +1,26 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { Routes, RouterModule } from '@angular/router';
+
+import { IonicModule } from '@ionic/angular';
+
+import { EsApplyScanPage } from './es-apply-scan.page';
+
+const routes: Routes = [
+  {
+    path: '',
+    component: EsApplyScanPage
+  }
+];
+
+@NgModule({
+  imports: [
+    CommonModule,
+    FormsModule,
+    IonicModule,
+    RouterModule.forChild(routes)
+  ],
+  declarations: [EsApplyScanPage]
+})
+export class EsApplyScanPageModule {}

+ 165 - 0
src/app/es-apply-scan/es-apply-scan.page.html

@@ -0,0 +1,165 @@
+<ion-header>
+  <ion-toolbar>
+    <ion-buttons slot="start">
+      <ion-menu-button></ion-menu-button>
+    </ion-buttons>
+    <ion-title>入库单号扫描</ion-title>
+    <ion-buttons slot="end">
+      <ion-button [disabled]="esStoreList.length===0" (click)="saveStore()">
+        保存
+      </ion-button>
+      /
+      <ion-button (click)="qrscan()">
+        <ion-icon name="qr-scanner"></ion-icon>
+      </ion-button>
+    </ion-buttons>
+  </ion-toolbar>
+</ion-header>
+
+<ion-content>
+  <ion-item>
+    <ion-label>入库申请单号:</ion-label>
+    <ion-input #scanInput clear-on-edit autofocus (ionFocus)="hideKeyboard()" (ionChange)="getStoreDetail()"
+      [(ngModel)]="scanCode"></ion-input>
+  </ion-item>
+  <!-- <ion-list style="margin-bottom: 0px;" *ngFor="let es of esStoreList index as i"> -->
+  <ion-grid *ngFor="let es of esStoreDetailList">
+    <ion-row *ngFor="let store of es.detailList;let i = index">
+      <!-- <form #esApplyForm="ngForm"> -->
+        <div class="divider"></div>
+        <ion-col size="3" class="ion-col">
+          <ion-label class="disabled-input">
+            PO号:
+          </ion-label>
+          <ion-input class="ion-input" [(ngModel)]="store.scpPoCode" name="scpPoCode" #scpPoCode="ngModel" disabled>
+          </ion-input>
+        </ion-col>
+        <ion-col size="3" class="ion-col">
+          <ion-label class="disabled-input">
+            我司货号:
+          </ion-label>
+          <ion-input class="ion-input" [(ngModel)]="store.scpCode" name="scpCode" #scpCode="ngModel" disabled>
+          </ion-input>
+        </ion-col>
+        <ion-col size="3" class="ion-col">
+          <ion-label class="disabled-input">
+            客户货号:
+          </ion-label>
+          <ion-input class="ion-input" [(ngModel)]="store.scpCustomercode" name="scpCustomercode"
+            #scpCustomercode="ngModel" disabled>
+          </ion-input>
+        </ion-col>
+        <ion-col size="9" class="ion-col">
+          <ion-label class="disabled-input">
+            中文品名:
+          </ion-label>
+          <ion-input class="ion-input" [(ngModel)]="store.scpCnname" name="scpCnname" #scpCnname="ngModel" disabled>
+          </ion-input>
+        </ion-col>
+        <ion-col size="3" class="ion-col">
+          <ion-label class="disabled-input">
+            总箱数:
+          </ion-label>
+          <ion-input class="ion-input" [(ngModel)]="store.boxsCount" name="boxsCount" #boxsCount="ngModel" disabled>
+          </ion-input>
+        </ion-col>
+        <ion-col size="3" class="ion-col">
+          <ion-label class="disabled-input">
+            qc员:
+          </ion-label>
+          <ion-input class="ion-input" [(ngModel)]="store.qcName" name="qcName" #qcName="ngModel" disabled>
+          </ion-input>
+        </ion-col>
+        <ion-col size="6" class="mode-input">
+          <div>
+            <ion-label>
+              外箱长度:
+            </ion-label>
+            <ion-input style="--padding-top: 0;" [(ngModel)]="store.outboxlength" type="number"
+              (ionFocus)="hideKeyboard()" name="outboxlength" required></ion-input>
+          </div>
+          <ion-text class="mode-input-danger" color="danger">
+            <p style="padding-left: 0;" [hidden]="!(!store.outboxlength&&clicked)" class="ion-padding-start">
+              请输入外箱长度
+            </p>
+          </ion-text>
+        </ion-col>
+        <ion-col size="3" class="mode-input">
+          <div>
+            <ion-label>
+              外箱宽度:
+            </ion-label>
+            <ion-input style="--padding-top: 0;" [(ngModel)]="store.outboxwidth" type="number"
+              (ionFocus)="hideKeyboard()" name="outboxwidth" required></ion-input>
+          </div>
+          <ion-text class="mode-input-danger" color="danger">
+            <p style="padding-left: 0;" [hidden]="!(!store.outboxwidth&&clicked)" class="ion-padding-start">
+              请输入外箱宽度
+            </p>
+          </ion-text>
+        </ion-col>
+        <ion-col size="3" class="mode-input">
+          <div>
+            <ion-label>
+              外箱高度:
+            </ion-label>
+            <ion-input style="--padding-top: 0;" [(ngModel)]="store.outboxheigt" type="number"
+              (ionFocus)="hideKeyboard()" name="outboxheigt" required></ion-input>
+          </div>
+          <ion-text class="mode-input-danger" color="danger">
+            <p style="padding-left: 0;" [hidden]="!(!store.outboxheigt&&clicked)" class="ion-padding-start">
+              请输入外箱高度
+            </p>
+          </ion-text>
+        </ion-col>
+        <ion-col size="3" class="mode-input">
+          <div>
+            <ion-label>
+              毛重:
+            </ion-label>
+            <ion-input style="--padding-top: 0;" [(ngModel)]="store.grossweight" type="number"
+              (ionFocus)="hideKeyboard()" name="grossweight" required></ion-input>
+          </div>
+          <ion-text class="mode-input-danger" color="danger">
+            <p style="padding-left: 0;" [hidden]="!(!store.grossweight&&clicked)" class="ion-padding-start">
+              请输入毛重:
+            </p>
+          </ion-text>
+        </ion-col>
+        <ion-col size="3" class="mode-input">
+          <div>
+            <ion-label>
+              仓位编号:
+            </ion-label>
+            <ion-input style="--padding-top: 0;" [(ngModel)]="store.storelocation" type="number"
+              (ionFocus)="hideKeyboard()" name="storelocation" required></ion-input>
+          </div>
+          <ion-text class="mode-input-danger" color="danger">
+            <p style="padding-left: 0;" [hidden]="!(!store.storelocation&&clicked)" class="ion-padding-start">
+              请输入仓位编号
+            </p>
+          </ion-text>
+        </ion-col>
+      <!-- </form> -->
+    </ion-row>
+  </ion-grid>
+
+  <!-- </ion-list> -->
+  <div class="ion-padding">
+    <ion-button color="primary" type="submit" expand="block" (click)="saveRecord(esApplyForm)"
+      [disabled]="esStoreDetailList.length===0">记 录</ion-button>
+  </div>
+  <ion-list>
+    <ion-item-group>
+      <ion-item-divider sticky>
+        <ion-label>
+          已扫描条形码编号
+        </ion-label>
+      </ion-item-divider>
+    </ion-item-group>
+    <ion-item *ngFor="let item of esStoreList index as i">
+      <ion-label color="primary" (click)="getStoreDetail(item)">入库申请单号:({{item.scanCode}})</ion-label>
+      <ion-icon name="trash" (click)="deleteStore(item, i)"></ion-icon>
+    </ion-item>
+  </ion-list>
+</ion-content>

+ 33 - 0
src/app/es-apply-scan/es-apply-scan.page.scss

@@ -0,0 +1,33 @@
+.ion-col {
+    display: flex;
+    font-size: 0.875rem;
+}
+
+.ion-col .ion-input{
+    --padding-top: 0;
+}
+
+.divider {
+    width: 100%;
+    height: 0.1rem;
+    background-color: #f2f2f2;
+}
+
+.disabled-input {
+    opacity: .4;
+}
+
+.mode-input {
+    font-size: 14px;
+}
+.mode-input div {
+    display: flex;
+}
+
+.ion-col,.mode-input {
+    padding: 0.2rem;
+}
+
+.mode-input-danger {
+
+}

+ 27 - 0
src/app/es-apply-scan/es-apply-scan.page.spec.ts

@@ -0,0 +1,27 @@
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { EsApplyScanPage } from './es-apply-scan.page';
+
+describe('EsApplyScanPage', () => {
+  let component: EsApplyScanPage;
+  let fixture: ComponentFixture<EsApplyScanPage>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ EsApplyScanPage ],
+      schemas: [CUSTOM_ELEMENTS_SCHEMA],
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(EsApplyScanPage);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});

+ 174 - 0
src/app/es-apply-scan/es-apply-scan.page.ts

@@ -0,0 +1,174 @@
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { Storage } from '@ionic/storage'
+import { UserData } from '../../providers/user-data';
+import { NgForm } from '@angular/forms';
+import { Keyboard } from '@ionic-native/keyboard/ngx';
+import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
+import { Device } from '@ionic-native/device/ngx'
+
+@Component({
+  selector: 'app-es-apply-scan',
+  templateUrl: './es-apply-scan.page.html',
+  styleUrls: ['./es-apply-scan.page.scss'],
+})
+export class EsApplyScanPage implements OnInit {
+
+  esStoreDetailList = []
+  clicked = false
+  esStoreList = [
+  ]
+  scpCodes = []
+  scanCode: string
+  pId: number
+  sscId: number
+  entergoodsCode: any
+  constructor(
+    private device: Device,
+    private storage: Storage,
+    private barcodeScanner: BarcodeScanner,
+    public userData: UserData,
+    private keyboard: Keyboard) { }
+
+  @ViewChild('scanInput') scanInput;
+  ngOnInit() {
+    this.storage.get('esStoreList').then(async (val) => {
+      if (val) {
+        this.esStoreList = JSON.parse(val)
+      }
+    })
+  }
+
+  // 进入页面
+  ionViewDidEnter() {
+    // 已打开键盘状态,切换另外input,不会再次进入此事件,故需hideKeyboard事件来隐藏键盘
+    window['keyboard'] = this.keyboard
+    window.addEventListener('keyboardDidShow', this.ifHideKeyboard)
+    this.initialData()
+  }
+
+  ifHideKeyboard() {
+    if (window['keyboardVisible'] === false) {
+      window['keyboard'].hide()
+    }
+  }
+
+  ionViewWillLeave() {
+    window.removeEventListener('keyboardDidShow', this.ifHideKeyboard)
+  }
+
+  ionViewDidLeave() {
+    if (this.esStoreList.length !== 0) {
+      this.storage.set('esStoreList', JSON.stringify(this.esStoreList))
+    } else {
+      this.storage.remove('esStoreList')
+    }
+  }
+
+  hideKeyboard() {
+    // 收缩键盘后还是聚焦状态,不会进入此事件,需监听事件来隐藏键盘
+    if (this.device.version == '6' || this.device.version == '6.0' || this.device.version == '6.0.0') {
+      window['keyboardVisible'] = false
+      setTimeout(() => {
+        this.keyboard.hide()
+      }, 300)
+    }
+  }
+
+  // enterEdit(e, key, index) {
+  //   e.preventDefault()
+  //   let keycode = window.event ? e.keyCode : e.which;
+  //   if (keycode == 13) {
+  //     e.preventDefault();
+  //     this[key].setFocus();
+  //     if(key==='complete') {
+  //       this.saveRecord(this.esStoreDetailList[index])
+  //     }
+  //   }
+  // }
+
+  // 显示键盘
+  showKeyboard() {
+    window['keyboardVisible'] = true
+  }
+
+  // 隐藏键盘
+  initialData() {
+    this.esStoreDetailList = []
+    this.clicked = false
+    this.scanCode = ''
+    this.scanInput.setFocus();
+  }
+
+  // 获取入库单详情
+  async getStoreDetail(item?) {
+    console.log('detail')
+    if (item) {
+      this.scanCode = item.scanCode
+      this.esStoreDetailList = new Array(item)
+    } else {
+      if (this.scanCode) {
+        let filterData = []
+        filterData = this.esStoreList.filter(item => {
+          return item.scanCode === this.scanCode
+        })
+        if (filterData.length === 0) {
+          let data = await this.userData.getAppStoreDetail(this.scanCode)
+          this.esStoreDetailList.push({
+            scanCode: this.scanCode,
+            detailList: data.data
+          })
+        } else {
+          this.esStoreDetailList = filterData
+        }
+      }
+    }
+  }
+  // 记录数据
+  async saveRecord(form: NgForm) {
+    this.clicked = true
+    // if (form.valid) {
+    // 是否已扫描记录过该数据
+    let filterData = []
+    filterData = this.esStoreList.filter(item => {
+      return item.scanCode === this.esStoreDetailList[0].scanCode
+    })
+    // 有则更新
+    if (filterData.length !== 0) {
+      filterData = this.esStoreDetailList
+      // 无则加上  
+    } else {
+      this.esStoreList = this.esStoreList.concat(this.esStoreDetailList)
+    }
+    // 显示记录中的外销合同号
+    for (let i of this.esStoreList) {
+      for (let j of i.detailList) {
+        j.enterCount = Number(j.enterBoxs) * Number(j.scpOutrate)
+        j.amount = j.enterCount
+      }
+    }
+    this.storage.set('esStoreList', JSON.stringify(this.esStoreList))
+    this.initialData()
+    // }
+  }
+
+  deleteStore(_store, index) {
+    this.esStoreList.splice(index)
+  }
+
+  // 保存并生成货号
+  async saveStore() {
+    for (let i of this.esStoreList) {
+      await this.userData.saveStoreDetail(i.detailList)
+    }
+    this.initialData()
+    this.esStoreList = []
+  }
+
+  qrscan() {
+    this.barcodeScanner.scan().then(barcodeData => {
+      this.scanCode = barcodeData.text
+    }).catch(err => {
+      console.log('Error', err);
+    });
+  }
+}

+ 9 - 4
src/app/menu/menu.ts

@@ -46,8 +46,13 @@ export const menu_list = [
             name: '入库扫描',
             icon: 'appstore',
             url: 'enter-store'
-        }, {
+        },{
             id: 8000,
+            name: '入库单号扫描',
+            icon: 'appstore',
+            url: 'es-apply-scan'
+        }, {
+            id: 9000,
             name: '待备货',
             icon: 'timer',
             url: 'warehouse-manage-pending'
@@ -55,17 +60,17 @@ export const menu_list = [
     },{
         title: 'QC',
         children: [{
-            id: 9000,
+            id: 10000,
             name: 'QC验货初检报告列表',
             icon: 'list-box',
             url: 'store-qc'
         }, {
-            id: 10000,
+            id: 11000,
             name: 'QC扫描',
             icon: 'qr-scanner',
             url: 'store-qc-scanning'
         }, {
-            id: 11000,
+            id: 12000,
             name: '待验货物',
             icon: 'checkbox',
             url: 'store-pending'

+ 36 - 2
src/providers/user-data.ts

@@ -187,7 +187,7 @@ export class UserData {
       from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/production/sample/factory/pCode`,
         data,
         headers)).pipe(
-          finalize(() => loading.dismiss() )
+          finalize(() => loading.dismiss())
         ).subscribe(async data => {
           if (JSON.parse(data.data).code == 1) {
             const toast = await this.toastCtrl.create({
@@ -361,7 +361,7 @@ export class UserData {
     return new Promise((resolve, reject) => {
       from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/production/samples/mobile/qalog/${sdpId}`, {},
         headers)).pipe(
-          finalize(() => {})
+          finalize(() => { })
         ).subscribe(async data => {
           resolve(data.data);
         }, async err => {
@@ -622,6 +622,39 @@ export class UserData {
     });
   }
 
+  // 查询入库申请单号
+  async getAppStoreDetail(applyCode: any): Promise<any> {
+    const token = await this.getToken();
+    const loading = await this.loadingCtrl.create();
+    await loading.present();
+    const headers = { Authorization: `Bearer ${token}` };
+    return new Promise((resolve, reject) => {
+      from(this.nativeHttp.get(`${environment.APP_SERVE_URL}/inventory/enterStore/mobile/apply?applyCode=${applyCode}`, {},
+        headers)).pipe(
+          finalize(() => loading.dismiss())
+        ).subscribe(async data => {
+          if (data.data === null) {
+            const toast = await this.toastCtrl.create({
+              message: '无数据',
+              duration: 1000,
+              position: 'top'
+            });
+            await toast.present();
+            resolve([]);
+          }
+          resolve(JSON.parse(data.data));
+        }, async err => {
+          console.log(err.url);
+          const toast = await this.toastCtrl.create({
+            message: err.url,
+            duration: 3000,
+            position: 'top'
+          });
+          await toast.present();
+        });
+    });
+  }
+
   // 获取仓库样品
   async getStoreSampleDetail(code: string): Promise<any> {
     const token = await this.getToken();
@@ -671,6 +704,7 @@ export class UserData {
           let message = '';
           if (JSON.parse(data.data).code === 0) {
             message = `保存成功,入库单号为${JSON.parse(data.data).data}`;
+            this.storage.remove('esStoreList')
           } else if (JSON.parse(data.data).code === 1) {
             message = JSON.parse(data.data).msg;
           }