import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { Component, OnInit, ViewChild } from '@angular/core'; import { CodeClassModel, DataResultT, OpMode, RhBaseDto, RhDynamicTableFieldDto, RhSafeAny, RhTableButtonInfoDto, RhTableQueryOptionDto, RhSelectItem, RhDynamicComponentFieldType, RhPortType } from 'rh-base/model'; import { FormHelper, MsgHelper, RhStorageService, RhApiUrlsService, ObjectHelper } from 'rh-base/core'; import { DynamicFormComponent } from 'rh-base/shared'; import { ClassShiftDto, ClassTimeBucketDto, ClassTimeBucketQueryDto, ClassTypeDto, ClassTypeQueryDto, CopyClassShiftDto, CopyClassTypeDto } from '../../mdp-model'; import { RhFactoryCalendarService } from '../factory-calendar.service'; // 班制维护 @Component({ selector: 'rh-class-shifts-setting', templateUrl: './class-shifts-setting.component.html', styleUrls: ['./class-shifts-setting.component.less'] }) export class RhClassShiftsSettingComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; isShowEditTab = false; dataresult!: DataResultT; dataLoading = false; defaultDataset: RhDynamicComponentFieldType[] = []; editDto: RhBaseDto = {}; defaultQueryDto: RhSafeAny = {}; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('edit', '编辑', 'default', false, 'edit', false, null, (data) => this.openEditTab(data as RhBaseDto)), new RhTableButtonInfoDto('link', '班次信息', 'default', false, 'unordered-list', false, null, (data) => this.openClassTypeTab(data as RhBaseDto) ), new RhTableButtonInfoDto('copy', '复制', 'default', false, 'copy', false, null, (data) => this.openCopyModal(data as RhBaseDto)) ]; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('new', '新建', 'primary', false, 'file', false, null, () => this.openEditTab(), true) ]; selectedDto!: ClassShiftDto; // 用于自定义表单表格时 selectedTypeDto!: ClassTypeDto; // 班次维护 isShowClassTypeTab = false; classTypeQueryDto!: ClassTypeQueryDto; classTypeQueryForm!: UntypedFormGroup; classTypeDatas: ClassTypeDto[] = []; classTypeQueryLoading = false; classTypeEditDto: RhBaseDto = {}; isShowClassTypeEditModal = false; classTypeSelectDatas: ClassTypeDto[] = []; today = new Date(Date.now()); currentYear = this.today.getFullYear(); currentMonth = this.today.getMonth(); currentDay = this.today.getDate(); // check operation(班次信息tab) isAllCheck = false; isIndeterminate = false; // 班次时段信息维护 isShowTimeBucketSettingTab = false; timeBucketQueryDto!: ClassTimeBucketQueryDto; timeBucketQueryForm!: UntypedFormGroup; timeBucketDatas: ClassTimeBucketDto[] = []; timeBucketQueryLoading = false; timeBucketEditDto: ClassTimeBucketDto = {} as ClassTimeBucketDto; isShowTimeBucketEditModal = false; timeBucketSelectDatas: ClassTimeBucketDto[] = []; // check operation(班次时段信息tab) isAllCheckTime = false; isIndeterminateTime = false; // 班制复制 isShowCopyModal = false; copyDto!: CopyClassShiftDto; copyForm!: UntypedFormGroup; copyLoading = false; // 班次复制 typeCopyeForm!: UntypedFormGroup; typeCopyeDto!: CopyClassTypeDto; isShowTypeCopyModal = false; typeCopyLoading = false; factoryCode!: string; classTypeSelectItems: RhSelectItem[] = []; /** 触发动态form rhValue值变更 */ __flagIndex = 0; mdpApiPort: RhPortType = RhPortType.mdp; constructor( private operator: RhFactoryCalendarService, public fb: UntypedFormBuilder, public localDb: RhStorageService, private apiUrlSer: RhApiUrlsService ) {} ngOnInit(): void { // 工厂代码 this.factoryCode = this.localDb.getUserSession()?.User?.FactoryCode as string; // 班次信息 this.classTypeQueryDto = this.initClassTypeQueryDto(); this.createClassTypeQueryForm(this.classTypeQueryDto); this.classTypeEditDto = this.initClassTypeEditDto() as RhBaseDto; // this.createClassTypeEditForm(this.classTypeEditDto); // 班次时段信息 this.timeBucketQueryDto = this.initTimeBucketQueryDto(); this.createTimeBucketQueryForm(this.timeBucketQueryDto); this.timeBucketEditDto = this.initTimeBucketEditDto(); // this.createTimeBucketEditForm(this.timeBucketEditDto); // 复制 this.copyDto = this.initCopyDto(); this.createCopyForm(this.copyDto); // 班次复制 this.typeCopyeDto = this.initTypeCopyDto(); this.createTypeCopyForm(this.typeCopyeDto); this.getClassTypeSelectItems(); } //#region ********** 基础crud ********** setDatas(dataset: DataResultT) { this.dataresult = dataset; } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDataset(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.defaultDataset = [...tempDatas]; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { this.queryFormCmt.submitDefaultForm(null, option); } } openEditTab(data?: RhBaseDto) { if (data) { this.editDto = data; this.editDto.OpSign = OpMode.OpEdit; } else { this.editDto = {}; this.editDto.OpSign = OpMode.OpAdd; } this.isShowEditTab = true; this.selectedIndex = 1; } closeEditTab() { this.isShowEditTab = false; this.selectedIndex = 0; } onStoreData(result: DataResultT) { if (result && result.Success) { const msg = this.editDto.OpSign === OpMode.OpAdd ? '新增' : '编辑'; MsgHelper.ShowSuccessMessage(`${msg}数据成功`); if (this.editDto.OpSign === OpMode.OpEdit) { this.isShowEditTab = false; this.selectedIndex = 0; } this.editDto = ObjectHelper.createRhBaseDto(); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`数据存储失败!${result.Message}`); } } // 切换回数据展示界面时关闭其它界面 backToTabOne() { if (this.isShowEditTab) { this.closeEditTab(); } else if (this.isShowClassTypeTab || this.isShowTimeBucketSettingTab) { if (this.isShowTimeBucketSettingTab) { this.closeClassTypeTab(); this.closeTimeBucketSettingTab(); } else { this.closeClassTypeTab(); } this.selectedIndex = 0; } } //#endregion ********** 基础crud ********** // //#region 班次信息维护 openClassTypeTab(data?: RhBaseDto) { this.selectedIndex = 1; this.isShowClassTypeTab = true; // this.selectedDto = data; // 用于自定义表单表格时 this.selectedDto = data as ClassShiftDto; this.classTypeQueryForm.get('ClassShiftCode')?.setValue(this.selectedDto.ClassShiftCode); this.submitClassTypeQueryForm(); } closeClassTypeTab() { this.selectedIndex = 0; this.isShowClassTypeTab = false; // 重置班次信息查询模型 this.classTypeQueryDto = this.initClassTypeQueryDto(); } // 切换回班次信息界面事关闭班次时段信息界面 backToTabTwo() { if (this.isShowTimeBucketSettingTab) { this.closeTimeBucketSettingTab(); } } initClassTypeQueryDto(): ClassTypeQueryDto { const dto = ClassTypeQueryDto.create(); dto.Mode = 8; return dto; } createClassTypeQueryForm(dto: ClassTypeQueryDto) { // 自行删除不需要的搜索条件 this.classTypeQueryForm = this.fb.group({ /** 班制代码 */ ClassShiftCode: [dto.ClassShiftCode], /** 班次代码 */ ClassTypeCode: [dto.ClassTypeCode], /** 班次名称 */ ClassTypeName: [dto.ClassTypeName] }); } initClassTypeEditDto(): ClassTypeDto { const dto = ClassTypeDto.create(); dto.OpSign = OpMode.OpAdd; return dto; } submitClassTypeQueryForm() { if (this.classTypeQueryDto) { this.classTypeQueryDto.SkipCount = 0; } FormHelper.YGSubmitForm(this.classTypeQueryDto, this.classTypeQueryForm, (dto) => { (dto as ClassTypeQueryDto).ClassShiftCode = '$' + dto?.ClassShiftCode; this.getClassTypeDatas(dto as ClassTypeQueryDto); }); } resetClassTypeQueryForm(event: Event) { if (event) { event.preventDefault(); } this.classTypeQueryDto = this.initClassTypeQueryDto(); this.classTypeQueryDto.ClassShiftCode = this.selectedDto.ClassShiftCode; this.classTypeQueryForm.reset(this.classTypeQueryDto); this.classTypeDatas = []; } // 新建,编辑 openNewClassTypeModeal() { this.classTypeEditDto = this.initClassTypeEditDto() as RhBaseDto; this.classTypeEditDto.OpSign = OpMode.OpAdd; this.classTypeEditDto['ClassShiftCode'] = this.selectedDto.ClassShiftCode; this.isShowClassTypeEditModal = true; } openEditClassTypeModeal(item: ClassTypeDto) { this.classTypeEditDto = item as RhBaseDto; this.classTypeEditDto.OpSign = OpMode.OpEdit; this.isShowClassTypeEditModal = true; } closeEditClassTypeModeal() { this.isShowClassTypeEditModal = false; this.classTypeEditDto = this.initClassTypeEditDto() as RhBaseDto; } beforeSubmitClassTypeData = (data: RhBaseDto) => { const dto = data as ClassTypeDto; if (!dto.IsDayAcross) { if (dto.StartTime > dto.EndTime) { MsgHelper.ShowErrorMessage(`开始时间和结束时间不合理,请检查!`); return false; } else { return true; } } else { if (dto.StartTime < dto.EndTime) { MsgHelper.ShowErrorMessage(`开始时间和结束时间不合理,请检查!`); return false; } else { return true; } } }; onStoreClassTypeData(result: DataResultT) { if (result && result.Success) { const msg = this.classTypeEditDto.OpSign === OpMode.OpAdd ? '新增' : '编辑'; MsgHelper.ShowSuccessMessage(`${msg}数据成功`); this.classTypeEditDto = ObjectHelper.createRhBaseDto(); if (this.classTypeEditDto.OpSign === OpMode.OpEdit) { this.isShowClassTypeEditModal = false; } else { this.classTypeEditDto['__flag'] = this.__flagIndex++; this.classTypeEditDto['ClassTypeCode'] = result.httpRequestPara?.['ClassTypeCode']; } this.getClassTypeDatas(this.classTypeQueryDto); } else { MsgHelper.ShowWarningMessage(`数据存储失败!${result.Message}`); } } removeClassTypeData() { MsgHelper.ShowDeleteConfirm('删除后数据无法恢复,是否确定?', () => { this.operator.RemoveClassTypeDatas(this.classTypeSelectDatas).subscribe((result) => { FormHelper.HandleOpResult(result, () => { this.getClassTypeDatas(this.classTypeQueryDto); MsgHelper.ShowSuccessMessage('删除成功!'); this.classTypeSelectDatas = []; this.isAllCheck = this.isIndeterminate = false; }); }); }); } allCheckedChange($event: RhSafeAny) { this.isIndeterminate = false; this.classTypeDatas.forEach((ele) => (ele.select = this.isAllCheck)); // this.getClassTypeDatas(this.classTypeQueryDto); this.getClassTypeSelectDatas(); } checkedChange(item: ClassTypeDto) { this.isAllCheck = this.classTypeDatas.every((ele) => ele.select); this.isIndeterminate = !!(this.classTypeDatas.find((ele) => ele.select) && !this.isAllCheck); this.getClassTypeSelectDatas(); } getClassTypeDatas(queryDto: ClassTypeQueryDto) { this.classTypeQueryLoading = true; this.operator.GetClassTypeDatas(queryDto).subscribe( (result) => { if (result && result.Success) { this.classTypeDatas = result.Attach; } else { this.classTypeDatas = []; MsgHelper.ShowWarningMessage(`查询失败:${result.Message}`); } this.classTypeQueryLoading = false; this.isAllCheck = false; this.isIndeterminate = false; }, () => { this.classTypeQueryLoading = false; this.isAllCheck = false; this.isIndeterminate = false; } ); } private getClassTypeSelectDatas() { this.classTypeSelectDatas = this.classTypeDatas.filter((ele) => ele.select); } //#endregion 班次信息维护 // //#region 班次时段信息维护 openTimeBucketSettingTab(dto?: ClassTypeDto, data?: RhBaseDto) { this.isShowTimeBucketSettingTab = true; this.selectedIndex = 2; this.selectedTypeDto = dto as ClassTypeDto; this.timeBucketQueryForm.get('ClassTypeCode')?.setValue(dto?.ClassTypeCode); this.timeBucketQueryForm.get('ClassShiftCode')?.setValue(dto?.ClassShiftCode); this.timeBucketQueryForm.get('Time')?.setValue(dto?.StartTime + '~' + dto?.EndTime); this.submitTimeBucketQueryForm(); } closeTimeBucketSettingTab() { this.isShowTimeBucketSettingTab = false; this.selectedIndex = 1; // 重置班次时段信息查询模型 this.timeBucketQueryDto = this.initTimeBucketQueryDto(); } initTimeBucketQueryDto(): ClassTimeBucketQueryDto { const dto = ClassTimeBucketQueryDto.create(); dto.Mode = 8; return dto; } createTimeBucketQueryForm(dto: ClassTimeBucketQueryDto) { // 自行删除不需要的搜索条件 this.timeBucketQueryForm = this.fb.group({ /** 班制代码 */ ClassShiftCode: [dto.ClassShiftCode], /** 班次代码 */ ClassTypeCode: [dto.ClassTypeCode], /** 班次时间信息 */ Time: [dto.Time] }); } submitTimeBucketQueryForm() { if (this.timeBucketQueryDto) { this.timeBucketQueryDto.SkipCount = 0; } FormHelper.YGSubmitForm(this.timeBucketQueryDto, this.timeBucketQueryForm, (dto) => { (dto as ClassTimeBucketQueryDto).ClassShiftCode = '$' + (dto as ClassTimeBucketQueryDto).ClassShiftCode; (dto as ClassTimeBucketQueryDto).ClassTypeCode = '$' + (dto as ClassTimeBucketQueryDto).ClassTypeCode; this.getTimeBucketDatas(dto as ClassTimeBucketQueryDto); }); } resetTimeBucketQueryForm(event: Event) { if (event) { event.preventDefault(); } this.timeBucketQueryDto = this.initTimeBucketQueryDto(); this.timeBucketQueryDto.ClassTypeCode = this.selectedTypeDto.ClassTypeCode; this.timeBucketQueryForm.reset(this.timeBucketQueryDto); this.timeBucketDatas = []; } initTimeBucketEditDto(): ClassTimeBucketDto { const dto = ClassTimeBucketDto.create(); dto.OpSign = OpMode.OpAdd; return dto; } // 提交表单前的验证 beforeSubmitTimeBucketData = (data: RhBaseDto) => { // 班次相关数据信息 const startTime = this.selectedTypeDto.StartTime; const endTime = this.selectedTypeDto.EndTime; const isDayAcross = this.selectedTypeDto.IsDayAcross; // 班次时段相关信息 const dto = data as ClassTimeBucketDto; if (isDayAcross) { // 1 班次跨天 if (!dto.IsDayAcross) { // 1-1 班次时段不跨天,分两种:(1)都在前一天 (2)都在后一天,并且 StartTime 必然小于 EndTime if (dto.StartTime >= dto.EndTime) { // 开始时间在结束时间后,不合常理,错 MsgHelper.ShowErrorMessage(`班次时段应在${startTime} - 次日${endTime}范围内,请检查!`); return false; } else { if (dto.StartTime >= startTime || dto.EndTime <= endTime) { return true; } else if (dto.StartTime < startTime) { MsgHelper.ShowErrorMessage(`班次时段应在${startTime} - 次日${endTime}范围内,请检查!`); return false; } else if (dto.EndTime > endTime) { MsgHelper.ShowErrorMessage(`班次时段应在${startTime} - 次日${endTime}范围内,请检查!`); return false; } else { MsgHelper.ShowErrorMessage(`班次时段范围设置错误,请检查!`); return false; } } } else { // 1-2 班次时段跨天 if (dto.StartTime >= startTime && dto.EndTime <= endTime) { return true; } else { MsgHelper.ShowErrorMessage(`班次时段应在${startTime} - 次日${endTime}范围内,请检查!`); return false; } } } else { // 2 班次不跨天 if (dto.IsDayAcross) { // 2-1 班次时段跨天必错 MsgHelper.ShowErrorMessage(`班次时段应在${startTime} - ${endTime}范围内,请检查!`); return false; } else { // 2-2 班次时段不跨天 if (startTime <= dto.StartTime && dto.StartTime < dto.EndTime && dto.EndTime <= endTime) { return true; } else { MsgHelper.ShowErrorMessage(`班次时段应在${startTime} - ${endTime}范围内,请检查!`); return false; } } } }; onStoreTimeBucketData(result: DataResultT) { if (result && result.Success) { const msg = this.timeBucketEditDto.OpSign === OpMode.OpAdd ? '新增' : '编辑'; MsgHelper.ShowSuccessMessage(`${msg}数据成功`); if (this.timeBucketEditDto.OpSign === OpMode.OpEdit) { this.isShowTimeBucketEditModal = false; } this.timeBucketEditDto = ObjectHelper.createRhBaseDto() as ClassTimeBucketDto; this.getTimeBucketDatas(this.timeBucketQueryDto); } else { MsgHelper.ShowWarningMessage(`数据存储失败!${result.Message}`); } } removeTimeBucketFormData() { MsgHelper.ShowDeleteConfirm('删除后数据无法恢复,是否确定?', () => { this.operator.RemoveClassTimeBucketDatas(this.timeBucketSelectDatas).subscribe((result) => { FormHelper.HandleOpResult(result, () => { this.getTimeBucketDatas(this.timeBucketQueryDto); MsgHelper.ShowSuccessMessage('删除成功!'); this.timeBucketSelectDatas = []; this.isAllCheckTime = this.isIndeterminateTime = false; }); }); }); } allCheckedChangeTime($event: Event) { this.isIndeterminateTime = false; this.timeBucketDatas.forEach((ele) => (ele.select = this.isAllCheckTime)); this.getTimeBucketDatas(this.timeBucketQueryDto); } checkedChangeTime(item: ClassTimeBucketDto) { this.isAllCheckTime = this.timeBucketDatas.every((ele) => ele.select); this.isIndeterminateTime = !!(this.timeBucketDatas.find((ele) => ele.select) && !this.isAllCheckTime); this.getTimeBucketDatasSelectDatas(); } // 新建,编辑 openNewTimeBucketModeal() { this.timeBucketEditDto = this.initTimeBucketEditDto(); this.timeBucketEditDto.OpSign = OpMode.OpAdd; this.timeBucketEditDto['ClassShiftCode'] = this.selectedTypeDto.ClassShiftCode; this.timeBucketEditDto['ClassTypeCode'] = this.selectedTypeDto.ClassTypeCode; this.isShowTimeBucketEditModal = true; } openEditTimeBucketModeal(item: ClassTimeBucketDto) { this.timeBucketEditDto = item; this.timeBucketEditDto.OpSign = OpMode.OpEdit; this.isShowTimeBucketEditModal = true; } closeEditTimeBucketModeal() { this.isShowTimeBucketEditModal = false; this.timeBucketEditDto = this.initTimeBucketEditDto(); } getTimeBucketDatas(queryDto: ClassTimeBucketQueryDto) { this.timeBucketQueryLoading = true; this.operator.GetClassTimeBucketDatas(queryDto).subscribe( (result) => { if (result && result.Success) { this.timeBucketDatas = result.Attach; } else { this.timeBucketDatas = []; MsgHelper.ShowWarningMessage(`查询失败:${result.Message}`); } this.timeBucketQueryLoading = false; }, () => { this.timeBucketQueryLoading = false; } ); } private getTimeBucketDatasSelectDatas() { this.timeBucketSelectDatas = this.timeBucketDatas.filter((ele) => ele.select); } //#endregion 班次时段信息维护 // //#region 班制复制功能 openCopyModal(data?: RhBaseDto) { this.selectedDto = data as ClassShiftDto; this.copyForm.get('CopiedClassShiftCode')?.setValue(this.selectedDto.ClassShiftCode); this.isShowCopyModal = true; } closeCopyModal() { this.isShowCopyModal = false; this.resetCopyForm(null); } initCopyDto(): CopyClassShiftDto { const dto = CopyClassShiftDto.create(); return dto; } createCopyForm(dto: CopyClassShiftDto) { // 自行删除不需要的搜索条件 this.copyForm = this.fb.group({ /** 被复制的班制代码(赋值) */ CopiedClassShiftCode: [dto.CopiedClassShiftCode, [Validators.required]], /** 复制深度【0:复制班制】【1:复制班制和班次】【2:复制班制、班次和班次时段】(选择) */ Depth: [dto.Depth, [Validators.required]], /** 班制代码(手输) */ ClassShiftCode: [dto.ClassShiftCode, [Validators.required]], /** 班制名称(手输) */ ClassShiftName: [dto.ClassShiftName, [Validators.required]] }); } resetCopyForm($event: Event | null) { if ($event) { $event.preventDefault(); } this.copyDto = this.initCopyDto(); if (this.isShowCopyModal) { this.copyDto.CopiedClassShiftCode = this.selectedDto.ClassShiftCode; } this.copyForm.reset(this.copyDto); } saveCopyClassShiftDto($event: Event) { if ($event) { $event.preventDefault(); } FormHelper.YGSubmitForm(this.copyDto, this.copyForm, (dto) => { this.copyLoading = true; this.operator.CopyClassShiftDatas(dto as CopyClassShiftDto).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('复制成功'); this.resetCopyForm(null); this.getDatas(); } else { MsgHelper.ShowErrorModal(`复制失败:${result.Message}`); } this.copyLoading = false; }, () => { this.copyLoading = false; } ); }); } //#endregion 班制复制功能 // //#region 班次复制 openTypeCopyModal(data?: RhBaseDto) { this.selectedTypeDto = data as ClassTypeDto; console.log(this.selectedDto.ClassShiftCode); this.typeCopyeForm.get('CopiedClassTypeCode')?.setValue(this.selectedTypeDto.ClassTypeCode); this.typeCopyeForm.get('ClassShiftCode')?.setValue(this.selectedTypeDto.ClassShiftCode); // 默认复制选中班次对应的班制代码,可手动修改 this.isShowTypeCopyModal = true; } closeTypeCopyModal() { this.isShowTypeCopyModal = false; this.resetTypeCopyForm(null); } initTypeCopyDto(): CopyClassTypeDto { const dto = CopyClassTypeDto.create(); return dto; } createTypeCopyForm(dto: CopyClassTypeDto) { // 自行删除不需要的搜索条件 this.typeCopyeForm = this.fb.group({ /** 被复制的班次代码(赋值) */ CopiedClassTypeCode: [dto.CopiedClassTypeCode, [Validators.required]], /** 复制深度【0:复制班次】【1:复制班次班次时段】(选择) */ Depth: [dto.Depth, [Validators.required]], /** 班次代码(手输) */ ClassTypeCode: [dto.ClassTypeCode, [Validators.required]], /** 班次名称(手输) */ ClassTypeName: [dto.ClassTypeName, [Validators.required]], /** 班制代码 */ ClassShiftCode: [dto.ClassShiftCode, [Validators.required]] }); } resetTypeCopyForm($event: Event | null) { if ($event) { $event.preventDefault(); } this.typeCopyeDto = this.initTypeCopyDto(); if (this.isShowTypeCopyModal) { this.typeCopyeDto.CopiedClassTypeCode = this.selectedTypeDto.ClassTypeCode; } this.typeCopyeDto.ClassShiftCode = this.selectedTypeDto.ClassShiftCode; this.typeCopyeForm.reset(this.typeCopyeDto); } saveTypeCopyClassShiftDto($event: Event) { if ($event) { $event.preventDefault(); } FormHelper.YGSubmitForm(this.typeCopyeDto, this.typeCopyeForm, (dto) => { this.typeCopyLoading = true; this.operator.CopyClassTypeDatas(dto as CopyClassTypeDto).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage('复制成功'); this.resetTypeCopyForm(null); this.getClassTypeDatas(this.classTypeQueryDto); } else { MsgHelper.ShowErrorModal(`复制失败:${result.Message}`); } this.typeCopyLoading = false; }, () => { this.typeCopyLoading = false; } ); }); } //#endregion 班次复制 // /** 获取班次列表数据源 */ getClassTypeSelectItems() { this.apiUrlSer .getSettingEntry({ moduleKey: 'MDP', groupKey: 'FactoryCalendarManagement', paraCode: 'ClassType' }) .subscribe((result) => { if (result.Success) { this.classTypeSelectItems = result.Attach; } else { this.classTypeSelectItems = []; } }); } classTypeChangeOfQueryForm(code: string) { const item = this.classTypeSelectItems.find((f) => f.Value === code); if (item) { this.classTypeQueryForm.get('ClassTypeName')?.setValue(item.Text); } else { this.classTypeQueryForm.get('ClassTypeName')?.setValue(null); } } }