import { InventoryVerificationOrderMasterQueryDto, InventoryVerificationOrderMasterDto } from './../../inventory-manage-model'; import { RhInventoryManageService } from './../../inventory-manage.service'; import { Component, OnInit, ViewChild } from '@angular/core'; import { DynamicFormComponent } from 'rh-base/shared'; import { DataResultT, RhSelectableDto, RhTableButtonInfoDto, RhLoginedUserDto, CodeClassModel, RhDynamicTableFieldDto, RhTableQueryOptionDto, RhBaseDto, WithNil } from 'rh-base/model'; import { RhStorageService, MsgHelper } from 'rh-base/core'; import { RhInventoryCountService } from '../inventory-count.service'; type tabType = 'replayManage' | 'inventoryGainLossManage' | 'differenceAudit' | 'snapshoot'; @Component({ selector: 'rh-inventory-verification-difference', templateUrl: './inventory-verification-difference.component.html', styleUrls: ['./inventory-verification-difference.component.less'] }) export class RhInventoryVerificationDifferenceComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; dataLoading = false; dataresult!: DataResultT; selectedData!: RhSelectableDto; defaultFieldDataset: RhDynamicTableFieldDto[] = []; titleButtonDataset: RhTableButtonInfoDto[] = []; editButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('replayManage', '复盘管理', 'default', false, 'copy', false, null, (data) => this.openReplayManageTab(data as RhBaseDto), true), new RhTableButtonInfoDto( 'inventoryGainLossManage', '盘盈盘亏管理', 'default', false, 'form', false, null, (data) => this.openInventoryGainLossManageTab(data as RhBaseDto), true ), new RhTableButtonInfoDto( 'inventoryGainLossView', '盘盈盘亏查看', 'default', false, 'eye', false, null, (data) => this.openInventoryGainLossManageTab(data as RhBaseDto), true ), new RhTableButtonInfoDto( 'differenceAudit', '差异审核', 'default', false, 'audit', false, null, (data) => this.openDifferenceAuditTab(data as RhBaseDto), true ), new RhTableButtonInfoDto( 'closedVerification', '完成盘点', 'primary', false, 'check', false, null, (data) => this.closedInventoryVerificationOrder(data as RhBaseDto), true ), new RhTableButtonInfoDto('snapshoot', '盘点快照', 'default', false, 'eye', false, null, (data) => this.openSnapshootTab(data as RhBaseDto), true) ]; // 辅助字段 currentUser: WithNil; curFactoryDefaultQueryDto = {}; currentTab!: tabType; get isReadOnly() { return ( this.selectedData['OrderStatus'] !== 'CompletedInitialInventoryVerification' && this.selectedData['OrderStatus'] !== 'CompletedRepeatInventoryVerification' ); } constructor( public storage: RhStorageService, private operator: RhInventoryCountService, private inventoryManageSer: RhInventoryManageService ) { } ngOnInit(): void { this.initPageConfig(); } initPageConfig() { /// 复盘管理 this.editButtonDataset[0].visible = `data=>data.OrderStatus==='CompletedInitialInventoryVerification'`; // 盘盈盘亏管理 this.editButtonDataset[1].visible = `data=>data.OrderStatus==='CompletedInitialInventoryVerification'||data.OrderStatus==='CompletedRepeatInventoryVerification'`; // 盘盈盘亏查看 this.editButtonDataset[2].visible = `data=>data.OrderStatus!=='CompletedInitialInventoryVerification'&&data.OrderStatus!=='CompletedRepeatInventoryVerification'`; // 差异审核 this.editButtonDataset[3].visible = `data=>data.OrderStatus==='CompletedInitialInventoryVerification'||data.OrderStatus==='CompletedRepeatInventoryVerification'||data.OrderStatus==='AuditDifferences'`; // 完成盘点 this.editButtonDataset[4].visible = `data=>data.OrderStatus==='AuditDifferences'`; // 盘点快照 this.editButtonDataset[5].visible = `data=>data.OrderStatus==='Closed'`; // 获取当前用户信息 this.currentUser = this.storage.getUserSession()?.User; this.curFactoryDefaultQueryDto = { FactoryCode: this.currentUser?.FactoryCode }; } setDatas(dataset: DataResultT) { this.dataresult = dataset; if (!this.dataresult?.Success) { MsgHelper.ShowWarningMessage(`搜索无数据!${this.dataresult?.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) { this.queryFormCmt.submitDefaultForm(null, option); } } openSnapshootTab(data: RhBaseDto) { this.selectedData = data; this.currentTab = 'snapshoot'; this.selectedIndex = 1; } closeDetailTab() { this.selectedIndex = 0; } // 复盘管理 openReplayManageTab(data: RhBaseDto) { this.selectedData = data; this.currentTab = 'replayManage'; this.selectedIndex = 1; } // 盘盈盘亏管理 openInventoryGainLossManageTab(data: RhBaseDto) { this.selectedData = data; this.currentTab = 'inventoryGainLossManage'; this.selectedIndex = 1; } // 差异审核 openDifferenceAuditTab(data: RhBaseDto) { this.selectedData = data; this.currentTab = 'differenceAudit'; this.selectedIndex = 1; } selectedIndexChange(index: number) { if (index === 0) { this.getDatas(); } } getDetails() { const queryDto = InventoryVerificationOrderMasterQueryDto.create(); queryDto.OrderCode = this.selectedData['OrderCode']; this.operator.GetInventoryVerificationOrderMasterDatas(queryDto).subscribe((result) => { if (result.Success && result.Attach.length === 1) { this.selectedData = result.Attach[0]; } }); } detailsUpdate() { this.getDetails(); } closedInventoryVerificationOrder(data: RhBaseDto) { this.operator.ClosedInventoryVerificationOrder(data as InventoryVerificationOrderMasterDto).subscribe((result) => { if (result.Success) { MsgHelper.ShowSuccessMessage('完成盘点成功!'); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`完成盘点失败!${result.Message}`); } }); } }