|
@@ -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)
|
|
|
}
|
|
|
}
|