import { RhProductionOrderManageService } from '../../production-order-manage/production-order-manage.service'; import { Component, EventEmitter, Input, OnInit, Output, SimpleChanges } from '@angular/core'; import { DataResultT, RhSafeAny, RhSelectableDto, RhBaseDto } from 'rh-base/model'; import { MsgHelper } from 'rh-base/core'; /** * 生产补料单明细来源,根据补料单计划单号查询 */ @Component({ selector: 'rh-product-plan-bom-table', templateUrl: './product-plan-bom-table.component.html', styleUrls: ['./product-plan-bom-table.component.less'] }) export class ProductPlanBomTableComponent implements OnInit { @Input() rhDefaultQueryDto: RhBaseDto = {}; @Input() rhName = 'ProductPlanBom'; @Output() rhModelChange = new EventEmitter(); /** 表格Loading */ dataLoading = false; dataresult!: DataResultT; selectedDatas!: RhSelectableDto[]; /** 设置默认的table显示字段 */ defaultTableFieldDataset: RhSafeAny = [ { name: 'ParentMaterialCode', displayName: '父物料编码', width: 150 }, { name: 'ProductBomCode', displayName: '产品BOM编码', width: 150 }, { name: 'VersionCode', displayName: '产品BOM版本号', width: 150 }, { name: 'MaterialCode', displayName: '物料代码', width: 120 }, { name: 'MaterialName', displayName: '物料名称', width: 120 }, { name: 'MaterialSpecification', displayName: '物料规格', width: 200, rhEllipsis: true }, { name: 'ProcessCode', displayName: '工序编码', width: 120 }, { name: 'ProcessName', displayName: '工序名称', width: 120 }, ]; constructor(private operator: RhProductionOrderManageService) { } ngOnInit(): void { } ngOnChanges(changes: SimpleChanges): void { const { rhDefaultQueryDto } = changes; if (rhDefaultQueryDto && rhDefaultQueryDto.currentValue) { this.getProductPlanBomDataByPlan(); } } onSelectedDatasChange(datas: RhSelectableDto[]) { this.selectedDatas = datas; this.rhModelChange.emit(this.selectedDatas); } getProductPlanBomDataByPlan() { this.dataLoading = true; this.operator.GetProductPlanBomDataByPlan(this.rhDefaultQueryDto?.['planOrderId']).subscribe(res => { if (res.Success) { const dataset = res.Attach?.[0]?.['BomDetails'] || []; dataset.forEach((data: { SourceOrderId: any; }) => { data.SourceOrderId = res.Attach[0]['ProductionPlanCode']; }); this.dataresult = { Attach: dataset, TotalCount: dataset.length, Success: true } as RhSafeAny; } else { this.dataresult = { Attach: [], TotalCount: 0 } as RhSafeAny; MsgHelper.ShowWarningMessage(`查询无数据!${res.Message}`); } this.dataLoading = false; }, () => this.dataLoading = false) } }