import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { IRHInterfaceLocation, RhSafeAny } from 'rh-base/model'; import { trigger, transition, style, animate, state } from '@angular/animations'; import { MsgHelper, RhApiUrlsService } from 'rh-base/core'; import { RhPortType } from 'rh-base/model'; import { RhConfigManageService } from './../../../config-manage.service'; import { CodingRuleInput } from './../../../config-manage-model'; @Component({ selector: 'rh-code-rule-edit', templateUrl: './code-rule-edit.component.html', styleUrls: ['./code-rule-edit.component.less'], animations: [ trigger('myInsertRemoveTrigger', [ state('in', style({ transform: 'translateX(0)', opacity: 1 })), transition(':enter', [style({ transform: 'translateX(-200px)', opacity: 0 }), animate('300ms')]) ]) ] }) export class CodeRuleEditComponent implements OnInit { @Input() rhData!: CodingRuleInput | RhSafeAny; @Output() rhClose = new EventEmitter(); @Output() rhSubmit = new EventEmitter(); sampleGenerateInterface: IRHInterfaceLocation = { interfaceType: 'post', port: this.apiUrl.getPortNum(RhPortType.rdp), controllerName: 'CodingRuleWebApi', interfaceName: 'GeneratingCode' }; isShowDatasourceModal = false; submitLoading = false; isSample = false; constructor(private operator: RhConfigManageService, public apiUrl: RhApiUrlsService) { // } ngOnInit(): void { // 初始化数据 } /** 保存到数据库 */ saveToDatabase(rules: string[]) { this.rhData.CodingRules = rules; this.submitLoading = true; this.operator.StoreCodingRuleData(this.rhData).subscribe( (result) => { if (result?.Success) { MsgHelper.ShowSuccessMessage(`编码规则保存成功!`); this.rhSubmit.emit(); // this.rhClose.emit(); } else { MsgHelper.ShowWarningModal(`编码规则保存失败!${result.Message}`); } this.submitLoading = false; }, () => (this.submitLoading = false) ); } openDatasourceModal() { this.isShowDatasourceModal = true; } close() { this.rhClose.emit(); } closeSampleModal() { this.isSample = false; } openSampleModal() { this.isSample = true; } }