import { AttachFileInfoDto, AttachFileInfoQueryDto } from './../../shared-manage-model'; import { RhSharedManageService } from './../../shared-manage.service'; import { RhBaseDto } from 'rh-base/model'; import { Component, OnInit, Input, SimpleChanges } from '@angular/core'; import { MsgHelper } from 'rh-base/core'; @Component({ selector: 'rh-attach-file-manage', templateUrl: './attach-file-manage.component.html', styleUrls: ['./attach-file-manage.component.less'] }) export class RhAttachFileManageComponent implements OnInit { @Input() rhOrder!: RhBaseDto; @Input() rhEnableAttachFileHandle = false; @Input() rhBusinessType!: string; /** 入库单附件 */ attachFileDataset: AttachFileInfoDto[] = []; fileAreaLoading = false; constructor(private inOutStockManageSer: RhSharedManageService) { } ngOnInit(): void { } ngOnChanges(changes: SimpleChanges): void { const { rhOrder } = changes; if (rhOrder && rhOrder.currentValue && this.rhOrder['OrderCode']) { this.getAttachFileInfoDatas(); } } /** 获取入库单附件 */ getAttachFileInfoDatas() { const queryDto = AttachFileInfoQueryDto.create(); queryDto.OrderCode = this.rhOrder['OrderCode']; this.fileAreaLoading = true; this.inOutStockManageSer.GetAttachFileInfoDatas(queryDto).subscribe( (result) => { if (result.Success) { this.attachFileDataset = result.Attach; } else { this.attachFileDataset = []; // 不用报错 // MsgHelper.ShowWarningMessage(`获取附件信息失败!${result.Message}`); } this.fileAreaLoading = false; }, () => { this.attachFileDataset = []; this.fileAreaLoading = false; } ); } /** 下载入库单附件 */ downAttachFileInfoDatas(file: AttachFileInfoDto) { this.inOutStockManageSer.downAttachFileInfoDatas(file); } /** 移除附件数据 */ removeAttachFileInfoDatas(file: AttachFileInfoDto) { MsgHelper.ShowDeleteConfirm('删除后数据无法恢复,是否确定?', () => { this.fileAreaLoading = true; this.inOutStockManageSer.RemoveAttachFileInfoDatas([file]).subscribe( (result) => { if (result.Success) { MsgHelper.ShowSuccessMessage('移除附件数据成功!'); this.getAttachFileInfoDatas(); } else { MsgHelper.ShowWarningMessage(`移除附件数据失败!${result.Message}`); } this.fileAreaLoading = false; }, () => { this.fileAreaLoading = false; } ); }); } }