import { RhControlValueAccessorComponent } from 'rh-base/shared'; import { MsgHelper, provideValueAccessor } from 'rh-base/core'; import { RhQmpService } from './../../../qmp.service'; import { DataResultT, RhDynamicComponentFieldType } from 'rh-base/model'; import { Component, OnInit, ChangeDetectorRef, Input } from '@angular/core'; import { View_MessageNotifyGroupDto, View_MessageNotifyGroupQueryDto, EmployeeMessageNotifyGroupConfigDto, EmployeeMessageNotifyGroupConfigQueryDto, EmployeeInfoDto } from './../../../qmp-model'; import { ControlValueAccessor } from '@angular/forms'; @Component({ selector: 'rh-maintenance-staff-selector', templateUrl: './maintenance-staff-selector.component.html', styleUrls: ['./maintenance-staff-selector.component.less'], providers: [provideValueAccessor(MaintenanceStaffSelectorComponent)] }) export class MaintenanceStaffSelectorComponent extends RhControlValueAccessorComponent implements OnInit, ControlValueAccessor { @Input() rhPlaceholder!: string; isShowModal = false; dataLoading = false; // /** 选中的人员 */ // rhSelectedEmp: View_MessageNotifyGroupDto; defaultQueryDto!: View_MessageNotifyGroupQueryDto; selectedIndex = 0; dataresult = { Attach: [] } as unknown as DataResultT; editGroupDto!: EmployeeMessageNotifyGroupConfigDto; defaultFieldDataset: RhDynamicComponentFieldType[] = []; messageNotifyGroups: EmployeeMessageNotifyGroupConfigDto[] = []; messageNotifyGroupsLoading = false; moduleKey = 'QualityManagement'; moduleName = '质量管理'; selectEmployeeData: EmployeeInfoDto | null = null; constructor(private qmpService: RhQmpService, cdk: ChangeDetectorRef) { super(cdk); } ngOnInit(): void { this.getEmployeeMessageNotifyGroupConfigDatas(); } openModal() { this.isShowModal = true; } closeModal() { this.isShowModal = false; } 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.moduleKey; 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.moduleKey, GroupKey: data.GroupKey, GroupName: data.GroupName } as View_MessageNotifyGroupQueryDto; setTimeout(() => { this.getDatas(); }); } //选择中的人员 getSelectedEmp(data: View_MessageNotifyGroupDto) { const selectedEmp = EmployeeInfoDto.create(); selectedEmp.EmployeeCode = data?.EmployeeCode; selectedEmp.EmployeeName = data?.EmployeeName; this.selectEmployeeData = selectedEmp.EmployeeCode ? selectedEmp : null; } saveInspectorDates() { this.value = this.selectEmployeeData?.EmployeeCode as string; this.closeModal(); } }