491 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			491 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
 | 
						||
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;
 | 
						||
  formData: 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 {
 | 
						||
    console.log('只读')
 | 
						||
    this.schema = {
 | 
						||
      properties: {
 | 
						||
        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格式',
 | 
						||
        },
 | 
						||
        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.request(this.service.$api_get_billAuditPass, params).subscribe((res) => {
 | 
						||
     if(res) {
 | 
						||
       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)
 | 
						||
    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);
 | 
						||
  }
 | 
						||
 | 
						||
}
 |