import { RhQmpService } from './../qmp.service'; import { RhSafeAny, RhBaseDto, RhDynamicInterfaceDto, RhDynamicComponentFieldType } from 'rh-base/model'; import { Component, OnInit, ViewChild } from '@angular/core'; import { MsgHelper, RhNavigatorService } from 'rh-base/core'; import { DataResultT, RhSelectableDto, CodeClassModel, RhDynamicTableFieldDto, RhTableQueryOptionDto, RhTableButtonInfoDto } from 'rh-base/model'; import { DynamicFormComponent } from 'rh-base/shared'; import { NzTreeNode } from 'ng-zorro-antd/tree'; @Component({ selector: 'rh-valid-date-manage', templateUrl: './valid-date-manage.component.html', styleUrls: ['./valid-date-manage.component.less'] }) export class RhValidDateManageComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; dataLoading = false; dataresult!: DataResultT; defaultFieldDataset: RhDynamicComponentFieldType[] = []; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('form', '生成复检单', 'default', false, 'edit', false, null, (data) => { this.createOverdueMaterialReInspectOrder(data as RhBaseDto); }), // 查看复检记录 new RhTableButtonInfoDto('view', '查看复检记录', 'default', false, 'eye', false, null, (data) => { this.openEditTab(data as RhBaseDto); }) ]; defaultQueryDto: Record = {}; //树内选中的物料 selectedMaterial: RhSafeAny; recordQueryInterfaceInfo: RhDynamicInterfaceDto = { port: 52882, interfaceType: 'post', controllerName: 'GdzMaterialInspectApi', interfaceName: 'GetIqcMaterialInventoryReInspectRecordDatas' }; recordQueryDto: Record = {}; constructor(private operator: RhQmpService, private navigator: RhNavigatorService) { // } ngOnInit(): void { // } closeEditTab() { this.selectedIndex = 0; } openEditTab(data: RhBaseDto) { this.initRecordQueryDto(data); this.selectedIndex = 1; } SelectedMaterialCode(node: NzTreeNode) { if (node && node.origin?.['customData']) { const data = node.origin['customData']; if (node.isSelected) { this.selectedMaterial = data; this.getDatas(); } } else { this.selectedMaterial = null; } } setDatas(dataset: DataResultT) { this.dataresult = dataset; if (!this.dataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataresult?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDataset(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 createOverdueMaterialReInspectOrder(data: RhBaseDto) { MsgHelper.ShowGlobalLoadingMessage('正在生成复检单,请稍候...'); this.operator.CreateOverdueMaterialReInspectOrder(data).subscribe( (result) => { if (result?.Success) { MsgHelper.ShowSuccessMessage(`生成复检单成功!!`); this.getDatas(); // 询问是否跳转到来料检验任务单界面 MsgHelper.ShowConfirmModal('是否跳转', '是否跳转到检验任务单页面?', () => { // this.router.navigate(['../IncomingInspectManagement'], { relativeTo: this.route }); this.navigator.navigatorTrigger('RH_IncomingInspectManagement', { InspectOrderCode: result.Message }); }); } else { MsgHelper.ShowWarningModal(`生成复检单失败!${result.Message}`); } MsgHelper.CloseGlobalLoadingMessage(); }, () => MsgHelper.CloseGlobalLoadingMessage() ); } //调用子组件中的接口 private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { const queryDto: RhSafeAny = {}; if (this.selectedMaterial?.MaterialCode) { queryDto.MaterialCode = this.selectedMaterial.MaterialCode ? `$${this.selectedMaterial.MaterialCode}` : null; } else { queryDto.MaterialCode = null; } this.defaultQueryDto = queryDto; setTimeout(() => { this.queryFormCmt.submitDefaultForm(null, option); }); } } private initRecordQueryDto(data: RhBaseDto) { this.recordQueryDto = data; } }