/* * @Author: your name * @Date: 2021-12-15 13:17:42 * @LastEditTime: 2021-12-22 19:19:25 * @LastEditors: Please set LastEditors * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @FilePath: \tms-obc-web\src\app\routes\order-management\modal\vehicle\confir-receipt\confir-receipt.component.ts */ import { Component, OnInit, ViewChild } from '@angular/core'; import { SFComponent, SFCustomWidgetSchema, SFNumberWidgetSchema, SFRadioWidgetSchema, SFSchema, SFSelectWidgetSchema, SFTextareaWidgetSchema, SFUISchema } from '@delon/form'; import { NzUploadChangeParam, NzUploadFile } from 'ng-zorro-antd/upload'; import { _HttpClient } from '@delon/theme'; import { NzMessageService } from 'ng-zorro-antd/message'; import { NzModalRef } from 'ng-zorro-antd/modal'; import { OrderManagementService } from '../../../services/order-management.service'; import { Observable, Observer } from 'rxjs'; import { STColumn } from '@delon/abc/st'; function getBase64(file: File): Promise { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => resolve(reader.result); reader.onerror = error => reject(error); }); } @Component({ selector: 'app-order-management-vehicle-confir-receipt', templateUrl: './confir-receipt.component.html', styleUrls: ['./confir-receipt.component.less'] }) export class VehicleConfirReceiptComponent implements OnInit { record: any = {}; i:any; Status: any costDetail: any // 费用明细 columns!: STColumn[]; previewVisible1 = false; dataInfo: any; detailList: any data: any = {}; previewImage1 = ''; listImagUrls: any[] = []; payeeList: any; driverList: any; carList: any; constructor(private modal: NzModalRef, private msgSrv: NzMessageService, public http: _HttpClient,public service: OrderManagementService) {} ngOnInit(): void { this.initST() this.initData() } save(): void { let imgList : any= []; if(this.listImagUrls.length > 0) { this.listImagUrls.forEach((res :any) => { if(res.url) { imgList.push(res.url) } }) } console.log(imgList) const params = { id: this.i?.id, filePathList: imgList, } this.service.request(this.service.$api_get_signWholeOrder, params).subscribe((res: any) => { console.log(res) if(res) { this.service.msgSrv.success('确认签收成功!') this.modal.destroy(); } else { this.service.msgSrv.error(res.msg) } }) } handlePreview1 = async (file: NzUploadFile) => { if (!file.url && !file.preview) { file.preview = await getBase64(file.originFileObj!); } this.previewImage1 = file.url || file.preview; this.previewVisible1 = true; }; close(): void { this.modal.destroy(); } beforeUpload = (file: NzUploadFile, _fileList: NzUploadFile[]) => { return new Observable((observer: Observer) => { const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/bmp'; if (!isJpgOrPng) { this.service.msgSrv.warning('只能上传图片!'); observer.complete(); return; } // tslint:disable-next-line: no-non-null-assertion const isLt2M = file.size! / 1024 / 1024 < 3; if (!isLt2M) { this.service.msgSrv.warning('图片大小超过3兆!'); observer.complete(); return; } observer.next(isJpgOrPng && isLt2M); observer.complete(); }); }; initData() { // 大宗 this.service.request(this.service.$api_get_getWholeSignForDetail, {id: this.i?.id}).subscribe((res: any) => { console.log(res) this.dataInfo = res; const cost: any = {} res.mybidDetailInfo.forEach((element: any) => { if(element.expenseName === "预付" || element.expenseCode === 'PRE') { cost.PRE = element.price } else if(element.expenseName === "到付" || element.expenseCode === 'RECE') { cost.RECE = element.price } else if(element.expenseName === "回单付" || element.expenseCode === 'BACK') { cost.BACK = element.price } else if(element.expenseName === "油卡" || element.expenseCode === 'OIL') { cost.OIL = element.price } else if(element.expenseName === "总费用") { cost.traiPrice = element.price } }); let arr : any= [] res.filePathList.forEach((element: any, index: any) => { console.log(index) arr.push( { url: element, status: 'done', uid: index }) }); this.listImagUrls = arr; this.service.request(this.service.$api_getUserDetailByAppUserId, {id: this.dataInfo?.payeeId}).subscribe((res: any) => { console.log(res) this.payeeList = res; }) this.service.request(this.service.$api_getUserDetailByAppUserId, {id: this.dataInfo?.driverId}).subscribe((res: any) => { console.log(res) this.driverList = res; }) this.service.request(this.service.$api_getCarLicenseByIds, {id: this.dataInfo?.carId}).subscribe((res: any) => { console.log(res) this.carList = res; }) console.log(cost) this.costDetail = [cost]; }) } initST() { this.columns = [ { title: '预付', index: 'PRE' }, { title: '到付', index: 'RECE' }, { title: '油卡', index: 'OIL' }, { title: '回单付', index: 'BACK' }, { title: '总运费', index: 'traiPrice' } ]; } handleChange1(info: NzUploadChangeParam): void { switch (info.file.status) { case 'uploading': break; case 'done': let fileList = [...info.fileList]; // 2. Read from response and show file link console.log(fileList) fileList = fileList.map((file: any) => { if (file.response) { file.url = file.response.data.fullFilePath; } return file; }); console.log(this.listImagUrls) break; case 'error': this.service.msgSrv.error('网络错误'); break; } } }