import { RhBusinessService } from './../../business.service'; import { SharedService } from 'rh-itm/shared'; import { MsgHelper, RhAppConfigService } from 'rh-base/core'; import { RhSafeAny } from 'rh-base/model'; import { RhMessageContentDto } from 'rh-itm/model'; import { Component, OnInit } from '@angular/core'; import { WorkShopLineInfoDto, WorkShopLineInfoQueryDto, WorkShopLineExtProperyQueryDto, WorkShopLineProductionParameter } from '../../business-model'; import { Router } from '@angular/router'; import { RhProcessControlService } from '../process-control.service'; @Component({ selector: 'rh-process-control-factory', templateUrl: './process-control-factory.component.html', styleUrls: ['./process-control-factory.component.less'] }) export class ProcessControlFactoryComponent implements OnInit { logoPath = ''; /** 当前公司名称 */ readonly companyName: string; readonly companyDisplayName: string; /** 车间列表 */ get workshopList(): WorkShopLineInfoDto[] { return this.operator.workshopList; } isShowWorkshopModal = false; /** 当前选中车间 */ get currentWorkShop(): WorkShopLineInfoDto { return this.operator.currentWorkShop; } set currentWorkShop(item: WorkShopLineInfoDto) { this.operator.currentWorkShop = item; } /** 选中车间对应的生产模式 */ productionMode = ''; /** 选中车间的生产参数配置 */ workShopProductionPara!: WorkShopLineProductionParameter; /** 当前消息内容 * // FIXME:没有用上?? */ currentMessageContent: RhMessageContentDto | null = null; /** 消息样式 */ messageStyle: { [propName: string]: string } = { color: 'whitesmoke', 'font-size': '24px', 'text-align': 'center' }; /** sucess消息 */ successStyle: { [propName: string]: string } = { color: '#49aa19', 'font-size': '24px', 'text-align': 'center' }; /** warning消息 */ warningStyle: { [propName: string]: string } = { color: '#d8bd14', 'font-size': '24px', 'text-align': 'center' }; /** error消息 */ errorStyle: { [propName: string]: string } = { color: '#d32029', 'font-size': '24px', 'text-align': 'center' }; isShowPopupMenu = false; /** 是否开始获取数据 */ isShowWaitProductionOrderDatas = false; constructor( public operator: RhProcessControlService, private appconfig: RhAppConfigService, public router: Router, private sharedSer: SharedService, private businessSer: RhBusinessService ) { this.companyDisplayName = (this.appconfig.appConfig as RhSafeAny).CompanyDisplayName; this.companyName = this.appconfig.appConfig.CompanyName as string; this.logoPath = `./assets/pages/logo_${this.companyName}.png`; // if (!this.rootSer.workshopList || !this.rootSer.workshopList.length) { // MsgHelper.ShowWarningMessage(`车间列表为空!`); // } else { // this.workshopList = this.rootSer.workshopList; // this.openWorkshopModal(); // } } ngOnInit() { this.sharedSer.popupMenuVisibleSubject$.subscribe((status) => { this.isShowPopupMenu = status; }); if (!this.currentWorkShop) { this.getWorkShopList(); } else { // 根据选择的车间获取生产参数 this.getProductionParaData(this.currentWorkShop.OrganizationStructureCode); } this.subscribeMessageContent(); } // ********** 多播订阅 ********** private subscribeMessageContent() { this.businessSer.messageContent$.subscribe((result) => { if (result) { this.currentMessageContent = this.businessSer.currentMessageContent = result; } }); } returnToDefaultPage() { this.router.navigate([`${this.appconfig.projectConfig.MainPath}${this.appconfig.projectConfig.MainPagePath}`]); } openWorkshopModal() { this.isShowWaitProductionOrderDatas = false; this.isShowWorkshopModal = true; } closeWorkshopModal() { this.isShowWorkshopModal = false; } onSelectWorkShop(workshop: WorkShopLineInfoDto) { // 存储当前车间到localStorage if (!workshop) { return; } this.currentWorkShop = workshop; this.businessSer.currentMessageContent = this.currentMessageContent = null; this.isShowWaitProductionOrderDatas = true; this.businessSer.messageContentTrigger(null); this.closeWorkshopModal(); // 根据选择的车间获取生产参数 this.getProductionParaData(this.currentWorkShop.OrganizationStructureCode); } getWorkShopList() { const queryDto = WorkShopLineInfoQueryDto.create(); queryDto.IsUse = true; queryDto.Mode = 8; MsgHelper.ShowGlobalLoadingMessage('正在拉取车间数据...', 0); this.operator.GetWorkShopLineInfoDatas(queryDto).subscribe( (result) => { if (result && result.Success) { this.operator.workshopList = result.Attach; this.openWorkshopModal(); } else { // MsgHelper.ShowWarningMessage(`车间列表获取失败:${result.Message}`); // console.log(`车间列表获取失败:${result.Message}`); this.operator.workshopList = []; } MsgHelper.CloseGlobalLoadingMessage(); }, () => { // console.log(`车间列表获取失败!!!`); this.operator.workshopList = []; MsgHelper.CloseGlobalLoadingMessage(); } ); } getProductionParaData(code: string) { const queryDto = WorkShopLineExtProperyQueryDto.create(); queryDto.OrganizationStructureCode = code; this.operator.GetWorkShopLineProductionParameterData(queryDto).subscribe((result) => { if (result && result.Success) { this.productionMode = result.Attach.ProductionMode; this.workShopProductionPara = result.Attach; } else { this.workShopProductionPara = WorkShopLineProductionParameter.create(); MsgHelper.ShowWarningMessage(`车间生产参数获取失败!${result.Message}`); this.productionMode = ''; } }); // console.log(this.productionMode); } }