import { ProcessRoutingOutPutDto } from './../../mdp-model'; import { RhSafeAny, DataResultT, RhSelectableDto, CodeClassModel, RhDynamicTableFieldDto, RhTableQueryOptionDto, RhTableButtonInfoDto, RhBaseDto, OpMode, RhDynamicInterfaceDto, RhDynamicComponentFieldType } from 'rh-base/model'; import { Component, OnInit, ViewChild } from '@angular/core'; import { DynamicFormComponent } from 'rh-base/shared'; import { ActivatedRoute } from '@angular/router'; import { MsgHelper, ObjectHelper, RhNavigatorService } from 'rh-base/core'; /** 编辑类型:编辑表头|关联工序 */ type EditType = 'edit' | 'relateStage' | 'relateProduct' | 'processRouteDiagram'; @Component({ selector: 'rh-process-route-manage', templateUrl: './process-route-manage.component.html', styleUrls: ['./process-route-manage.component.less'] }) export class RhProcessRouteManageComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; editDto: RhBaseDto = {}; dataLoading = false; dataresult!: DataResultT; defaultFieldDataset: RhDynamicComponentFieldType[] = []; defaultExportInterface!: RhDynamicInterfaceDto; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('edit', '编辑工艺路线', 'default', false, 'edit', false, null, (data) => this.openEditModal(data)), new RhTableButtonInfoDto('relatedStage', '关联工序', 'default', false, 'link', false, null, (data) => this.openRelateStageTab(data as RhBaseDto) ), new RhTableButtonInfoDto('relatedProduct', '关联产品', 'default', false, 'link', false, null, (data) => this.openRelateProductTab(data as RhBaseDto) ), new RhTableButtonInfoDto('createDiagram', '制作工艺路线图', 'default', false, 'snippets', false, null, (data) => this.openProcessRouteDiagramTab(data as RhBaseDto) ) ]; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('new', '新建', 'primary', false, 'file', false, null, () => this.openEditModal(), true) ]; defaultQueryDto: RhSafeAny = {}; currentEditType: EditType = 'edit'; selectedRouteDto!: ProcessRoutingOutPutDto; constructor(private navigator: RhNavigatorService, private route: ActivatedRoute) { // } ngOnInit(): void { // this.initQueryDto(); } initQueryDto() { this.route.queryParamMap.subscribe((result) => { this.defaultQueryDto = { FactoryCode: result.get('FactoryCode'), ProcessRoutingCode: result.get('ProcessRoutingCode') }; setTimeout(() => { if (this.queryFormCmt.dynamicStorageDto?.hostConfig?.interface) this.getDatas(); }); }); } exportInterfaceChange(item: RhDynamicInterfaceDto) { this.defaultExportInterface = item; } openEditModal(data?: RhBaseDto) { // if (data) { this.editDto = data; this.editDto.OpSign = OpMode.OpEdit; } else { this.editDto = {}; this.editDto.OpSign = OpMode.OpAdd; } this.currentEditType = 'edit'; this.selectedIndex = 1; } closeEditModal() { // this.resetEditType(); this.selectedIndex = 0; } openRelateStageTab(data: RhBaseDto) { this.currentEditType = 'relateStage'; this.selectedRouteDto = data as ProcessRoutingOutPutDto; this.selectedIndex = 1; } openRelateProductTab(data: RhBaseDto) { this.currentEditType = 'relateProduct'; this.selectedRouteDto = data as ProcessRoutingOutPutDto; this.selectedIndex = 1; } openProcessRouteDiagramTab(data: RhBaseDto) { this.currentEditType = 'processRouteDiagram'; this.selectedRouteDto = data as ProcessRoutingOutPutDto; this.selectedIndex = 1; } navigateToUrl(data: RhSafeAny) { this.navigator.navigatorTrigger('/main/Test/demo2', { FactoryCode: data.FactoryCode }); } setDatas(dataset: DataResultT) { this.dataresult = dataset; } dataLoadingChange(status: boolean) { this.dataLoading = status; } onStoreData(result: DataResultT) { if (result && result.Success) { const msg = this.editDto.OpSign === OpMode.OpAdd ? '新增' : '编辑'; MsgHelper.ShowSuccessMessage(`${msg}数据成功!`); if (this.editDto.OpSign === OpMode.OpEdit) { this.selectedIndex = 0; } this.editDto = ObjectHelper.createRhBaseDto(); this.getDatas(); } else { MsgHelper.ShowWarningModal(`存储数据失败!${result.Message}`); } } 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) { this.queryFormCmt.submitDefaultForm(null, option); } } private resetEditType() { this.currentEditType = 'edit'; } upgradeSuccess() { this.getDatas(); } }