import { NzTreeNode } from 'ng-zorro-antd/tree'; import { Component, OnInit, ViewChild } from '@angular/core'; import { RhBaseDto, DataResultT, RhSelectableDto, RhTableButtonInfoDto, CodeClassModel, RhDynamicTableFieldDto, RhTableQueryOptionDto, RhSafeAny } from 'rh-base/model'; import { MsgHelper, RhStorageService } from 'rh-base/core'; import { DynamicFormComponent, } from 'rh-base/shared'; @Component({ selector: 'rh-inventory-query', templateUrl: './inventory-query.component.html', styleUrls: ['./inventory-query.component.css'] }) export class RhInventoryQueryComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; areaIndex = 0; shelfIndex = 0; locationIndex = 0; BusinessType = 'MaterialInventory'; editDto: RhBaseDto = {}; dataLoading = false; isShowImport = false; dataresult!: DataResultT; defaultFieldDataset: RhDynamicTableFieldDto[] = []; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('inOutOrderDetails', '出入库流水', 'default', false, 'unordered-list', false, null, (data) => this.openInOutOrderDetailsTab(data as RhBaseDto, 0) ), new RhTableButtonInfoDto('inventoryDetails', '库存明细', 'default', false, 'appstore', false, null, (data) => this.openStorageLocationDatasTab({ data }) ) ]; titleButtonDataset: RhTableButtonInfoDto[] = []; extraButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('dataloader', '数据导入', 'default', false, 'import', false, null, () => this.openImportTab(), true) ]; defaultQueryDto = {}; inventoryDetailsQueryDto = {}; inventoryStorageLocationQueryDto = {}; inOutOrderDetailsQueryDto = {}; // 可见性 inOutOrderDetailsQueryFormVisibleSetting = {}; //树内选中的物料 selectedMaterial: RhSafeAny; // 当前库存层级 currentInventoryLevel = 0; isShowStorageLocationDatasTab = false; isShowDetailsTab = false; isShowAreaTab = false; isShowShelfTab = false; isShowInOutOrderDetailsTab = false; constructor(private storage: RhStorageService) { // } ngOnInit(): void { // } setDatas(dataset: DataResultT) { this.dataresult = dataset; if (!this.dataresult.httpRequestPara) this.dataresult.httpRequestPara = {}; this.dataresult.httpRequestPara['FactoryCode'] = this.storage.getFactoryCode(); if (!dataset?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${dataset?.Message}`); } } dataLoadingChange(status: boolean) { this.dataLoading = status; } 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]; } refreshDatas(option: RhTableQueryOptionDto) { this.getDatas(option); } //调用子组件中的接口 private getDatas(option?: RhTableQueryOptionDto) { if (this.queryFormCmt) { const queryDto: RhSafeAny = {}; if (this.selectedMaterial?.MaterialCode) { queryDto.MaterialCode = this.selectedMaterial.MaterialCode ? `$${this.selectedMaterial.MaterialCode}` : null; } else { queryDto.MaterialCode = null; } this.defaultQueryDto = queryDto; setTimeout(() => { this.queryFormCmt.submitDefaultForm(null, option); }); } } closeEditTab() { this.editDto = {}; this.selectedIndex = 0; this.isShowImport = false; } openImportTab() { this.isShowImport = true; this.isShowStorageLocationDatasTab = false; this.selectedIndex = 1; } openDetailsTab(dto: RhBaseDto) { this.editDto = dto['data']; this.inventoryDetailsQueryDto = { WarehouseCode: this.editDto?.['WarehouseCode'] ? `$${this.editDto?.['WarehouseCode']}` : null, MaterialCode: this.editDto?.['MaterialCode'] ? `$${this.editDto?.['MaterialCode']}` : null, WarehouseAreaCode: this.editDto?.['WarehouseAreaCode'] ? `$${this.editDto?.['WarehouseAreaCode']}` : null, WarehouseShelfCode: this.editDto?.['WarehouseShelfCode'] ? `$${this.editDto?.['WarehouseShelfCode']}` : null, StorageLocationCode: this.editDto?.['StorageLocationCode'] ? `$${this.editDto?.['StorageLocationCode']}` : null }; this.isShowDetailsTab = true; this.closeInOutOrderDetailsTab(); this.selectedIndex++; } closeDetailsTab() { this.isShowDetailsTab = false; } openAreaTab(dto: RhBaseDto) { this.editDto = dto['data']; this.inventoryStorageLocationQueryDto = { WarehouseCode: this.editDto?.['WarehouseCode'] ? `${this.editDto?.['WarehouseCode']}` : null, MaterialCode: this.editDto?.['MaterialCode'] ? `$${this.editDto?.['MaterialCode']}` : null, WarehouseAreaCode: this.editDto?.['WarehouseAreaCode'] ? `$${this.editDto?.['WarehouseAreaCode']}` : null }; this.isShowAreaTab = true; this.closeInOutOrderDetailsTab(); this.selectedIndex++; } closeAreaTab() { this.isShowAreaTab = false; this.isShowShelfTab = false; this.isShowDetailsTab = false; } openShelfTab(dto: RhBaseDto) { this.editDto = dto['data']; this.inventoryStorageLocationQueryDto = { WarehouseCode: this.editDto?.['WarehouseCode'] ? `${this.editDto?.['WarehouseCode']}` : null, MaterialCode: this.editDto?.['MaterialCode'] ? `$${this.editDto?.['MaterialCode']}` : null, WarehouseAreaCode: this.editDto?.['WarehouseAreaCode'] ? `$${this.editDto?.['WarehouseAreaCode']}` : null, WarehouseShelfCode: this.editDto?.['WarehouseShelfCode'] ? `$${this.editDto?.['WarehouseShelfCode']}` : null }; this.isShowShelfTab = true; this.closeInOutOrderDetailsTab(); this.selectedIndex = 3; } closeShelfTab() { this.isShowShelfTab = false; this.isShowDetailsTab = false; } // openImportTab() { // this.isShowImport = true;; // this.selectedIndex = 1; // } openStorageLocationDatasTab(dto: RhBaseDto) { this.editDto = dto['data']; this.inventoryStorageLocationQueryDto = { WarehouseCode: this.editDto?.['WarehouseCode'] ? `${this.editDto?.['WarehouseCode']}` : null, MaterialCode: this.editDto?.['MaterialCode'] ? `$${this.editDto?.['MaterialCode']}` : null }; this.isShowStorageLocationDatasTab = true; this.closeInOutOrderDetailsTab(); this.selectedIndex = 1; } closeStorageLocationDatasTab() { this.isShowStorageLocationDatasTab = false; this.isShowAreaTab = false; this.isShowShelfTab = false; this.isShowDetailsTab = false; this.inventoryStorageLocationQueryDto = {}; } SelectedMaterialCode(node: NzTreeNode) { if (node && node.origin['customData']) { const data = node.origin['customData']; if (node.isSelected) { this.selectedMaterial = data; this.getDatas(); } } else { this.selectedMaterial = null; } } openInOutOrderDetailsTab(data: RhBaseDto, level: number) { this.currentInventoryLevel = level; this.editDto = data; this.inOutOrderDetailsQueryDto = { WarehouseCode: this.editDto?.['WarehouseCode'] ? `$${this.editDto?.['WarehouseCode']}` : null, MaterialCode: this.editDto?.['MaterialCode'] ? `$${this.editDto?.['MaterialCode']}` : null, WarehouseAreaCode: this.editDto?.['WarehouseAreaCode'] ? `$${this.editDto?.['WarehouseAreaCode']}` : null, WarehouseShelfCode: this.editDto?.['WarehouseShelfCode'] ? `$${this.editDto?.['WarehouseShelfCode']}` : null, StorageLocationCode: this.editDto?.['StorageLocationCode'] ? `${this.editDto?.['StorageLocationCode']}` : null, LotNum: this.editDto?.['LotNum'] ? `$${this.editDto?.['LotNum']}` : null, SN: this.editDto?.['SN'] ? `$${this.editDto?.['SN']}` : null }; switch (level) { case 0: this.inOutOrderDetailsQueryFormVisibleSetting = { MaterialCode: false, WarehouseCode: false }; this.isShowStorageLocationDatasTab = false; this.isShowAreaTab = false; this.isShowShelfTab = false; this.isShowDetailsTab = false; break; case 1: this.inOutOrderDetailsQueryFormVisibleSetting = { MaterialCode: false, WarehouseCode: false, WarehouseAreaCode: false }; this.isShowAreaTab = false; this.isShowShelfTab = false; this.isShowDetailsTab = false; break; case 2: this.inOutOrderDetailsQueryFormVisibleSetting = { MaterialCode: false, WarehouseCode: false, WarehouseAreaCode: false, WarehouseShelfCode: false }; this.isShowShelfTab = false; this.isShowDetailsTab = false; break; case 3: this.inOutOrderDetailsQueryFormVisibleSetting = { MaterialCode: false, WarehouseCode: false, WarehouseAreaCode: false, WarehouseShelfCode: false, StorageLocationCode: false }; this.isShowDetailsTab = false; break; case 4: this.inOutOrderDetailsQueryFormVisibleSetting = { MaterialCode: false, WarehouseCode: false, WarehouseAreaCode: false, WarehouseShelfCode: false, StorageLocationCode: false, LotNum: false }; break; default: break; } this.selectedIndex = this.selectedIndex + 1; this.isShowInOutOrderDetailsTab = true; } closeInOutOrderDetailsTab() { this.currentInventoryLevel = 0; this.isShowInOutOrderDetailsTab = false; } selectedIndexChange(index: number) { if (this.isShowInOutOrderDetailsTab && index < this.currentInventoryLevel + 1) { if (this.currentInventoryLevel == 3 && index < this.currentInventoryLevel + this.shelfIndex - 1) { this.isShowInOutOrderDetailsTab = false; } if (this.currentInventoryLevel == 4 && index < this.currentInventoryLevel + this.locationIndex - 2) { this.isShowInOutOrderDetailsTab = false; } if (this.currentInventoryLevel <= 2) { this.isShowInOutOrderDetailsTab = false; } } } getWarehouseControl(para: { IsEnableWarehouseArea: any; IsEnableWarehouseShelf: any; IsEnableStorageLocation: any; }) { this.areaIndex = 0; this.shelfIndex = 0; this.locationIndex = 0; if (para.IsEnableWarehouseArea) { this.areaIndex++; this.shelfIndex++; this.locationIndex++; } if (para.IsEnableWarehouseShelf) { this.shelfIndex++; this.locationIndex++; } if (para.IsEnableStorageLocation) { this.locationIndex++; } } }