import { Component, Input, OnInit, SimpleChanges, ViewChild } from '@angular/core'; import { CodeClassModel, DataResultT, RhBaseDto, RhDynamicInterfaceDto, RhDynamicTableFieldDto, RhSafeAny, RhTableButtonInfoDto, RhTableQueryOptionDto } from 'rh-base/model'; import { ContainerInfoDto, LabelRuleOutput, LabelTemplateDesignRuleDto } from '../../../../label-model'; import { RhLabelService } from '../../../../label.service'; import { MsgHelper } from 'rh-base/core'; import { DynamicFormComponent } from 'rh-base/shared'; @Component({ selector: 'rh-box-label-manage-default', templateUrl: './label-manage-default.component.html', styleUrls: ['./label-manage-default.component.less'] }) export class LabelBoxManageDefaultComponent implements OnInit { @Input() rhBusinessType = ''; @Input() rhLabelRuleDto!: LabelRuleOutput; ruleType!: string; @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; dataresult!: DataResultT; defaultFieldDataset: RhDynamicTableFieldDto[] = []; dataLoading = false; /** 选中的模板 */ selectedLabelSpecifyDto!: LabelTemplateDesignRuleDto; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'again', '补打', 'primary', false, 'sync', false, null, (data) => this.makeUpLabel(data as RhBaseDto[]), false ), new RhTableButtonInfoDto( 'del', '作废', 'primary', true, 'delete', false, null, (data) => this.cancelLabel(data as ContainerInfoDto[]), false ) ]; makeUpModalItems!: RhBaseDto[]; isMakeUpModalShow = false; visibleTableSetting = {}; visibleFormSetting = {}; printLabel = (data: RhBaseDto) => { data['RuleId'] = this.rhLabelRuleDto.RuleId; data['BusinessType'] = this.rhBusinessType; data['ContainerCategory'] = this.rhBusinessType; data['RuleId'] = this.selectedLabelSpecifyDto.RuleId; data['LabelSpecify'] = this.selectedLabelSpecifyDto.LabelSpecify; data['SnLibaryContainerInfoDtos'] = this.makeUpModalItems; return true; }; /** 设置默认补打接口 */ defaultFormInterface: RhDynamicInterfaceDto = { interfaceType: 'post', port: 52880, controllerName: 'SnLibraryWebApi', interfaceName: 'RebuildContainerInfoLabel' }; queryDto!: RhBaseDto; constructor(private operator: RhLabelService) {} ngOnInit(): void { // } ngOnChanges(changes: SimpleChanges): void { const { rhLabelRuleDto } = changes; if (rhLabelRuleDto && rhLabelRuleDto.currentValue) { this.ruleType = this.rhLabelRuleDto.RuleId.replace('Label', ''); if (this.ruleType === 'MaterialInventory') { // this.initTalbleAndFormFieldDisplay(); } else { // } } } // initTalbleAndFormFieldDisplay() { // /** 是否启用库区货架 */ // const isEnableWarehouseAreaAndWarehouseShelf = this.wmsSysConfigSer.getIsEnableWarehouseAreaAndWarehouseShelf(); // /** 是否启用库位 */ // const isEnableStorageLocation = this.wmsSysConfigSer.getIsEnableStorageLocation(); // const visibleTableSetting = {}; // const visibleFormSetting = {}; // if (!isEnableWarehouseAreaAndWarehouseShelf) { // const temp = { // WarehouseAreaCode: false, // WarehouseAreaName: false, // WarehouseShelfCode: false, // WarehouseShelfName: false // }; // Object.assign(visibleTableSetting, temp); // Object.assign(visibleFormSetting, temp); // } // if (!isEnableStorageLocation) { // const temp = { // StorageLocationCode: false, // StorageLocationName: false // }; // Object.assign(visibleTableSetting, temp); // Object.assign(visibleFormSetting, temp); // } // this.visibleTableSetting = visibleTableSetting; // this.visibleFormSetting = visibleFormSetting; // } /** * * @param data */ makeUpLabel(data: RhBaseDto[]) { this.isMakeUpModalShow = true; this.makeUpModalItems = data; } /** * * @param data */ cancelLabel(data: ContainerInfoDto[]) { MsgHelper.ShowConfirmModal('是否废除', '是否确认作废采购物料条码?', () => { this.operator.AbortedSnLibraryContainerInfoDatas(data as ContainerInfoDto[]).subscribe((result) => { if (result.Success) { MsgHelper.ShowWarningMessage('废除成功!'); this.getDatas(); } else { MsgHelper.ShowWarningMessage('废除失败!' + result.Message); } }); }); } onStoreDatas(result: DataResultT) { if (result?.__context) { result.__context.submitLoading = true; setTimeout(() => { result.__context.submitLoading = false; }, 3000); } if (result?.Success) { // TODO: 唤起打印插件 this.operator.getPrintLabelClientUrlNew(result.Attach); this.closePrintModal(); this.getDatas(); } else { MsgHelper.ShowWarningModal(`条码生成失败,提示:${result.Message}`); MsgHelper.CloseGlobalLoadingMessage(); } } rhModelChange(dto: LabelTemplateDesignRuleDto) { this.selectedLabelSpecifyDto = dto; } closePrintModal() { this.isMakeUpModalShow = false; this.makeUpModalItems = []; } setDatas(dataset: DataResultT) { this.dataresult = dataset; } setInitFieldDataset(item: CodeClassModel) { const tempDatas: RhDynamicTableFieldDto[] = []; item.CodeProperties.forEach((ele) => { const temp = RhDynamicTableFieldDto.create(); temp.name = ele.PropertyName; temp.displayName = ele.Descirption; tempDatas.push(temp); }); this.defaultFieldDataset = [...tempDatas]; } dataLoadingChange(status: boolean) { this.dataLoading = status; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { this.queryFormCmt.submitDefaultForm(null, option); } } }