import { UntypedFormGroup } from '@angular/forms'; import { MaterialSnPtyDto } from './../../../../mdp-model'; import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges } from '@angular/core'; import { DataResultT, RhSafeAny, RhBaseDto } from 'rh-base/model'; import { MsgHelper } from 'rh-base/core'; @Component({ selector: 'rh-material-sn-pty-edit', templateUrl: './material-sn-pty-edit.component.html', styleUrls: ['./material-sn-pty-edit.component.less'] }) export class MaterialSnPtyEditComponent implements OnInit { @Input() rhData!: MaterialSnPtyDto; @Output() rhClose = new EventEmitter(); @Output() rhSubmit = new EventEmitter(); snMappedName = ''; snMappedPlaceholder = ''; snMappedObj = { Without: null, FixedContent: '产品条码固定内容', RangeContent: '产品条码区间规则', MarkContent: '产品条码标志位' }; snMappedPlaceholderObj = { RangeContent: '$代表需要检测的数字区间' }; constructor() {} ngOnInit(): void {} ngOnChanges(changes: SimpleChanges): void { const { rhData } = changes; if (rhData && rhData.currentValue) { if (this.rhData.ProductSnCheckMode === null) { this.rhData.ProductSnCheckMode = 'Without'; } this.changeProductSnCheckMode(this.rhData?.ProductSnCheckMode as string); } } close() { this.rhClose.emit(); } onSubmitInterface(result: DataResultT) { if (result && result.Success) { MsgHelper.ShowSuccessMessage('物料条码验证信息存储成功!'); this.rhSubmit.emit(); } else { MsgHelper.ShowWarningModal(`物料条码验证信息存储失败!${result.Message}`); } } changeProductSnCheckMode(mode: string, formGroup?: UntypedFormGroup) { this.snMappedName = this.snMappedObj[mode as keyof typeof this.snMappedObj] as string; this.snMappedPlaceholder = this.snMappedPlaceholderObj[mode as keyof typeof this.snMappedPlaceholderObj] || this.snMappedName; if (!this.snMappedName && formGroup) { formGroup.get('ProductSnCheckParameter')?.setValue(null); } } }