import { RhQmpService } from './../../qmp.service'; import { EmployeeInfoDto, EmployeeMessageNotifyGroupConfigDto, IpqcProductInspectSchemaQueryDto, ProcessInspectParameter, ProductProcessRouteQueryDto, View_MessageNotifyGroupDto, View_MessageNotifyGroupQueryDto, ProcessInspectRulesDto, IpqcProductInspectSchemaGroupDto, IpqcProductInspectSchemaDto, SynchronousIpqcProductInspectSchemaByProductDto, SelectedInspectCategoryDto, SelectedProductDto, SynchronousIpqcProductInspectSchemaByGroupDto, DataImportInput, DataStoreDto, IpqcProductInspectDatasExportDto, IpqcProductInspectDatas } from './../../qmp-model'; import { Component, OnInit, ViewChild } from '@angular/core'; import { MsgHelper, ObjectHelper, RhApiUrlsService, FileHelper, DateHelper } from 'rh-base/core'; import { RhPortType, RhPortLocalFieldType, RhDynamicComponentFieldType } from 'rh-base/model'; import { CodeClassModel, DataResultT, OpMode, OpResult, RhBaseDto, RhDynamicTableFieldDto, RhSafeAny, RhSelectableDto, RhSelectItem, RhTableButtonInfoDto, RhTableQueryOptionDto } from 'rh-base/model'; import { DynamicFormComponent, MaterialDocumentDto } from 'rh-base/shared'; import { RhProcessControlService } from '../process-control.service'; import { UntypedFormGroup } from '@angular/forms'; import { cloneDeep } from 'lodash'; import { firstValueFrom, Observable, Observer } from 'rxjs'; import { NzModalService } from 'ng-zorro-antd/modal'; import { NzTreeNode } from 'ng-zorro-antd/tree'; import { NzUploadFile } from 'ng-zorro-antd/upload'; @Component({ selector: 'rh-ipqc-product-inspect-schema', templateUrl: './ipqc-product-inspect-schema.component.html', styleUrls: ['./ipqc-product-inspect-schema.component.less'] }) export class RhIpqcProductInspectSchemaComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; dataLoading = false; dataresult!: DataResultT; tabType: 'newschema' | 'edit' | 'entry' | 'paraConfig' | 'processRoute' | null = null; selectData!: RhBaseDto; defaultFieldDataset: RhDynamicComponentFieldType[] = []; defaultQueryDto: RhSafeAny = {}; //选中的方案 SelectedSchemaDtos: IpqcProductInspectSchemaDto[] = []; //选中的检验组 SelectedInspectGroup!: string; isShowInspectGroupModal = false; // 同步方案(产品) isShowSyncModal = false; SelectedProductDatas: MaterialDocumentDto[] = []; SelectInspectTypes!: SelectedInspectCategoryDto; SelectInspectTypeList: RhSafeAny[] = []; // 同步方案(检验组) SourceSchemaDto: IpqcProductInspectSchemaDto | null = null; SelectedGroup: { label: string; value: string; checked?: boolean; disabled?: boolean; }[] = []; SelectedInspectGroups: string[] = []; count = 1; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'setting', '设置检验组', 'default', false, 'setting', false, null, (data) => this.openInspectGroup(data as IpqcProductInspectSchemaDto[]), false ) ]; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('edit', '编辑', 'default', false, 'edit', false, null, (data) => this.openEditTab(data as RhBaseDto)), new RhTableButtonInfoDto( 'details', '方案明细', 'default', false, 'unordered-list', false, null, (data) => this.openEntryDatasTab(data as RhBaseDto), true, false, 'green' ), new RhTableButtonInfoDto( 'sync', '同步方案', 'default', false, 'sync', false, null, (data) => this.openSyncModal(data as RhBaseDto), true, false, 'green' ) ]; extraButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('import', '导入Excel', 'default', 'import', false, null, () => this.openImportModal(), true) ]; //树内选中的物料(产品) selectedMaterial: { MaterialCode: string; MaterialName: string; MaterialSpecification: string; } | null = null; //选中的产品节点信息 selectedNode!: NzTreeNode; /** 绑定的工艺路线集合 */ ProcessRouteItems: RhSelectItem[] = []; /** 选中的工艺路线 */ selectedProcessRoute: RhSelectItem | null = null; /** 是否显示绑定的工艺路线 */ isShowGrandsonNode = false; //选择员工Modal isShowInspectorModal = false; selectEmployeeData: EmployeeInfoDto | null = null; editForm!: UntypedFormGroup; saveLoading = false; //#region 新建方案区域 editDto: RhBaseDto = {}; startDate!: Date; endDate!: Date; // rangeDate: Date[] = []; inspectCategoryInEdit: { label: string; value: string; checked?: boolean; disabled?: boolean; }[] = []; /** 质量人员 && 组 */ qualityInspectGroup: EmployeeMessageNotifyGroupConfigDto[] = []; qualityInspector: View_MessageNotifyGroupDto[] = []; //#endregion // //#region ********** ipqc检验方案明细 ********** inspectCategoryList: RhSelectItem[] = []; /** 当前选中的检验类别 */ selectedInspectCategory!: string; inspectParaDatas!: ProcessInspectParameter; //#endregion 新建方案区域结束 //#region 数据导入 isShowUploadDrawer = false; /** 上传的文件数据模型列表 */ uploadDatas: RhSafeAny; uploadFileList: NzUploadFile[] = []; uploading = false; // 导入的数据 importDatas: RhSafeAny[] = []; //数据导入页面 isOpenImportTab = false; isAddAfterDeleteAll = false; tableWidth = '0px'; // 导入数据返回的表头信息 dataHeadFields: { FieldName: string; FieldDescription: string }[] = []; //#endregion 数据导入 //#region 明细数据导出 detailDatas: RhSafeAny = []; //#endregion 明细数据导出 dataHandler = (data: RhBaseDto) => { data['ValidStartDate'] = this.startDate; data['ValidEndDate'] = this.endDate; // 检验类别赋值 this.inspectCategoryInEdit.forEach((ele) => { data[ele.value] = ele.checked; }); return true; }; // 工艺路线检验方案维护 constructor( private qmpSer: RhQmpService, private operator: RhProcessControlService, private apiUrl: RhApiUrlsService, private modal: NzModalService ) { // } ngOnInit() { // 获取检验方案类别list this.getInspectCategory(); this.inspectParaDatas = ProcessInspectParameter.create(); } // selectedMaterialCode(item: RhSafeAny) { // if (item) { // this.selectedMaterial = item; // this.getDatas(); // /** 获取绑定的工艺路线集合 */ // this.getBindingProcessRouteItems(); // } // } getProcessRouteInfo(ProcessRoute: RhSelectItem) { this.selectedProcessRoute = ProcessRoute; this.getDatas(); } getSelectedNode(node: NzTreeNode) { this.selectedNode = node; if (node && node.origin['customData']) { const data = node.origin['customData']; if (node.level === 2 && node.isSelected) { this.selectedMaterial = node.parentNode?.origin['customData']; this.selectedProcessRoute = data; this.getDatas(); } if (node.level === 1 && node.isSelected) { this.selectedMaterial = data; this.selectedProcessRoute = null; this.getDatas(); /** 获取绑定的工艺路线集合 */ this.getBindingProcessRouteItems(); } } else { this.selectedProcessRoute = null; this.selectedMaterial = null; } } getBindingProcessRouteItems() { this.isShowGrandsonNode = true; if (this.selectedNode.level === 1) { this.ProcessRouteItems = []; const queryDto = ProductProcessRouteQueryDto.create(); queryDto.ProductCode = this.selectedMaterial?.MaterialCode; // queryDto.ProductName = this.selectedMaterial?.MaterialName; this.operator.GetProductBindingProcessRouteItems(queryDto).subscribe((result) => { if (result && result.Success) { this.ProcessRouteItems = result.Attach; } else { this.ProcessRouteItems = []; } }); } } //#region 表头查询 setDatas(dataset: DataResultT) { this.dataresult = dataset; if (!this.dataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataresult?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDatset(item: CodeClassModel) { const tempDatas: RhDynamicComponentFieldType[] = []; item.CodeProperties.forEach((ele) => { const temp = RhDynamicTableFieldDto.create(); temp.name = ele.PropertyName; temp.displayName = ele.Descirption; tempDatas.push(temp); }); this.defaultFieldDataset = [...tempDatas]; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } //调用子组件中的接口 private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { const queryDto: RhSafeAny = {}; queryDto.ProductCode = this.selectedMaterial?.MaterialCode; if (this.selectedNode?.level === 2) { queryDto.ProcessRoutingCode = this.selectedProcessRoute?.Value; } else if (this.selectedNode?.level === 1) { queryDto.ProcessRoutingCode = null; } this.defaultQueryDto = queryDto; setTimeout(() => { this.queryFormCmt.submitDefaultForm(null, option); }); } } //#endregion // //#region 新建方案 openNewSchemaTab() { if (this.selectedProcessRoute) { this.tabType = 'processRoute'; } else { this.tabType = 'newschema'; } this.editDto = {}; this.editDto.OpSign = OpMode.OpAdd; // this.rangeDate = []; // 获取数据方案数据(用于数据编辑) this.getIpqcProductCreatedInspectSchemaData(); } // closeNewSchemaTab() { // this.tabType = null; // this.selectedIndex = 0; // this.getDatas(); // } onEditInspectRuleChange(data: ProcessInspectRulesDto) { const temp = cloneDeep(this.editDto); temp['InspectRulesDto'] = data; this.editDto = temp; } // 获取检验人员 getQualityInspector() { const queryDto = View_MessageNotifyGroupQueryDto.create(); queryDto.Mode = 8; this.qmpSer.GetEmployeeMessageNotifyGroupViewDatas(queryDto).subscribe((result) => { if (result && result.Success) { this.qualityInspector = result.Attach; } else { this.qualityInspector = []; } }); } // 获取检验类别 private getInspectCategory() { this.apiUrl .getSettingEntry({ moduleKey: 'QualityManagement', groupKey: 'ProcessInspectOrderConst', paraCode: 'InspectCategory' }) .subscribe((result) => { if (result && result.Success) { // 用于检验方案明细顶部的展示和切换 this.inspectCategoryList = result.Attach; // 用于新建、编辑方案的外部传入控件 this.inspectCategoryList.forEach((ele) => { this.inspectCategoryInEdit.push({ label: ele.Text, value: ele.Value?.toString() as string, checked: false }); }); } else { this.inspectCategoryList = []; this.inspectCategoryInEdit = []; } }); } getIpqcProductCreatedInspectSchemaData() { const queryDto = IpqcProductInspectSchemaQueryDto.create(); if (this.selectedMaterial?.MaterialCode) { queryDto.ProductCode = this.selectedMaterial.MaterialCode; if (this.selectedNode) { if (this.selectedNode.level === 2) { queryDto.ProcessRoutingCode = this.selectedProcessRoute?.Value?.toLocaleString(); } } } this.operator.GetIpqcProductCreatedInspectSchemaData(queryDto).subscribe((result) => { if (result && result.Success) { if (result.Attach.ProductCode) { ObjectHelper.MapT(result.Attach, this.editDto); // this.editDto['ValidDateRange'] = [result.Attach.ValidStartDate, result.Attach.ValidEndDate]; // this.rangeDate[0] = result.Attach.ValidStartDate; // this.rangeDate[1] = result.Attach.ValidEndDate; this.inspectCategoryInEdit.forEach((ele) => { ele.checked = this.editDto[ele.value]; // 新建时已经选中的检验类型无法编辑 ele.disabled = ele.checked; }); } else { if (this.selectedMaterial?.MaterialCode) { this.editDto['ProductCode'] = this.selectedMaterial.MaterialCode; this.editDto['ProductName'] = this.selectedMaterial.MaterialName; this.editDto['ProductSpecification'] = this.selectedMaterial.MaterialSpecification; this.inspectCategoryInEdit.forEach((ele) => { ele.checked = false; }); if (this.selectedNode.level === 2) { this.editDto['ProcessRoutingCode'] = this.selectedProcessRoute?.Value; this.editDto['ProcessRoutingName'] = this.selectedProcessRoute?.Text; } } } this.inspectCategoryInEdit = [...this.inspectCategoryInEdit]; } this.selectedIndex = 1; }); } // 打开员工选择框 closeInspectorModal() { this.isShowInspectorModal = false; } openInspectorModal(formGroup: UntypedFormGroup) { this.editForm = formGroup; this.isShowInspectorModal = true; } // 从维护人员组件中获取到的人员 getAssignEmployee(data: View_MessageNotifyGroupDto) { const selectedEmp = EmployeeInfoDto.create(); selectedEmp.EmployeeCode = data?.EmployeeCode; selectedEmp.EmployeeName = data?.EmployeeName; this.selectEmployeeData = selectedEmp.EmployeeCode ? selectedEmp : null; } // saveInspectorDates() { // this.editForm.get('QualityInspector').setValue(this.selectEmployeeData.EmployeeCode); // this.closeInspectorModal(); // } //#endregion // //#region 编辑方案 openEditTab(data: RhBaseDto) { this.tabType = 'edit'; data.OpSign = OpMode.OpEdit; this.editDto = data; // this.rangeDate = []; // this.rangeDate[0] = data.ValidStartDate; // this.rangeDate[1] = data.ValidEndDate; this.editDto['ValidDateRange'] = [data['ValidStartDate'], data['ValidEndDate']]; this.selectedIndex = 1; } closeEditTab() { this.tabType = null; this.selectedIndex = 0; this.getDatas(); } //#endregion // //#region 检验方案明细 openEntryDatasTab(dto: RhBaseDto) { this.selectData = dto; this.selectedInspectCategory = dto['InspectCategory']; this.tabType = 'entry'; this.selectedIndex = 1; } closeEntryDatasTab() { this.tabType = null; this.selectedIndex = 0; } selectedInspectCategoryChange(category: string) { if (category) { const queryDto = IpqcProductInspectSchemaQueryDto.create(); // ObjectHelper.MapT(this.selectData, queryDto); queryDto.InspectSchemaBasisCode = this.selectData['InspectSchemaBasisCode']; queryDto.InspectSchemaCode = this.selectData?.['InspectSchemaCode']; queryDto.InspectCategory = category; queryDto.ProductCode = this.selectData['ProductCode']; queryDto.ProcessRoutingCode = this.selectData['ProcessRoutingCode']; queryDto.ProcessRoutingEntryCode = this.selectData['ProcessRoutingEntryCode']; this.refreshIpqcProductInspectSchemaData(queryDto); } } // 刷新表头数据 refreshIpqcProductInspectSchemaData(dto: IpqcProductInspectSchemaQueryDto) { this.operator.GetIpqcProductInspectSchemaDataBy(dto).subscribe((result) => { if (result && result.Success) { this.selectData = ObjectHelper.createRhBaseDto(); ObjectHelper.MapT(result.Attach, this.selectData); this.selectData = { ...this.selectData }; } else { MsgHelper.ShowWarningMessage('暂无数据'); this.selectedInspectCategory = this.selectData['InspectCategory']; } }); } //#endregion // //#region 检验参数 openParaConfigTab() { if (this.selectedMaterial) { // this.getProcessInspectParameterData(); this.tabType = 'paraConfig'; this.selectedIndex = 1; } else { MsgHelper.ShowWarningMessage('请先选择产品!'); return; } } closeParaConfigTab() { this.tabType = null; this.selectedIndex = 0; } //#endregion // //#region 设置检验组 openInspectGroup(datas: IpqcProductInspectSchemaDto[]) { this.SelectedSchemaDtos = datas; this.isShowInspectGroupModal = true; } closeInspectGroup() { this.isShowInspectGroupModal = false; } setInspectGroup() { if (!this.SelectedInspectGroup) { MsgHelper.ShowWarningMessage('请先选择检验组!'); return; } const queryDto = IpqcProductInspectSchemaGroupDto.create(); queryDto.SelectedSchemaDtos = this.SelectedSchemaDtos; queryDto.InspectGroup = this.SelectedInspectGroup; this.operator.SetupIpqcProductInspectSchemaGroup(queryDto).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('数据存储成功'); this.closeInspectGroup(); } else { MsgHelper.ShowWarningMessage(`数据存储失败!${result.Message}`); } }); } //#endregion 设置检验组 //#region 同步方案 openSyncModal(data?: RhSafeAny) { if (data) { this.SourceSchemaDto = data; } else { this.SourceSchemaDto = null; } this.isShowSyncModal = true; } closeSyncModal() { this.isShowSyncModal = false; } // 获取选中的产品 getSelectedProductDatas(datas: MaterialDocumentDto[]) { this.SelectedProductDatas = datas; } getSelectedInspectType(datas: RhSafeAny[]) { this.SelectInspectTypeList = datas; } SynchronousIpqcProductInspectSchemaByProduct() { const queryDto = SynchronousIpqcProductInspectSchemaByProductDto.create(); const SelectInspectTypes = SelectedInspectCategoryDto.create(); this.SelectInspectTypeList.forEach((ele) => { if (ele.checked === true) { if (ele.value === 'FirstInspect') { SelectInspectTypes.FirstInspect = true; } if (ele.value === 'ProfessionalInspect') { SelectInspectTypes.ProfessionalInspect = true; } if (ele.value === 'SpecialInspect') { SelectInspectTypes.SpecialInspect = true; } if (ele.value === 'SampleInspect') { SelectInspectTypes.SampleInspect = true; } if (ele.value === 'PatrolInspect') { SelectInspectTypes.PatrolInspect = true; } if (ele.value === 'RegularInspect') { SelectInspectTypes.RegularInspect = true; } } }); queryDto.SelectedInspectCategory = SelectInspectTypes; queryDto.SourceProductCode = this.selectedMaterial?.MaterialCode; queryDto.SelectedProducts = this.SelectedProductDatas.map((ele) => { const temp = {} as SelectedProductDto; temp.ProductCode = ele.MaterialCode; temp.ProductName = ele.MaterialName; temp.ProductSpecification = ele.MaterialSpecification; return temp; }); this.operator.SynchronousIpqcProductInspectSchemaByProduct(queryDto).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('数据存储成功'); this.closeSyncModal(); } else { MsgHelper.ShowWarningMessage(`数据存储失败!${result.Message}`); } }); } getSelectedInspectGroup(item: RhSafeAny) { this.SelectedGroup = item; } SynchronousIpqcProductInspectSchemaByGroup() { const queryDto = SynchronousIpqcProductInspectSchemaByGroupDto.create(); queryDto.SourceSchemaDto = this.SourceSchemaDto; const SelectInspectTypes = SelectedInspectCategoryDto.create(); this.SelectInspectTypeList.forEach((ele) => { if (ele.checked === true) { if (ele.value === 'FirstInspect') { SelectInspectTypes.FirstInspect = true; } if (ele.value === 'ProfessionalInspect') { SelectInspectTypes.ProfessionalInspect = true; } if (ele.value === 'SpecialInspect') { SelectInspectTypes.SpecialInspect = true; } if (ele.value === 'SampleInspect') { SelectInspectTypes.SampleInspect = true; } if (ele.value === 'PatrolInspect') { SelectInspectTypes.PatrolInspect = true; } if (ele.value === 'RegularInspect') { SelectInspectTypes.RegularInspect = true; } } }); queryDto.SelectedInspectCategory = SelectInspectTypes; //先置空 this.SelectedInspectGroups = []; this.SelectedGroup.forEach((ele) => { if (ele.checked === true) { this.SelectedInspectGroups.push(ele.value); } }); queryDto.SelectedInspectGroups = this.SelectedInspectGroups; this.operator.SynchronousIpqcProductInspectSchemaByGroup(queryDto).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('数据存储成功'); } else { MsgHelper.ShowWarningMessage(`数据存储失败!${result.Message}`); } }); } //#endregion //#region 导入Excel /*******************************************导入Excel******************************************** */ openImportTab() { this.isOpenImportTab = true; this.isAddAfterDeleteAll = false; this.selectedIndex = 1; } closeImportTab() { this.isOpenImportTab = false; this.selectedIndex = 0; } // 导入设备类别 openImportModal() { this.isShowUploadDrawer = true; } closeUploadFileDrawer() { this.isShowUploadDrawer = false; this.uploadFileList = []; } beforeUpload = (file: NzUploadFile) => { if (this.uploadFileList.length >= 1) { MsgHelper.ShowWarningMessage('每次只能上传一个文件!'); return false; } return new Observable((observer: Observer) => { const reader = new FileReader(); reader.readAsDataURL(file as RhSafeAny); reader.onload = () => { const importQueryDto = DataImportInput.create(); importQueryDto.FileStreamString = reader.result as RhSafeAny; this.uploadDatas = importQueryDto; // 只有一个文件 this.uploadFileList = this.uploadFileList.concat(file); // this.uploadFileList = [file]; observer.next(false); observer.complete(); }; reader.onerror = (e) => { MsgHelper.ShowWarningModal(`读取文件失败!${e}`); observer.next(false); observer.complete(); }; }); }; // 导入 handleImport() { this.uploading = true; this.uploadDatas.BusinessCode = 'IpqcInspectSchemaImporter'; this.operator.DataImport(this.uploadDatas).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('文件导入成功!'); this.importDatas = result.Attach; this.dataHeadFields = result.DataHeadFields as RhSafeAny; this.tableWidth = this.dataHeadFields.length * 120 + 100 + 'px'; this.closeUploadFileDrawer(); this.getDatas(); this.openImportTab(); } else { MsgHelper.ShowWarningModal(`文件导入失败!${result.Message}`); } this.uploading = false; }, () => (this.uploading = false) ); } async storeImportedDatas() { if (this.importDatas.some((f) => !f.Success)) { MsgHelper.ShowWarningMessage('请修改错误或重新导入后保存!'); return; } const businessType = 'IpqcInspectSchemaImporter'; let result: OpResult | null = null; if (this.isAddAfterDeleteAll) { this.importDatas.forEach((f) => (f.OpSign = OpMode.OpAddAfterDeleteAll)); } else { this.importDatas.forEach((f) => (f.OpSign = OpMode.OpAdd)); } try { const dto = DataStoreDto.create(); dto.BusinessCode = businessType; dto.DataGroup = this.importDatas; result = await firstValueFrom(this.operator.DataStore(dto)); } catch (error) { MsgHelper.ShowErrorMessage(`保存错误!${error}`); } if (result) { if (result.Success) { MsgHelper.ShowSuccessMessage('保存成功!'); this.importDatas = []; this.closeImportTab(); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`保存失败!${result.Message}`); } } } /** 清空数据 */ clearImportedPlanDatas() { MsgHelper.ShowConfirmModal('是否继续', '是否清空所有导入的模板数据?', () => { this.importDatas = []; MsgHelper.ShowSuccessMessage('数据清空成功!'); }); } changeIsAddAfterDeleteAll(value: boolean) { if (value) { this.modal.confirm({ nzTitle: '警告!', nzContent: '若勾选此项,将会进行不可逆的删除,是否确认?', nzOnCancel: () => { this.isAddAfterDeleteAll = false; }, nzOkType: 'primary', nzOkDanger: true, nzIconType: 'warning' }); } } getDataType(data: string) { if (data) { const tmp = data.toString().trim().toLowerCase(); const dateReg = new RegExp(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?/, 'i'); if (['true', 'false'].includes(tmp)) { return 'boolean'; } else if (dateReg.test(data)) { return 'date'; } } return 'string'; } removeImportTempData(index: number) { MsgHelper.ShowConfirmModal('是否继续', '是否移除选中的模板数据?', () => { this.importDatas.splice(index, 1); this.importDatas = [...this.importDatas]; }); } //#endregion 导入Excel //#region 数据导出 getDataResult(data: DataResultT) { if (data && data.Attach) { if (data.Record == data.TotalCount) { this.detailDatas = data.Attach; } } else { this.detailDatas = []; } } exportDetailDatas() { const dto = IpqcProductInspectDatasExportDto.create(); dto.BusinessCode = 'IpqcProductInspectSchemaFullExport'; dto.DataGroup = []; const queryDto = IpqcProductInspectDatas.create(); /** 检验方案编码 */ queryDto.InspectSchemaCode = this.selectData['InspectSchemaCode']; /** 检验方案名称 */ queryDto.InspectSchemaName = this.selectData['InspectSchemaName']; /** 检验方案基础编码 */ queryDto.InspectSchemaBasisCode = this.selectData['InspectSchemaBasisCode']; /** 检验组别 */ queryDto.InspectGroup = this.selectData['InspectGroup']; /** 检验类别 */ queryDto.InspectCategory = this.selectData['InspectCategory']; /** 产品编码 */ queryDto.ProductCode = this.selectData['ProductCode']; /** 产品名称 */ queryDto.ProductName = this.selectData['ProductName']; /** 产品规格 */ queryDto.ProductSpecification = this.selectData['ProductSpecification']; /** 工艺路线编码 */ queryDto.ProcessRoutingCode = this.selectData['ProcessRoutingCode']; /** 工艺路线名称 */ queryDto.ProcessRoutingName = this.selectData['ProcessRoutingName']; /** 工序唯一编码 */ queryDto.ProcessRoutingEntryCode = this.selectData['ProcessRoutingEntryCode']; /** 工序代码 */ queryDto.ProcessCode = this.selectData['ProcessCode']; /** 工序名称 */ queryDto.ProcessName = this.selectData['ProcessName']; /** 产品图纸号 */ queryDto.ProductDrawCode = this.selectData['ProductDrawCode']; /** 检验规则 */ queryDto.InspectRules = this.selectData['InspectRules']; /** 开始有效期 */ queryDto.ValidStartDate = this.selectData['ValidStartDate']; /** 结束有效期 */ queryDto.ValidEndDate = this.selectData['ValidEndDate']; /** 检验规范文件 */ queryDto.InspectStandardFile = this.selectData['InspectStandardFile']; /** 质量人员 */ queryDto.QualityInspector = this.selectData['QualityInspector']; /** 质量人员组 */ queryDto.QualityInspectGroup = this.selectData['QualityInspectGroup']; /** 是否启用 */ queryDto.IsUse = this.selectData['IsUse']; /** 备注 */ queryDto.Remark = this.selectData['Remark']; /** 明细数据 */ queryDto.ReportEntryDtos = this.detailDatas; dto.DataGroup.push(queryDto); // 文件流读取文件 MsgHelper.ShowGlobalLoadingMessage('正在导出数据,请稍候。。。'); const url = this.apiUrl.GetApiOperateUrl( RhPortType.emp, 'DataImportExportApi', 'IpqcProductInspectSchemaDataExport', RhPortLocalFieldType.emp ); FileHelper.PostFileBlob(url, dto).subscribe( (result) => { const fileUrl = FileHelper.CreateDownloadFileUrl(result); const anchor = document.createElement('a'); anchor.download = '检验方案明细报告' + DateHelper.format(new Date(Date.now()), 'yyyy-MM-dd HH:mm:ss') + '.xlsx'; anchor.href = fileUrl; anchor.click(); setTimeout(() => { MsgHelper.CloseGlobalLoadingMessage(); }, 300); }, () => { MsgHelper.CloseGlobalLoadingMessage(); } ); } //#endregion 数据导出 }