فهرست منبع

路由传值更新

panxingxin 5 سال پیش
والد
کامیت
8693c0d015

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

@@ -20,6 +20,7 @@ const routes: Routes = [
   { path: 'store-pending', loadChildren: './store-pending/store-pending.module#StorePendingPageModule' },
   { path: 'store-qc', loadChildren: './store-qc/store-qc.module#StoreQCPageModule' },
   { path: 'store-qc-detail', loadChildren: './store-qc-detail/store-qc-detail.module#StoreQCDetailPageModule' },
+  { path: 'store-qc-scanning/:sscId/:pId', loadChildren: './store-qc-scanning/store-qc-scanning.module#StoreQCScanningPageModule' },
   { 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' }

+ 1 - 0
src/app/app.component.ts

@@ -182,6 +182,7 @@ export class AppComponent {
           text: '退出',
           handler: () => {
             navigator['app'].exitApp();
+            this.storage.clear()
           }
         }
       ]

+ 3 - 3
src/app/store-pending/store-pending.page.ts

@@ -50,9 +50,9 @@ export class StorePendingPage implements OnInit {
 
   // 获取扫描详情
   async getStoreQCDetail(pending) {
-    this.storage.set('store-pending', pending).then(() => {
-      this.router.navigateByUrl('/store-qc-scanning')
-    })
+    // this.storage.set('store-pending', pending).then(() => {
+      this.router.navigateByUrl(`/store-qc-scanning/${pending.sscId}/${pending.pid}`)
+    // })
     // let data = await this.userData.getQCDetail(pending.sscId, pending.pId)
 
     // this.storeQCDetailList = new Array(data)

+ 5 - 2
src/app/store-qc-scanning/store-qc-scanning.page.html

@@ -1,8 +1,11 @@
 <ion-header>
   <ion-toolbar>
-    <ion-buttons slot="start">
+    <ion-buttons slot="start" *ngIf="!defaultHref">
       <ion-menu-button></ion-menu-button>
     </ion-buttons>
+    <ion-buttons slot="start" *ngIf="defaultHref">
+      <ion-back-button [defaultHref]="defaultHref"></ion-back-button>
+    </ion-buttons>
     <ion-title>QC扫描</ion-title>
     <ion-buttons slot="end">
       <ion-button [disabled]="storeQCList.length===0" (click)="generateQC()">
@@ -68,7 +71,7 @@
       <ion-item slot="end">
         <ion-checkbox [(ngModel)]="qc.deal" readonly></ion-checkbox>
         <ion-label *ngIf="qc.deal">通过</ion-label>
-        <ion-label *ngIf="!qc.deal" color="danger">未通过s</ion-label>
+        <ion-label *ngIf="!qc.deal" color="danger">未通过</ion-label>
       </ion-item>
     </ion-item>
     <ion-item>

+ 50 - 18
src/app/store-qc-scanning/store-qc-scanning.page.ts

@@ -5,6 +5,7 @@ import { Keyboard } from '@ionic-native/keyboard/ngx';
 import { UserData } from '../../providers/user-data';
 import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
 import { commonService } from '../../providers/common.service';
+import { ActivatedRoute } from '@angular/router'
 
 
 @Component({
@@ -16,8 +17,10 @@ export class StoreQCScanningPage implements OnInit {
 
   scanCode = ''
   storeQCList = []
+  defaultHref = ''
   storeQCDetailList = []
   constructor(private router: Router,
+    private activeRoute: ActivatedRoute,
     public commonService: commonService,
     private storage: Storage,
     public userData: UserData,
@@ -26,24 +29,50 @@ export class StoreQCScanningPage implements OnInit {
 
   @ViewChild('scanInput') scanInput;
   ngOnInit() {
+    this.storage.get('storeQCList').then(async (val) => {
+      if (val) {
+        this.storeQCList = JSON.parse(val)
+      }
+    })
   }
 
   ionViewDidEnter() {
-    this.initialData()
+    this.activeRoute.paramMap.subscribe(params => {
+      if (params['params'].sscId && params['params'].pId) {
+        this.scanCode = params['params'].sscId + '_' + params['params'].pId
+        this.defaultHref = '/store-pending'
+      } else {
+        this.scanCode = ''
+      }
+      // this.product = products[+params.get('productId')];
+    });
+
+    // this.initialData()
+  }
+
+  ionViewDidLeave() {
+    if (this.storeQCList.length !== 0) {
+      this.storage.set('storeQCList', JSON.stringify(this.storeQCList))
+    } else {
+      this.storage.remove('storeQCList')
+    }
+    this.storage.remove('store-pending') // 离开页面清除scancode
   }
 
   initialData() {
     this.storeQCDetailList = []
-    this.scanCode = ''
     this.scanInput.setFocus();
-    this.storage.get('store-pending').then(async (val) => {
-      if(val) {
-        this.scanCode = val.sscId + '_' +val.pid
-      }
-      this.storage.remove('store-pending')
-    })
+    // this.storage.get('store-pending').then(async (val) => {
+    //   if(val) {
+    //     this.scanCode = val.sscId + '_' +val.pid
+    //     this.defaultHref = '/store-pending'
+    //   } else {
+    //     this.defaultHref = ''
+    //   }
+    // })
+    this.scanCode = ''
   }
-  
+
   showFullScreenImage(url) {
     this.commonService.fullScreenImg(url)
   }
@@ -76,11 +105,13 @@ export class StoreQCScanningPage implements OnInit {
             i.qclog = JSON.parse(qclogdata).data[0].mark
             i.qcimgUrl = JSON.parse(qclogdata).data[0].picture.split(",")[0]
           }
-          // 处理意见转换boolean
-          if (i.dealpropose == 1) {
-            i.deal = true
-          } else {
-            i.deal = false
+          // 处理意见转换boolean(无deal)
+          if (i.deal === undefined) {
+            if (i.dealpropose == 1) {
+              i.deal = true
+            } else {
+              i.deal = false
+            }
           }
         }
       }
@@ -101,7 +132,6 @@ export class StoreQCScanningPage implements OnInit {
 
   // 记录数据
   async saveQCRecord() {
-    let _this = this
     // 是否已扫描记录过该数据
     let filterData = []
     filterData = this.storeQCList.filter(item => {
@@ -117,17 +147,19 @@ export class StoreQCScanningPage implements OnInit {
     // 显示记录中的外销合同号
     // this.scpCodes = []
     for (let i of this.storeQCList) {
-      i.scanCode = this.scanCode
+      if (!i.scanCode) {
+        i.scanCode = this.scanCode // 无scancode则加上
+      }
       // this.scpCodes.push(i.scpCode)
     }
     this.addQClog()
+    this.storage.remove('store-pending')
     this.initialData()
   }
 
   // 添加qc记录
   async addQClog() {
     for (let i of this.storeQCDetailList) {
-      // console.log(i)
       if (i.qclog && i.imgData) {
         // let file = []
         // file.push(i.imgData)
@@ -166,6 +198,6 @@ export class StoreQCScanningPage implements OnInit {
   }
 
   deleteQCStore(store, index) {
-    this.storeQCList.splice(index)
+    this.storeQCList.splice(index, 1)
   }
 }

+ 2 - 2
src/app/store-sample/store-sample.page.ts

@@ -34,8 +34,8 @@ export class StoreSamplePage implements OnInit {
     this.getList()
   }
 
-  async doRefresh(event) {
-    await this.getList()
+  doRefresh(event) {
+    this.getList()
     event.target.complete();    //告诉ion-refresher  更新数据
   }
 

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

@@ -71,7 +71,7 @@ export class UserData {
             this.storage.set('access_token', JSON.parse(data.data).access_token);
             this.storage.set('user_id', JSON.parse(data.data).user_id);
             this.storage.set(this.HAS_LOGGED_IN, true);
-            this.router.navigateByUrl('/scanning');
+            this.router.navigateByUrl('/sample');
             return this.events.publish('user:login');
           }
         }, async err => {
@@ -570,7 +570,7 @@ export class UserData {
     });
   }
 
-  // 货架借出销毁
+  // 货架借出
   async changeShelfLend(code: string): Promise<any> {
     const token = await this.getToken();
     const loading = await this.loadingCtrl.create();