import { ProcessRoutingFlowChartQueryDto } from './../../business-model'; import { RhBusinessService } from './../../business.service'; import { ProcessRoutingOutPutDto, ProcessRoutingFlowChartDto } from '../../business-model'; import { RhFlowchartDisplayType } from 'rh-base/shared'; import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core'; import * as go from 'gojs'; import { MsgHelper } from 'rh-base/core'; // const init_x_xis = -300; // const init_y_aixs = 100; @Component({ selector: 'rh-process-route-flowchart', templateUrl: './process-route-flowchart.component.html', styleUrls: ['./process-route-flowchart.component.less'] }) export class RhProcessRouteFlowchartComponent implements OnInit, OnChanges { @Input() rhData!: ProcessRoutingOutPutDto; flowchartData: ProcessRoutingFlowChartDto | null = null; diagramDisplayDto!: RhFlowchartDisplayType; goModel!: go.Model; FlowChartDto = {}; constructor(private operator: RhBusinessService) {} ngOnInit(): void { // } ngOnChanges(changes: SimpleChanges) { const { rhData } = changes; if (rhData && rhData.currentValue) { // this.getMappedDatas(this.rhData); // this.goModel = this.transformProcessInfoDatasToDiagramDisplayDto(this.rhData.EntryDtos); this.getProcessRoutingEntryFlowChartDatas(); } } // getMappedDatas(data: ProcessRoutingOutPutDto) { // this.operator.GetProcessRoutingFlowChartData(data).subscribe((result) => { // if (result && result.Success) { // this.flowchartData = result.Attach.FlowChartDto; // } else { // this.flowchartData = null; // } // }); // } /** 获取流程图消息 */ private getProcessRoutingEntryFlowChartDatas() { const queryDto = ProcessRoutingFlowChartQueryDto.create(); queryDto.ProcessRoutingCode = this.rhData.ProcessRoutingCode; this.operator.GetProcessRoutingEntryFlowChartDatas(queryDto).subscribe((result) => { if (result.Success) { this.flowchartData = result.Attach; if (this.flowchartData.ProcessRoutingFlowChartContent) { this.goModel = go.Model.fromJson(this.flowchartData.ProcessRoutingFlowChartContent); } else { this.goModel = this.operator.transformProcessInfoDatasToDiagramDisplayDto(this.flowchartData.EntryDtos); } MsgHelper.ShowSuccessMessage('获取工艺路线流程图成功!'); } else { this.flowchartData = null; MsgHelper.ShowWarningMessage(`获取工艺路线流程图失败!${result.Message}`); } }); } // private transformProcessInfoDatasToDiagramDisplayDto(dataset: ProcessRoutingEntryDto[]): go.GraphLinksModel { // // const temp: RhFlowchartDisplayType = { JsonFile: null }; // const model = new go.GraphLinksModel(); // const linkDataArray: RhFlowchartLinkDataDto[] = []; // const nodeDataArray = dataset // .sort((a, b) => a.ProcessSeq - b.ProcessSeq) // .map((ele, index) => { // const node = RhFlowchartNodeDataDto.create(ele.ProcessSeq, 'Procedure', ele.ProcessName); // const coordinate = [init_x_xis + (index + 1) * 100, init_y_aixs]; // node.loc = coordinate.toString(); // // 添加连接线 // if (index === 0) { // linkDataArray.push(RhFlowchartLinkDataDto.create(-1, index + 1)); // dataset.length === 1 // ? linkDataArray.push(RhFlowchartLinkDataDto.create(index + 1, -2)) // : linkDataArray.push(RhFlowchartLinkDataDto.create(index + 1, index + 2)); // } else if (index === dataset.length - 1) { // linkDataArray.push(RhFlowchartLinkDataDto.create(index + 1, -2)); // } else { // linkDataArray.push(RhFlowchartLinkDataDto.create(index + 1, index + 2)); // } // return node; // }); // model.nodeDataArray = [...nodeDataArray, ...blankTemplateDatas]; // model.linkDataArray = linkDataArray; // return model; // } }