import { MsgHelper, FormHelper, ObjectHelper, RhStorageService } from 'rh-base/core'; import { UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { ProductionPlanCreateFlowCardDto, ProductionPlanExtParameter, ProductionPlanImportDto, ProductionPlanOrderDto, ProductionPlanOrderExtProperyQueryDto, ProductionPlanOrderQueryDto, ProductionPlanSplitDto } from './../../ppm-model'; import { RhProductionPlanManagementService } from './../production-plan-management.service'; import { Component, OnInit, ViewChild } from '@angular/core'; import { DataResultT, RhSelectableDto, CodeClassModel, RhDynamicTableFieldDto, RhTableQueryOptionDto, RhTableButtonInfoDto, RhBaseDto, RhSafeAny, WithNil, OpResult } from 'rh-base/model'; import { DynamicFormComponent } from 'rh-base/shared'; import * as _ from 'lodash'; import { Router } from '@angular/router'; @Component({ selector: 'rh-plan-maintain', templateUrl: './plan-maintain.component.html', styleUrls: ['./plan-maintain.component.less'] }) export class RhPlanMaintainComponent implements OnInit { @ViewChild('queryForm', { static: false }) queryFormCmt!: DynamicFormComponent; selectedIndex = 0; dataLoading = false; dataresult!: DataResultT; defaultFieldDataset: RhSafeAny = []; titleButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('release', '下达', 'primary', false, 'check-circle', false, null, () => this.issuedPlanDatas(), false), new RhTableButtonInfoDto( 'level', '调整优先级', 'default', false, 'ordered-list', false, null, () => this.openAdjustPlanLevelModal(), false ) ]; editButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('edit', '编辑', 'default', 'edit', false, null, (data) => this.openEditTab(data as RhBaseDto), true), new RhTableButtonInfoDto( 'breakdown', '分解', 'default', false, 'scissor', false, null, (data) => this.openSplitModal(data as RhBaseDto), true ), new RhTableButtonInfoDto( 'cancel', '取消分解', 'default', false, 'undo', false, null, (data) => this.cancelSplit(data as RhBaseDto), true, false, 'red' ), new RhTableButtonInfoDto( 'create', '生成流转卡', 'default', false, 'snippets', false, null, (data) => this.openCreateFModal(data as RhBaseDto), true ), new RhTableButtonInfoDto( 'detail', '计划展开', 'default', false, 'unordered-list', false, null, (data) => this.openSpreadDataTab(data as RhBaseDto), true ), new RhTableButtonInfoDto( 'SNConfig', 'SN配置', 'default', false, 'setting', false, null, (data) => this.openSNModal(data as RhBaseDto), true ) // new RhTableButtonInfoDto( // 'dispatch', // '计划派工', // 'default', // 'edit', // false, // null, // (data) => this.getDispatchDtos(data as RhBaseDto), // true // ) ]; extraButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto('close', '关闭', 'primary', true, 'close-circle', true, null, () => this.closePlanDatas(), false), new RhTableButtonInfoDto('start', '反关闭', 'default', false, 'play-circle', false, null, () => this.enablePlanDatas(), false), new RhTableButtonInfoDto('freeze', '冻结', 'primary', true, 'lock', true, null, () => this.freezePlanDatas(), false), new RhTableButtonInfoDto('unfreeze', '解冻', 'default', false, 'unlock', false, null, () => this.unFreezePlanDatas(), false) ]; SpreadDatasExtraButtonDataset: RhTableButtonInfoDto[] = [ new RhTableButtonInfoDto( 'save', '保存', 'default', false, 'save', false, null, (data) => this.onStoreSpreadDatas(data as ProductionPlanOrderDto), false, true ) ]; tabType = 'scan'; factoryCode!: WithNil; selecedDatas: RhSelectableDto[] = []; selecedPlanDatas: ProductionPlanOrderDto[] = []; // 计划关闭 isShowCloseModal = false; closeReasonForm!: UntypedFormGroup; submitCloseReasonLoading = false; // 调整优先级 isShowAdjustLevelModal = false; adjustForm!: UntypedFormGroup; adjustDto!: ProductionPlanOrderDto; submitAdjustLoading = false; // 计划分解 isShowSplitModal = false; /** 选中的计划单 */ selectPlanData!: RhSafeAny; selectPlanExtPara!: RhSafeAny; splitForm!: UntypedFormGroup; splitDto!: ProductionPlanSplitDto; submitSplitLoading = false; isEvenlySplit = false; // 是否均分 // 生成流转卡 createFlowCardDto!: ProductionPlanCreateFlowCardDto; createFlowCardForm!: UntypedFormGroup; isShowCreateFModal = false; submitCreateFLoading = false; // 计划展开 spreadDatas = { Attach: [] } as DataResultT; spreadTableStatus = 'scan'; storageSpreadDatas = { Attach: [] } as DataResultT; collapseQueryDto = {}; defaultQueryDto = {}; // 计划派工 // dispatchDataresult: DataResultT; // dispatchLoading = false; // selectDispatchOrder: ProductionPlanDispatchDto; // dispatchEditButtonDataset: RhTableButtonInfoDto[] = [ // new RhTableButtonInfoDto('dispatchOrder', '派工', 'default', 'edit', false, null, (data) => this.openDispatchModal(data), true) // ]; // isShowDispatchModal = false; // dispatchedOrders: DataResultT; // dispatchedOrderLoading = false; // loginUser: RhLoginedUserDto; isShowSNModal = false; constructor( private operator: RhProductionPlanManagementService, private fb: UntypedFormBuilder, private storage: RhStorageService, public router: Router ) { // } ngOnInit() { this.adjustDto = this.initAdjustDto(); this.createAdjustForm(this.adjustDto); this.splitDto = this.initSplitDto(); this.createSplitForm(this.splitDto); this.createCloseReasonForm(); this.createFlowCardDto = this.initCreateFDto(); this.createCreateFForm(this.createFlowCardDto); // this.selectDispatchOrder = this.initDispatchOrder(); // this.loginUser = this.storage.getUserSession().User; } initDefaultQueryDto(dto: RhSafeAny) { this.collapseQueryDto = dto; this.defaultQueryDto = { ...this.defaultQueryDto, ...this.collapseQueryDto }; } getValueChange() { this.defaultQueryDto = { ...this.defaultQueryDto, ...this.collapseQueryDto }; setTimeout(() => { this.getDatas(); }); } setDatas(dataset: DataResultT | OpResult) { this.dataresult = dataset as DataResultT; } dataLoadingChange(status: boolean) { this.dataLoading = status; } setInitFieldDatset(item: CodeClassModel) { const tempDatas: RhSafeAny = []; 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); } } selectedDatasChange(dtos: RhSelectableDto[] | null) { if (dtos) { this.selecedPlanDatas = []; this.selecedDatas = dtos; this.selecedDatas.forEach((ele) => { this.selecedPlanDatas.push(ele as ProductionPlanOrderDto); }); } } //#region 计划关闭 closePlanDatas() { const dto = this.selecedDatas.find((ele) => ele['OrderStatus'] !== 'Created' || ele['ControlStatus'] !== 'Enable'); // console.log(dto); if (dto) { if (this.selecedDatas.some((ele) => ele['ControlStatus'] === 'Close')) { MsgHelper.ShowWarningMessage(`所选计划单中包含已关闭的计划单,无法执行计划关闭!`); } else { MsgHelper.ShowWarningMessage(`所选计划单中有不满足【单据状态】为 "制单" 且【控制状态】为 "启用" 的计划单,请检查!`); } return; } // 填写计划关闭原因 this.isShowCloseModal = true; } closeCloseModal() { this.isShowCloseModal = false; } createCloseReasonForm() { this.closeReasonForm = this.fb.group({ /** 计划关闭原因 */ ControlReason: [null, [Validators.required]] }); } resetCloseReasonForm($event: Event) { if ($event) { $event.preventDefault(); } this.closeReasonForm.get('ControlReason')?.setValue(null); } submitCloseResonForm($event: Event) { if ($event) { $event.preventDefault(); } this.submitCloseReasonLoading = true; this.selecedPlanDatas.forEach((ele) => { ele.ControlReason = this.closeReasonForm.get('ControlReason')?.value; }); this.operator.CloseProductionPlanOrder(this.selecedPlanDatas).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`计划关闭成功`); this.getDatas(); this.closeCloseModal(); } else { MsgHelper.ShowWarningMessage(`计划关闭失败:${result.Message}`); } this.submitCloseReasonLoading = false; }, () => { this.submitCloseReasonLoading = false; } ); } //#endregion // // 计划启用(反关闭) enablePlanDatas() { if (this.selecedDatas.some((ele) => ele['ControlStatus'] !== 'Close')) { if (this.selecedDatas.some((ele) => ele['ControlStatus'] === 'Enable')) { MsgHelper.ShowWarningMessage(`所选计划单中包含已启用的计划单,无法执行计划反关闭!`); } else { MsgHelper.ShowWarningMessage(`所选计划单中有【控制状态】不为 "关闭" 的计划单,请检查!`); } return; } this.operator.EnableProductionPlanOrder(this.selecedPlanDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`计划启用成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`计划启用失败:${result.Message}`); } }); } // 计划下达 issuedPlanDatas() { const dto = this.selecedDatas.find((ele) => ele['OrderStatus'] !== 'Created' || ele['ControlStatus'] !== 'Enable'); if (dto) { if (this.selecedDatas.some((ele) => ele['OrderStatus'] === 'Issued')) { MsgHelper.ShowWarningMessage(`所选计划单中包含已下达的计划单,无法执行计划下达!`); } else { MsgHelper.ShowWarningMessage(`所选计划单中有不满足【单据状态】为 "制单" 且【控制状态】为 "启用" 的计划单,请检查!`); } return; } this.dataLoading = true; this.operator.IssuedProductionPlanOrder(this.selecedPlanDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`计划下达成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`计划下达失败:${result.Message}`); this.dataLoading = false; } }); } // 计划冻结 freezePlanDatas() { if (this.selecedDatas.some((ele) => ele['ControlStatus'] !== 'Enable')) { if (this.selecedDatas.some((ele) => ele['ControlStatus'] !== 'Freeze')) { MsgHelper.ShowWarningMessage(`所选计划单中包含已冻结的计划单,无法执行计划冻结!`); } else { MsgHelper.ShowWarningMessage(`所选计划单中有【控制状态】不为 "启用" 的计划单,请检查!`); } return; } this.operator.FreezeProductionPlanOrder(this.selecedPlanDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`计划冻结成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`计划冻结失败:${result.Message}`); } }); } // 计划解冻 unFreezePlanDatas() { if (this.selecedDatas.some((ele) => ele['ControlStatus'] !== 'Freeze')) { MsgHelper.ShowWarningMessage(`只有【控制状态】为 "冻结" 的计划单才能进行解冻,请检查!`); return; } this.operator.UnFreezeProductionPlanOrder(this.selecedPlanDatas).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`计划解冻成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`计划解冻失败:${result.Message}`); } }); } //#region 调整优先级 openAdjustPlanLevelModal() { this.isShowAdjustLevelModal = true; } closeAdjustPlanLevelModal() { this.isShowAdjustLevelModal = false; this.resetAdjustForm(null); } initAdjustDto(): ProductionPlanOrderDto { const dto = ProductionPlanOrderDto.create(); dto.IsEmergency = false; return dto; } createAdjustForm(dto: ProductionPlanOrderDto) { this.adjustForm = this.fb.group({ // 优先级 PriorityLevel: [dto.PriorityLevel], // 是否紧急 IsEmergency: [dto.IsEmergency] }); } resetAdjustForm($event: WithNil) { if ($event) { $event.preventDefault(); } this.adjustDto = this.initAdjustDto(); this.adjustForm.reset(this.adjustDto); } submitAdjustForm($event: Event) { if ($event) { $event.preventDefault(); } this.submitAdjustLoading = true; FormHelper.submitForm(this.adjustDto, this.adjustForm, (dto) => { this.selecedPlanDatas.forEach((ele) => { ele.PriorityLevel = dto?.PriorityLevel; ele.IsEmergency = dto?.IsEmergency; }); this.operator.AdjustProductionPlanPriorityLevel(this.selecedPlanDatas).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`优先级调整成功`); this.closeAdjustPlanLevelModal(); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`优先级调整失败:${result.Message}`); } this.submitAdjustLoading = false; }, () => { this.submitAdjustLoading = false; } ); }); } //#endregion // //#region 计划分解 openSplitModal(dto: RhBaseDto) { this.selectPlanData = dto as ProductionPlanOrderDto; // 先判断状态 if (this.selectPlanData.ControlStatus !== 'Enable') { if (this.selectPlanData.ControlStatus === 'Delete') { MsgHelper.ShowWarningMessage(`计划已删除,无法进行分解`); } else if (this.selectPlanData.ControlStatus === 'Freeze') { MsgHelper.ShowWarningMessage(`计划已冻结,无法进行分解`); } else if (this.selectPlanData.ControlStatus === 'Close') { MsgHelper.ShowWarningMessage(`计划已关闭,无法进行分解`); } return; } const queryDto = ProductionPlanOrderExtProperyQueryDto.create(); queryDto.ProductionPlanCode = this.selectPlanData.ProductionPlanCode; this.operator.GetProductionPlanExtParameterData(queryDto).subscribe((result) => { if (result && result.Success) { this.selectPlanExtPara = result.Attach; } else { MsgHelper.ShowWarningMessage(`获取计划扩展属性失败:${result.Message}`); } }); this.splitDto.SplitQty = []; this.splitForm.get('PlanStartTime')?.patchValue(this.selectPlanData.PlanStartTime); this.splitForm.get('PlanEndTime')?.patchValue(this.selectPlanData.PlanEndTime); this.splitForm.get('IsEvenlySplit')?.patchValue(false); this.splitForm.get('EvenlySplitNumber')?.patchValue(null); // 清空分解数列表 if (this.NumberList.length > 0) { for (let i = this.NumberList.length - 1; i >= 0; i--) { this.NumberList.removeAt(i); } } this.addSplitQty(); this.isShowSplitModal = true; } closeSplitModal() { this.isShowSplitModal = false; this.isEvenlySplit = false; } initSplitDto(): ProductionPlanSplitDto { const dto = ProductionPlanSplitDto.create(); return dto; } createSplitForm(dto: ProductionPlanSplitDto) { this.splitForm = this.fb.group({ // /** 计划拆分数量 */ // SplitQty: [dto.SplitQty, [Validators.required]], /** 计划预计开始时间 */ PlanStartTime: [dto.PlanStartTime, [Validators.required]], /** 计划预计结束时间 */ PlanEndTime: [dto.PlanEndTime, [Validators.required]], /** 计划拆分数量数组 */ NumberList: this.fb.array([]), /** 是否均分 */ IsEvenlySplit: [false], /** 均分数 */ EvenlySplitNumber: [null] }); } get NumberList(): UntypedFormArray { return this.splitForm.get('NumberList') as UntypedFormArray; } addSplitQty(num?: number) { if (num) { this.NumberList.push( this.fb.group({ number: [num] }) ); } else { this.NumberList.push( this.fb.group({ number: [null] }) ); } } removeSplitQty(id: number) { this.NumberList.removeAt(id); this.setSplitQty(); } setSplitQty() { this.splitDto.SplitQty = []; this.splitForm.get('NumberList')?.value.forEach((ele: RhSafeAny) => { this.splitDto.SplitQty?.push(ele.number); }); } resetSplitForm($event: Event) { if ($event) { $event.preventDefault(); } this.splitDto = this.initSplitDto(); this.splitDto.PlanStartTime = this.selectPlanData.PlanStartTime; this.splitDto.PlanEndTime = this.selectPlanData.PlanEndTime; this.splitForm.reset(this.splitDto); this.isEvenlySplit = false; this.splitForm.get('IsEvenlySplit')?.patchValue(false); this.splitForm.get('EvenlySplitNumber')?.patchValue(null); // 清空分解数列表 if (this.NumberList.length > 0) { for (let i = this.NumberList.length - 1; i >= 0; i--) { this.NumberList.removeAt(i); } } this.addSplitQty(); this.splitDto.SplitQty = []; } submitSplitForm(event: Event) { if (event) { event.preventDefault(); } // 先判断数量是否符合要求 if ( this.splitDto.SplitQty?.some((ele) => ele <= this.selectPlanExtPara?.ProductStandardPackingQty) || this.splitDto.SplitQty?.length === 0 ) { MsgHelper.ShowWarningMessage(`请确保每一个分解的数量都大于产品标准装箱量!`); return; } // 分解数之和要小于等于计划数 let sum = 0; this.splitDto.SplitQty?.forEach((item) => { sum = sum + item; }); if (sum >= this.selectPlanData?.PlanQty) { MsgHelper.ShowWarningMessage(`请确保分解数之和小于计划数!`); return; } else { this.submitSplitLoading = true; FormHelper.submitForm(this.splitDto, this.splitForm, (dto) => { dto.ProductionPlanCode = this.selectPlanData.ProductionPlanCode; dto.PlanQty = this.selectPlanData.PlanQty; this.operator.SplitProductionPlanOrder(dto).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`计划分解成功`); this.getDatas(); this.closeSplitModal(); } else { MsgHelper.ShowWarningMessage(`计划分解失败:${result.Message}`); } this.submitSplitLoading = false; }, () => { this.submitSplitLoading = false; } ); }); } } // 是否均分 evenlySplitStatusChange(isEvenly: boolean) { this.isEvenlySplit = isEvenly; if (!isEvenly) { if (this.NumberList.length > 0) { for (let i = this.NumberList.length - 1; i >= 0; i--) { this.NumberList.removeAt(i); } } this.addSplitQty(); } else { this.splitForm.get('EvenlySplitNumber')?.patchValue(null); } } // 均分数计算赋值 evenlySplit(evenlyNumber: number) { if (this.NumberList.length > 0) { for (let i = this.NumberList.length - 1; i >= 0; i--) { this.NumberList.removeAt(i); } } if (!evenlyNumber) { return; } else { if (evenlyNumber > 1) { const every = Math.floor(this.selectPlanData.PlanQty / evenlyNumber); // 再循环赋值 for (let i = 0; i < evenlyNumber - 1; i++) { this.addSplitQty(every); } } } this.setSplitQty(); } //#endregion // // 取消计划分解 cancelSplit(dto: RhSafeAny) { const splitData = dto.ProductionPlanCode.split('-'); if (splitData.length > 1) { const item = ProductionPlanSplitDto.create(); item.ProductionPlanCode = dto.ProductionPlanCode; item.PlanQty = dto.PlanQty; this.operator.CancelSplitProductionPlanOrder(item).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`取消分解成功`); this.getDatas(); } else { MsgHelper.ShowWarningMessage(`取消分解失败:${result.Message}`); } }); } else { MsgHelper.ShowWarningMessage(`非分解生成的计划无法取消分解!`); return; } } // //#region 生成流转卡 openCreateFModal(dto: RhBaseDto) { this.selectPlanData = dto as ProductionPlanOrderDto; // 先判断状态 if (this.selectPlanData.ControlStatus !== 'Enable') { if (this.selectPlanData.ControlStatus === 'Delete') { MsgHelper.ShowWarningMessage(`计划已删除,无法生成流转卡`); } else if (this.selectPlanData.ControlStatus === 'Freeze') { MsgHelper.ShowWarningMessage(`计划已冻结,无法生成流转卡`); } else if (this.selectPlanData.ControlStatus === 'Close') { MsgHelper.ShowWarningMessage(`计划已关闭,无法生成流转卡`); } return; } // 清空分卡数列表 if (this.FNumberList.length > 0) { for (let i = this.FNumberList.length - 1; i >= 0; i--) { this.FNumberList.removeAt(i); } } this.addFlowCardQty(); this.isShowCreateFModal = true; } closeCreateFModal() { this.isShowCreateFModal = false; } initCreateFDto(): ProductionPlanCreateFlowCardDto { const dto = ProductionPlanCreateFlowCardDto.create(); return dto; } // eslint-disable-next-line @typescript-eslint/no-unused-vars createCreateFForm(dto: ProductionPlanCreateFlowCardDto) { this.createFlowCardForm = this.fb.group({ /** 生成流转卡数量 */ FNumberList: this.fb.array([]) }); } get FNumberList(): UntypedFormArray { return this.createFlowCardForm.get('FNumberList') as UntypedFormArray; } addFlowCardQty(event?: Event) { if (event) { event.preventDefault(); } this.FNumberList.push( this.fb.group({ number: [null] }) ); } removeFlowCardQty(id: number) { this.FNumberList.removeAt(id); this.setFlowCardQty(); } setFlowCardQty() { this.createFlowCardDto.SplitQty = []; this.createFlowCardForm.get('FNumberList')?.value.forEach((ele: RhSafeAny) => { this.createFlowCardDto.SplitQty?.push(ele.number); }); } resetCreateFForm($event: Event) { if ($event) { $event.preventDefault(); } this.createFlowCardDto = this.initSplitDto(); this.createFlowCardForm.reset(this.createFlowCardDto); // 清空分解数列表 // if (this.FNumberList.length > 0) { // for (let i = this.FNumberList.length - 1; i >= 0; i--) { // this.FNumberList.removeAt(i); // } // } // this.addFlowCardQty(); this.createFlowCardForm.get('FNumberList')?.patchValue(null); } submitCreateFForm(event: Event) { if (event) { event.preventDefault(); } this.submitCreateFLoading = true; // 数量判断 let number = 0; this.createFlowCardForm.get('FNumberList')?.value.forEach((ele: RhSafeAny) => { number = number + ele.number; }); if (number + this.selectPlanData.ProductionFlowCardQty > this.selectPlanData.PlanQty) { MsgHelper.ShowWarningMessage(`流转卡数量大于计划数量,请重新输入!`); this.submitCreateFLoading = false; return; } else { FormHelper.submitForm(this.createFlowCardDto, this.createFlowCardForm, (dto) => { dto.ProductionPlanCode = this.selectPlanData.ProductionPlanCode; this.operator.CreateProductionFlowCardByPlan(dto).subscribe( (result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`生成流转卡成功`); this.getDatas(); this.closeCreateFModal(); } else { MsgHelper.ShowWarningMessage(`${result.Message}`); } this.submitCreateFLoading = false; }, () => { this.submitCreateFLoading = false; } ); }); } } // #endregion // #region 计划展开 openSpreadDataTab(dto: RhBaseDto) { this.selectPlanData = dto as ProductionPlanOrderDto; // 获取数据 this.getSpreadDatasByPlan(this.selectPlanData); } closeSpreadDataTab() { this.tabType = 'scan'; this.selectedIndex = 0; this.spreadDatas = { Attach: [] } as DataResultT; this.storageSpreadDatas = { Attach: [] } as DataResultT; this.spreadTableStatus = 'scan'; } getSpreadDatasByPlan(dto: ProductionPlanOrderDto) { // 获取数据 const queryDto = ProductionPlanOrderQueryDto.create(); queryDto.ProductionPlanCode = dto.ProductionPlanCode; queryDto.Mode = 8; this.operator.GetProductionPlanOrderSpreadDatas(queryDto).subscribe((result) => { if (result && result.Success) { this.spreadDatas = result; this.storageSpreadDatas = _.cloneDeep(this.spreadDatas); // 备用数据,取消时使用 // 打开tab页 this.tabType = 'spread'; this.selectedIndex = 1; } else { this.spreadDatas = { Attach: [] } as DataResultT; this.storageSpreadDatas = { Attach: [] } as DataResultT; MsgHelper.ShowWarningMessage(`${result.Message}`); } }); } onStoreSpreadDatas(data?: ProductionPlanOrderDto) { const dtos: RhSafeAny = []; const Datas: RhSafeAny = []; Datas.push(data); Datas[0].map((ele: RhSafeAny) => { const dto = ProductionPlanImportDto.create(); ObjectHelper.MapT(ele, dto); dtos.push(dto); }); this.operator.CreateProductionPlanOrders(dtos).subscribe((result) => { if (result && result.Success) { MsgHelper.ShowSuccessMessage(`数据保存成功!`); this.getSpreadDatasByPlan(this.selectPlanData); this.spreadTableStatus = 'scan'; } else { MsgHelper.ShowWarningMessage(`${result.Message}`); } }); } onCancelSpreadDatas() { this.spreadDatas = _.cloneDeep(this.storageSpreadDatas); this.spreadTableStatus = 'scan'; } //#endregion // //#region ******** 计划派工 ******** // // 获取可派工对象 // getDispatchDtos(dto: RhBaseDto) { // this.selectPlanData = dto as ProductionPlanOrderDto; // this.dispatchLoading = true; // this.dispatchDataresult = null; // this.operator.GetPlanDispatchObjectDatas(this.selectPlanData).subscribe( // (result) => { // if (result && result.Success) { // this.openDispatchTab(); // this.dispatchDataresult = result; // } else { // MsgHelper.ShowWarningModal(`${result.Message}`); // } // this.dispatchLoading = false; // }, // () => { // this.dispatchLoading = false; // } // ); // } // openDispatchTab() { // // 获取已经被分派出来的派工单 // this.getProductionDispatchOrderDatasBy(); // this.tabType = 'dispatch'; // this.selectedIndex = 1; // } // closeDispatchTab() { // this.tabType = 'scan'; // this.selectedIndex = 0; // } // getProductionDispatchOrderDatasBy() { // this.dispatchedOrderLoading = true; // const dto = ProductionDispatchOrderQueryDto.create(); // dto.ProductionPlanCode = this.selectPlanData.ProductionPlanCode; // this.operator.GetProductionDispatchOrderDatasBy(dto).subscribe( // (result) => { // if (result) { // this.dispatchedOrders = result; // if (!result.Success) { // MsgHelper.ShowWarningMessage(`未获取到派工单数据:${result.Message}`); // } // } else { // this.dispatchedOrders = null; // } // this.dispatchedOrderLoading = false; // }, // () => { // this.dispatchedOrderLoading = false; // } // ); // } // // 派工 // initDispatchOrder(): ProductionPlanDispatchDto { // const dto = ProductionPlanDispatchDto.create(); // return dto; // } // openDispatchModal(dto: RhBaseDto) { // const order = dto as PlanDispatchObjectDto; // ObjectHelper.MapT(order, this.selectDispatchOrder); // this.selectDispatchOrder.ProductionPlanCode = this.selectPlanData.ProductionPlanCode; // this.selectDispatchOrder.Dispatcher = this.loginUser.UserName; // this.isShowDispatchModal = true; // } // closeDispatchModal() { // this.isShowDispatchModal = false; // } // dispatchPlanOrder(result: DataResultT) { // if (result && result.Success) { // MsgHelper.ShowSuccessMessage(`派工成功!`); // this.getProductionDispatchOrderDatasBy(); // this.closeDispatchModal(); // } else { // MsgHelper.ShowWarningModal(`派工失败!${result.Message}`); // } // } //#endregion // //#region SN配置区域 closeSNModal() { this.selectPlanData = null; this.isShowSNModal = false; } openSNModal(data: RhBaseDto) { this.selectPlanData = data as ProductionPlanOrderDto; this.isShowSNModal = true; } //#endregion SN配置区域结束 }