123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- import { Component, OnInit } from '@angular/core';
- import { Storage } from '@ionic/storage'
- import { UserData } from '../../providers/user-data';
- import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
- import { commonService } from '../../providers/common.service'
- // import { FullScreenImage } from '@ionic-native/full-screen-image/ngx';
- // import { PopoverController } from '@ionic/angular'
- // import { PopoverPage } from '../qc-popover/qc-popover';
- @Component({
- selector: 'app-store-qc-detail',
- templateUrl: './store-qc-detail.page.html',
- styleUrls: ['./store-qc-detail.page.scss'],
- })
- export class StoreQCDetailPage implements OnInit {
- defaultHref = ""
- qcData = {
- details: []
- }
- QCdetails = {
- details: []
- }
- pId = ''
- sscId = ''
- showDetail: boolean = true
- constructor(private storage: Storage,
- public commonService: commonService,
- // private fullScreenImage: FullScreenImage,
- // public popoverCtrl: PopoverController,
- private camera: Camera,
- public userData: UserData) { }
- ngOnInit() {
- this.showDetail = true
- this.storage.get('QCdetails').then((val) => {
- this.QCdetails = JSON.parse(val)
- });
- this.storage.get('qc-pId').then((val) => {
- this.pId = val
- });
- this.storage.get('qc-sscId').then((val) => {
- this.sscId = val
- });
- }
- ionViewDidEnter() {
- // console.log(this.fullScreenImage)
- this.getDetail()
- }
- showFullScreenImage(data) {
- this.commonService.fullScreenImg(data)
- }
- async getDetail() {
- if (this.QCdetails) {
- this.qcData = this.QCdetails
- for (let i of this.qcData['details']) {
- this.showDetail = false
- // 获取QA日志
- i.qaimgList = []
- i.qcimgList = []
- i['qcIdList'] = []
- let qalogdata = await this.userData.getQAlog(i.sscId, i.pid)
- if (JSON.parse(qalogdata).data.length !== 0) {
- i.qalog = JSON.parse(qalogdata).data[0].mark
- i.qaimgList = JSON.parse(qalogdata).data[0].picture.split(",")
- }
- let qclogdata = await this.userData.getQClog(i.sscId, i.pid)
- if (JSON.parse(qclogdata).data.length !== 0) {
- for (let j of JSON.parse(qclogdata).data) {
- i['qcIdList'].push(j.id) // qc记录的id数组
- }
- i.qclog = JSON.parse(qclogdata).data[0].mark
- i.qcimgList = JSON.parse(qclogdata).data[0].picture.split(",")
- i.imageData = JSON.parse(qclogdata).data[0].picture
- }
- // 处理意见转换boolean
- if (i.dealpropose == 1) {
- i.deal = true
- } else {
- i.deal = false
- }
- }
- this.defaultHref = `/store-qc`;
- }
- // if (this.pId && this.sscId) {
- // let data = await this.userData.getQCDetail(this.pId, this.sscId)
- // this.defaultHref = `/store-qc-scanning`;
- // this.qcData['details'] = new Array(data)
- // }
- }
- takePicture(qc) {
- const options: CameraOptions = {
- quality: 100,
- destinationType: this.camera.DestinationType.DATA_URL,
- encodingType: this.camera.EncodingType.PNG,
- mediaType: this.camera.MediaType.PICTURE,
- targetWidth: 1500,
- targetHeight: 1125
- }
- this.camera.getPicture(options).then((imageData) => {
- qc.qcimgList.push(
- 'data:image/png;base64,' + imageData
- )
- if (qc.imageData) {
- qc.imageData = qc.imageData + ',' + imageData
- } else {
- qc.imageData = '' + imageData
- }
- }, (err) => {
- // Handle error
- console.log("Camera issue: " + err);
- });
- }
- deletePicture(qc, index) {
- qc.qcimgList.splice(index, 1)
- let arr = qc.imageData.split(',')
- arr.splice(qc, 1)
- qc.imageData = arr.toString()
- }
- // async presentPopover(event: Event) {
- // const popover = await this.popoverCtrl.create({
- // component: PopoverPage,
- // event: event,
- // translucent: true
- // });
- // return await popover.present();
- // }
- async createQC() {
- await this.userData.createQC(this.qcData['details'])
- }
- async addQClog() {
- for (let i of this.qcData['details']) {
- for (let j of i['qcIdList']) {
- this.userData.deleteSampleQc(j)
- }
- if (i.qclog && i.imageData) {
- let form = {
- files: i.imageData,
- mark: i.qclog,
- pId: i.pid,
- sscId: i.sscId
- }
- await this.userData.addQClog(form)
- }
- }
- }
- }
|