import { ProductionDispatchOrderDto } from './../../ppm-model'; import { Component, OnInit, ViewChild } from '@angular/core'; import { CodeClassModel, DataResultT, OpResult, RhBaseDto, RhDynamicTableFieldDto, RhLoginedUserDto, RhSafeAny, RhSelectableDto, RhTableButtonInfoDto, RhTableQueryOptionDto, WithNil } from 'rh-base/model'; import { MsgHelper } from 'rh-base/core'; import { DynamicFormComponent } from 'rh-base/shared'; import { RhProductionPerformService } from '../production-perform.service'; @Component({ selector: 'rh-product-plan-dispatch-maintenance', templateUrl: './product-plan-dispatch-maintenance.component.html', styleUrls: ['./product-plan-dispatch-maintenance.component.less'] }) export class RhProductPlanDispatchMaintenanceComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; editDto: RhBaseDto = {}; dataLoading = false; dataresult!: DataResultT; isShowEditModal = false; defaultFieldDataset: RhSafeAny = []; editButtonDataset: RhTableButtonInfoDto[] = []; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'release', '下达', 'primary', false, 'check-circle', false, null, () => this.issuedProductionDispatchOrder(), false ) ]; loginUser!: WithNil; selecedDatas: RhSelectableDto[] = []; selecedDispatchOrderDatas: ProductionDispatchOrderDto[] = []; constructor(private operator: RhProductionPerformService) { // } ngOnInit(): void { // } setDatas(dataset: DataResultT | OpResult) { this.dataresult = dataset as DataResultT; if (!this.dataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataresult?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDatset(item: CodeClassModel) { const tempDatas: RhSafeAny = []; 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) { this.queryFormCmt.submitDefaultForm(null, option); } } selectedDatasChange(dtos: RhSelectableDto[] | null) { if (dtos) { this.selecedDispatchOrderDatas = []; this.selecedDatas = dtos; this.selecedDatas.forEach((ele) => { this.selecedDispatchOrderDatas.push(ele as ProductionDispatchOrderDto); }); } } //#region ******** 下达 ******** issuedProductionDispatchOrder() { if (this.selecedDatas.some((ele) => ele['OrderStatus'] === 'Issued')) { MsgHelper.ShowWarningMessage(`所选派工单中包含已下达的派工单,无法执行派工单下达!`); return; } this.operator.IssuedProductionDispatchOrder(this.selecedDispatchOrderDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`派工单下达成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`派工单下达失败:${result.Message}`); } }); } //#endregion ******** 下达 ******** }