123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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'
- @Component({
- selector: 'app-contract-detail',
- templateUrl: './contract-detail.page.html',
- styleUrls: ['./contract-detail.page.scss'],
- })
- export class ContractDetailPage implements OnInit {
- defaultHref = '';
- contractDetailList=[]
- sscCode=''
- sscCreator=''
- scpModifiedtime=''
- sscId=''
- constructor(
- private camera: Camera,
- public commonService: commonService,
- private storage: Storage,
- public userData: UserData
- ) { }
- ngOnInit() {
- this.storage.get('sscId').then(async (val) => {
- if (val) {
- this.sscId = val
- let data = await this.userData.getContractDetail(val)
- if (JSON.parse(data).data.length !== 0) {
- this.sscCode = JSON.parse(data).data[0].scbCode
- this.scpModifiedtime = JSON.parse(data).data[0].scpModifiedtime
- this.contractDetailList = JSON.parse(data).data
- for (let i of this.contractDetailList) {
- i.imgsrc = i.pictures[0].smallPicture
- let data = await this.userData.getQAlog(val, i.pid)
- if (JSON.parse(data).data.length !== 0) {
- i.qalog = JSON.parse(data).data[0].mark
- i.imgUrl = JSON.parse(data).data[0].picture.split(",")[0]
- }
- }
- }
- }
- });
- }
- ionViewDidEnter() {
- this.defaultHref = `/contract-table`;
- }
- showFullScreenImage(data) {
- this.commonService.fullScreenImg(data)
- }
- takePicture(contract) {
- const options: CameraOptions = {
- quality: 10,
- destinationType: this.camera.DestinationType.DATA_URL,
- encodingType: this.camera.EncodingType.JPEG,
- mediaType: this.camera.MediaType.PICTURE
- }
- this.camera.getPicture(options).then((imageData) => {
- contract.showPicture = true
- contract.imgData = imageData
- contract.imgUrl = 'data:image/jpeg;base64,' + imageData
- }, (err) => {
- // Handle error
- console.log("Camera issue: " + err);
- });
- }
- deletePicture(contract) {
- contract.imgData = ''
- contract.showPicture = false
- }
- async saveDetail() {
- for(let i of this.contractDetailList) {
- if(i.qalog && i.imgData) {
- // let file = []
- // file.push(i.imgData)
- let form = {
- files: i.imgData,
- mark: i.qalog,
- pId: i.pid,
- sscId: this.sscId
- }
- await this.userData.contractQAlog(form)
- }
- }
- }
- }
|