import { Component, OnInit, ViewChild } from '@angular/core'; import { DataResultT, RhSelectableDto, CodeClassModel, RhDynamicTableFieldDto, RhTableQueryOptionDto, RhTableButtonInfoDto, RhBaseDto, OpMode, RhSafeAny, RhDynamicComponentFieldType } from 'rh-base/model'; import { RhNavigatorService, ObjectHelper, MsgHelper, RhAppConfigService } from 'rh-base/core'; import { DynamicFormComponent } from 'rh-base/shared'; // 工厂信息组件 @Component({ selector: 'rh-factory-info-setting', templateUrl: './factory-info-setting.component.html', styleUrls: ['./factory-info-setting.component.less'] }) export class RhFactoryInfoSettingComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; editDto: RhBaseDto = {}; dataLoading = false; dataresult!: DataResultT; isShowEditModal = false; defaultFieldDataset: RhDynamicComponentFieldType[] = []; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('edit', '编辑', 'default', false, 'edit', false, null, (data) => this.openEditTab(data as RhBaseDto)) ]; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('new', '新建', 'primary', false, 'file', false, null, () => this.openEditTab(), true) ]; extraButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('link', '配置组织架构', 'primary', false, 'build', false, null, () => this.linkToOrganizationStructure(), true) ]; constructor(private navigator: RhNavigatorService, public appConfigSer: RhAppConfigService) { // } ngOnInit(): void { // } // to 配置组织架构 linkToOrganizationStructure() { const rootPrefix = this.appConfigSer.projectConfig.RootMenu.split('_')?.[0]; if (!rootPrefix) { MsgHelper.ShowWarningMessage(`程序配置没有设置RootMenu属性,请检查后重试`); } this.navigator.navigatorTrigger(`${rootPrefix}_OrganizationStructureSetting`); } openEditTab(data?: RhBaseDto) { // if (button) { // button.enableLoading = true; // button.loading = true; // setTimeout(() => { // button.loading = false; // }, 3000); // } if (data) { this.editDto = data; this.editDto.OpSign = OpMode.OpEdit; } else { this.editDto = {}; this.editDto.OpSign = OpMode.OpAdd; } this.selectedIndex = 1; } closeEditTab() { // this.selectedIndex = 0; } setDatas(dataset: DataResultT) { this.dataresult = dataset; if (!this.dataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataresult?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } onStoreData(result: DataResultT) { if (result && result.Success) { const msg = this.editDto.OpSign === OpMode.OpAdd ? '新增' : '编辑'; MsgHelper.ShowSuccessMessage(`${msg}数据成功!`); if (this.editDto.OpSign === OpMode.OpEdit) { this.selectedIndex = 0; } this.editDto = ObjectHelper.createRhBaseDto(); this.getDatas(); } else { MsgHelper.ShowWarningModal(`存储数据失败!${result.Message}`); } } setInitFieldDatset(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.defaultFieldDataset = [...tempDatas]; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } //调用子组件中的接口 private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { this.queryFormCmt.submitDefaultForm(null, option); } } }