import { RhQmpService } from './../../qmp.service'; import { EmployeeMessageNotifyGroupConfigDto, EmployeeMessageNotifyGroupConfigQueryDto, View_MessageNotifyGroupDto, View_MessageNotifyGroupQueryDto } from './../../qmp-model'; import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core'; import { MsgHelper } from 'rh-base/core'; import { DataResultT, RhDynamicComponentFieldType } from 'rh-base/model'; /** 质量管理或者设备管理人员选择 */ @Component({ selector: 'rh-maintenance-staff-manage-selector', templateUrl: './maintenance-staff-manage.component.html', styleUrls: ['./maintenance-staff-manage.component.less'] }) export class RhMaintenanceStaffManageComponent implements OnInit, OnChanges { /** 键值:设备管理或者质量管理 */ @Input() rhModuleKey: 'QualityManagement' | 'EquipmentManagement' = 'EquipmentManagement'; @Input() rhMinSize = '300px'; @Input() rhSize = '500px'; @Input() rhChange!: number; /** 选中的人员 */ @Output() rhSelectedEmp = new EventEmitter(); defaultQueryDto!: View_MessageNotifyGroupQueryDto; selectedIndex = 0; dataLoading = false; dataresult = { Attach: [] } as unknown as DataResultT; editGroupDto!: EmployeeMessageNotifyGroupConfigDto; defaultFieldDataset: RhDynamicComponentFieldType[] = []; messageNotifyGroups: EmployeeMessageNotifyGroupConfigDto[] = []; messageNotifyGroupsLoading = false; // moduleName = '设备管理'; constructor(private qmpService: RhQmpService) { // } ngOnChanges(changes: SimpleChanges) { if (changes) { this.dataresult.Attach.forEach((ele) => { ele.select = false; }); this.dataresult = { ...this.dataresult }; this.rhSelectedEmp.emit(null); } } ngOnInit(): void { this.getEmployeeMessageNotifyGroupConfigDatas(); } refreshDatas() { this.getDatas(); } //调用子组件中的接口 private getDatas() { if (this.defaultQueryDto) { this.defaultQueryDto.Mode = 8; } this.qmpService.GetEmployeeMessageNotifyGroupViewDatas(this.defaultQueryDto).subscribe((result) => { if (result && result.Success) { this.dataresult = result; } else { this.dataresult.Attach = []; } this.dataresult = { ...this.dataresult }; }); } getEmployeeMessageNotifyGroupConfigDatas() { const queryDto = EmployeeMessageNotifyGroupConfigQueryDto.create(); queryDto.ModuleKey = this.rhModuleKey; queryDto.IsEnable = true; queryDto.Mode = 8; this.messageNotifyGroupsLoading = true; this.qmpService.GetEmployeeMessageNotifyGroupConfigDatas(queryDto).subscribe( (result) => { if (result.Success) { this.messageNotifyGroups = result.Attach; // if (this.selectedMessageNotifyGroup) { // const temp = this.messageNotifyGroups.find( // (f) => f.ModuleKey === this.selectedMessageNotifyGroup.ModuleKey && f.GroupKey === this.selectedMessageNotifyGroup.GroupKey // ); // if (temp) { // temp.select = true; // } // } } else { this.messageNotifyGroups = []; MsgHelper.ShowWarningMessage(`查询无数据!${result.Message}`); } this.messageNotifyGroupsLoading = false; }, () => { this.messageNotifyGroupsLoading = false; } ); } getCheckedData(data: EmployeeMessageNotifyGroupConfigDto) { // this.selectedMessageNotifyGroup = data; this.defaultQueryDto = { ModuleKey: this.rhModuleKey, GroupKey: data.GroupKey, GroupName: data.GroupName } as View_MessageNotifyGroupQueryDto; setTimeout(() => { this.getDatas(); }); } //选择中的人员 getSelectedEmp(data: View_MessageNotifyGroupDto) { this.rhSelectedEmp.emit(data); } }