diff --git a/src/views/modules/schedule/com_schedule_order_expand.vue b/src/views/modules/schedule/com_schedule_order_expand.vue index 4469190..a90810b 100644 --- a/src/views/modules/schedule/com_schedule_order_expand.vue +++ b/src/views/modules/schedule/com_schedule_order_expand.vue @@ -1,8 +1,6 @@ + + + + + + 应用 + 保存 + 关闭 + @@ -163,7 +245,7 @@ var functionId = 'C10000038'; export default { data() { return { - height: 320, + height: 220, titleCon: '排产扩展', showDefault: false, buttons: { @@ -358,6 +440,7 @@ export default { }, resourceShiftList: [], orderScheduleList: [], + scheduleDetailList: [], dataListLoading: false, columnTimeArray: [ { @@ -1174,6 +1257,7 @@ export default { //清空参数 this.resourceList = []; this.resourceShiftList = []; + this.scheduleDetailList = []; this.pageData.resourceId = ''; this.pageData.workCenterNo = ''; this.orderScheduleList = []; @@ -1245,6 +1329,145 @@ export default { this.getResourceShiftData(); }, + /*新增排产明细行*/ + addScheduleDetail(){ + // 检查是否选择了机台 + if(this.resourceList.length === 0){ + this.$message.warning('请先获取可用机台信息'); + return; + } + // 默认选择第一个机台 + let defaultResourceId = this.resourceList.length > 0 ? this.resourceList[0].resourceId : ''; + + this.scheduleDetailList.push({ + orderNo: this.pageData.orderNo, + itemNo: this.pageData.itemNo, + resourceId: defaultResourceId, + qtyRequired: 0, + rowCount: 0, + rollCount: 0 + }); + }, + + /*删除排产明细行*/ + deleteScheduleDetail(index){ + this.scheduleDetailList.splice(index, 1); + }, + + /*批量应用排产*/ + applyScheduleBatch(){ + // 验证排产明细 + if(this.scheduleDetailList.length === 0){ + this.$message.warning('请先添加排产明细'); + return; + } + + // 验证每行数据 + for(let i = 0; i < this.scheduleDetailList.length; i++){ + let item = this.scheduleDetailList[i]; + + if(!item.resourceId || item.resourceId === ''){ + this.$message.error(`第${i+1}行:请选择机台`); + return; + } + + if(!item.qtyRequired || item.qtyRequired <= 0){ + this.$message.error(`第${i+1}行:需求数量必须大于0`); + return; + } + } + + // 循环调用排产接口(不关闭对话框) + this.executeBatchSchedule(0, false); + }, + + /*保存并关闭*/ + saveAndClose(){ + // 验证排产明细 + if(this.scheduleDetailList.length === 0){ + this.$message.warning('请先添加排产明细'); + return; + } + + // 验证每行数据 + for(let i = 0; i < this.scheduleDetailList.length; i++){ + let item = this.scheduleDetailList[i]; + + if(!item.resourceId || item.resourceId === ''){ + this.$message.error(`第${i+1}行:请选择机台`); + return; + } + + if(!item.qtyRequired || item.qtyRequired <= 0){ + this.$message.error(`第${i+1}行:需求数量必须大于0`); + return; + } + } + + // 循环调用排产接口(完成后关闭对话框) + this.executeBatchSchedule(0, true); + }, + + /*执行批量排产(递归调用)*/ + executeBatchSchedule(index, closeAfterFinish){ + if(index >= this.scheduleDetailList.length){ + // 全部排产完成 + this.$message.success('批量排产完成'); + // 清空排产明细 + this.scheduleDetailList = []; + // 刷新数据 + this.refreshShopOrderData(); + this.getOrderScheduleList(); + + // 如果需要关闭对话框 + if(closeAfterFinish){ + this.closeDialog(); + // 通知父组件刷新 + this.$emit('refreshPageTables'); + } + return; + } + + let item = this.scheduleDetailList[index]; + + // 构建排产参数 + let scheduleData = { + site: this.pageData.site, + username: this.pageData.username, + orderNo: item.orderNo, + itemNo: item.itemNo, + resourceId: item.resourceId, + workCenterNo: this.pageData.workCenterNo, + scheduleDate: this.pageData.scheduleDate, + scheduleTime: this.pageData.scheduleTime, + specifiedTime: this.pageData.specifiedTime, + scheduledQty: item.qtyRequired, + calendarId: this.pageData.calendarId, + checkFlag: true, + rowCount: item.rowCount, + rollCount: item.rollCount + }; + + // 调用排产接口 + scheduleOrderWithExpand(scheduleData).then(({data}) => { + if(data.code == 500){ + this.$message.error(`第${index+1}行排产失败:${data.msg}`); + // 停止继续排产 + return; + }else if(data.code == 201){ + // 有警告信息,跳过此条继续下一条 + this.$message.warning(`第${index+1}行:${data.msg}`); + this.executeBatchSchedule(index + 1, closeAfterFinish); + }else{ + // 排产成功,继续下一条 + this.executeBatchSchedule(index + 1, closeAfterFinish); + } + }).catch(error => { + this.$message.error(`第${index+1}行排产异常`); + console.error(error); + }); + }, + /*开始排产*/ startScheduleOrderBun(){ let scheduledQty = this.pageData.scheduledQty; @@ -1508,4 +1731,13 @@ div.customer-el-card-blue { background-color: unset !important; } +/*对话框底部按钮样式*/ +.dialog-footer { + text-align: center; +} + +.dialog-footer .el-button { + margin: 0 10px; +} +