Files
bbq/src/app/routes/order-management/modal/audit/voucher-view/voucher-view.component.ts
wangshiming 5f06aaf4a4 fix bug
2022-04-01 16:00:39 +08:00

524 lines
18 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Component, OnInit, ViewChild } from '@angular/core';
import { DatePipe } from '@angular/common';
import {
SFComponent,
SFCustomWidgetSchema,
SFDateWidgetSchema,
SFNumberWidgetSchema,
SFRadioWidgetSchema,
SFSchema,
SFSelectWidgetSchema,
SFTextareaWidgetSchema,
SFUISchema,
SFUploadWidgetSchema
} from '@delon/form';
import { apiConf } from '@conf/api.conf';
import { _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { Observable, Observer } from 'rxjs';
import { EAEnvironmentService } from '@shared';
import { OrderManagementService } from '../../../services/order-management.service';
@Component({
selector: 'app-order-management-voucher-view',
templateUrl: './voucher-view.component.html',
styleUrls: ['./voucher-view.component.less'],
providers: [DatePipe]
})
export class orderManagementVoucherViewComponent implements OnInit {
record: any = {};
i: any;
loadPDF: string = '';
formData: any;
datas: any;
Status: any;
data: any ={
weight: 0,
volume: 0
};
@ViewChild('sf', { static: false }) sf!: SFComponent;
schema: SFSchema = {};
ui: SFUISchema = {};
constructor(private modal: NzModalRef, private msgSrv: NzMessageService, public http: _HttpClient, public service: OrderManagementService,private datePipe: DatePipe,private envSrv: EAEnvironmentService, ) {}
ngOnInit(): void {
// console.log(this.i)
this.initData()
this.i.time = this.i.loadingTime;
this.initSF();
}
initSF() {
console.log(this.Status)
if(this.Status == 1) {
this.schema = {
properties: {
loadingLadingBillFilePath: {
type: 'string',
title: '装货凭证',
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '提货单',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
},
loadingPeopleVehiclesGoodsFilePath: {
type: 'string',
title: '',
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '人车货照片',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
},
no4: {
type: 'string',
title: '',
ui: {
widget: 'text',
},
default: '单张大小不超过5M支持.jpg、.jpeg和 .png格式',
},
unloadingLadingBillFilePath: {
type: 'string',
title: '卸货凭证',
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '提货单',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
},
unloadingPeopleVehiclesGoodsFilePath: {
type: 'string',
title: '',
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '人车货照片',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
}
},
required: ['loadingLadingBillFilePath', 'loadingPeopleVehiclesGoodsFilePath','unloadingLadingBillFilePath','unloadingPeopleVehiclesGoodsFilePath' ]
};
}else {
this.schema = {
properties: {
no0: {
type: 'string',
title: '',
ui: {
widget: 'custom',
},
},
loadingLadingBillFilePath: {
type: 'string',
title: '装货凭证',
readOnly: true,
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '提货单',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
},
loadingPeopleVehiclesGoodsFilePath: {
type: 'string',
title: '',
readOnly: true,
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '人车货照片',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
},
no4: {
type: 'string',
title: '',
ui: {
widget: 'text',
},
default: '单张大小不超过5M支持.jpg、.jpeg和 .png格式',
},
no6: {
type: 'string',
title: '',
ui: {
widget: 'custom',
},
},
unloadingLadingBillFilePath: {
type: 'string',
title: '卸货凭证',
readOnly: true,
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '提货单',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
},
unloadingPeopleVehiclesGoodsFilePath: {
type: 'string',
title: '',
readOnly: true,
ui: {
widget: 'upload',
action: apiConf.fileUpload,
fileType: 'image/png,image/jpeg,image/jpg,image/gif',
limit: 1,
limitFileCount: 1,
resReName: 'data.fullFileWatermarkPath',
urlReName: 'data.fullFileWatermarkPath',
descriptionI18n: '人车货照片',
data: {
appId: this.envSrv.env.appId,
},
name: 'multipartFile',
beforeUpload: (file: any, fileList: any) => {
return new Observable((observer: Observer<boolean>) => {
const isLt1M = file.size / 1024 / 1024 < 5;
const fileType = 'image/png,image/jpeg';
if (fileType.indexOf(file.type) === -1) {
this.service.msgSrv.warning('图片格式不正确!');
observer.complete();
return;
}
if (!isLt1M) {
this.service.msgSrv.warning('图片大小超过5M!');
observer.complete();
return;
}
observer.next(isLt1M);
observer.complete();
});
},
multiple: false,
listType: 'picture-card',
} as SFUploadWidgetSchema,
}
},
required: ['loadingLadingBillFilePath', 'loadingPeopleVehiclesGoodsFilePath','unloadingLadingBillFilePath','unloadingPeopleVehiclesGoodsFilePath' ]
};
}
this.ui = {
'*': {
spanLabelFixed: 100,
grid: { span: 20 }
},
$unloadingLadingBillFilePath: { grid: { span: 12} },
$unloadingPeopleVehiclesGoodsFilePath: { grid: { span: 12} },
$loadingLadingBillFilePath: { grid: { span: 12} },
$loadingPeopleVehiclesGoodsFilePath: { grid: { span: 12} },
};
}
save(value: any): void {
if(!this.sf.valid) {
this.service.msgSrv.warning('必填项为空!')
return;
}
console.log(value)
const params = {
id: this.i?.id,
loadingLadingBillFilePath: value?.loadingLadingBillFilePath?.data?.fullFilePath,
loadingPeopleVehiclesGoodsFilePath: value?.loadingPeopleVehiclesGoodsFilePath?.data?.fullFilePath,
unloadingLadingBillFilePath: value?.unloadingLadingBillFilePath?.data?.fullFilePath,
unloadingPeopleVehiclesGoodsFilePath: value?.unloadingPeopleVehiclesGoodsFilePath?.data?.fullFilePath,
}
console.log(params)
this.service.request(this.service.$api_get_updateBillExamine, params).subscribe((res) => {
if(res) {
this.service.msgSrv.success('修改成功!')
this.modal.destroy(true);
}
})
}
sure() {
const params = [this.i?.id];
this.service.downloadFile(this.service.$api_createBillTakeGoods,params)
this.service.downloadFile(this.service.$api_createBillDischargeGoods,params)
this.service.msgSrv.success('生成电子单据成功!')
this.modal.destroy(true);
}
// 确认到车界面信息(两个只能看的图片)
initData() {
this.service.request(this.service.$api_get_getCredentials, { id : this.i?.id}).subscribe((res) => {
console.log(res)
this.datas = res
if (res.unloadingLadingBillFilePath) {
this.formData = {
loadingLadingBillFilePath: [
{
uid: 'logo',
name: 'LOGO',
status: 'done',
url: res.loadingLadingBillFilePath,
response: {
url: res.loadingLadingBillFilePath,
},
},
],
loadingPeopleVehiclesGoodsFilePath: [
{
uid: 'logo',
name: 'LOGO',
status: 'done',
url: res.loadingPeopleVehiclesGoodsFilePath,
response: {
url: res.loadingPeopleVehiclesGoodsFilePath,
},
},
],
unloadingLadingBillFilePath: [
{
uid: 'logo',
name: 'LOGO',
status: 'done',
url: res.unloadingLadingBillFilePath,
response: {
url: res.unloadingLadingBillFilePath,
},
},
],
unloadingPeopleVehiclesGoodsFilePath: [
{
uid: 'logo',
name: 'LOGO',
status: 'done',
url: res.unloadingPeopleVehiclesGoodsFilePath,
response: {
url: res.unloadingPeopleVehiclesGoodsFilePath,
},
},
],
};
}
})
}
close(): void {
this.modal.destroy(true);
}
openlaod(value: any) {
if(value === 1) {
const a = document.createElement('a');
a.href = this.datas?.loadingLadingBillFilePath;
document.body.appendChild(a);
console.log(document.body.contains(a))
a.click(); //点击下载
document.body.removeChild(a); //下载完成移除元素
} else {
const a = document.createElement('a');
a.href = this.datas?.loadingPeopleVehiclesGoodsFilePath;
document.body.appendChild(a);
console.log(document.body.contains(a))
a.click(); //点击下载
document.body.removeChild(a); //下载完成移除元素
}
}
}