import { LabelRuleOutput } from './../../label-model'; import { RhLabelService } from './../../label.service'; import { Component, OnInit } from '@angular/core'; import { RhSelectItem, LabelRuleQueryDto } from 'rh-base/model'; import { MsgHelper, RhApiUrlsService } from 'rh-base/core'; @Component({ selector: 'rh-material-inventory-label-design', templateUrl: './material-inventory-label-design.component.html', styleUrls: ['./material-inventory-label-design.component.less'] }) export class RhMaterialInventoryLabelDesignComponent implements OnInit { businessDataset: RhSelectItem[] = []; dataLoading = false; selectedBusinessType!: string; labelRuleDataset: LabelRuleOutput[] = []; labelRuleDataloading = false; isShowEditModal = false; selectedLabelRuleDto!: LabelRuleOutput; constructor(private operator: RhLabelService, public apiurlSer: RhApiUrlsService) { // } ngOnInit(): void { this.getBusinessDatas(); } onModelChange(type: string) { if (!type) { return; } this.selectedBusinessType = type; // 获取对应产品标签业务类型数据 const queryDto = LabelRuleQueryDto.create(); queryDto.LabelType = 'MaterialInventoryLabel'; queryDto.LabelBusinessTypeCode = type; queryDto.IsEnable = true; this.labelRuleDataloading = true; this.operator.GetLabelRuleDatasNew(queryDto).subscribe( (result) => { if (result.Success) { this.labelRuleDataset = result.Attach; } else { this.labelRuleDataset = []; MsgHelper.ShowInfoMessage(`查询无数据:${result.Message}`); } this.labelRuleDataloading = false; }, () => (this.labelRuleDataloading = false) ); } onSelectLabelRule(item: LabelRuleOutput) { this.selectedLabelRuleDto = item; // if (item.RuleId === 'PurchaseMaterialLabel') { // this.operator.navigateToLabelDesignPrintUrl(item.RuleId); // } else { // this.openEditModal(); // } // RuleId为标签类型,根据标签类型跳转至标签打印平台 this.operator.navigateToLabelDesignPrintUrl(item.RuleId, item.LabelBusinessTypeCode as string, 'WMS'); // this.openEditModal(); } closeEditModal() { this.isShowEditModal = false; } openEditModal() { this.isShowEditModal = true; } private getBusinessDatas() { this.dataLoading = true; this.apiurlSer .getSettingEntry({ moduleKey: 'LabelConfiguration', groupKey: 'MaterialInventoryLabel', paraCode: 'MaterialInventoryLabelBusinessType' }) .subscribe( (result) => { if (result.Success) { this.businessDataset = result.Attach; // 默认选中第一个选项 if (this.businessDataset[0]?.Value) { this.onModelChange(this.businessDataset[0].Value as string); this.businessDataset[0].select = true; } } else { this.businessDataset = []; MsgHelper.ShowWarningMessage(`获取仓储标签业务类型数据失败!`); } this.dataLoading = false; }, () => (this.dataLoading = false) ); } }