diff --git a/src/views/plan/whiteOrder/index.vue b/src/views/plan/whiteOrder/index.vue index 2dc27e80..30331930 100644 --- a/src/views/plan/whiteOrder/index.vue +++ b/src/views/plan/whiteOrder/index.vue @@ -928,6 +928,18 @@ export default { this.splitData = response.data.proOrderWorkorderList; this.productData.push(response.data.proOrderList[0]); + //数据初始化 + function setAtrr1(row) { + row.atrr1 = 0 + if (row.children !== undefined) { + for (let i = 0; i < row.children.length; i++) { + setAtrr1(row.children[i]) + } + } + } + + setAtrr1(this.productData[0]) + }) // 5.设置默认工单日期 this.splitForm.productDate = moment(new Date()).format('YYYY-MM-DD') @@ -991,7 +1003,7 @@ export default { this.materielQueryParams.pageNum = 1; this.getMaterielList(); }, - // 新增-车数数量校验 + // 拆分-车数数量校验 changeCarNum(num) { console.log("车数数量改变") // 请先输入订单数量 diff --git a/src/views/plan/workorder/index.vue b/src/views/plan/workorder/index.vue index 9272bb0f..26e7516f 100644 --- a/src/views/plan/workorder/index.vue +++ b/src/views/plan/workorder/index.vue @@ -356,6 +356,13 @@ clearable> + + + + + + @@ -378,11 +385,10 @@ - - - - + + + + @@ -454,6 +460,7 @@ import { } from '@/api/plan/workorder' import moment from 'moment'; import { getProEquipment, getProRoutes, getProShifts} from '@/api/plan/order' +import {prototype} from "clipboard"; export default { name: "Workorder", @@ -514,6 +521,7 @@ export default { productDate: null, shiftId: null, routeCode: null, + carNum: null, }, // 遮罩层 loading: true, @@ -600,6 +608,38 @@ export default { this.getList(); }, methods: { + // 变更-车数数量校验 + changeCarNum(num) { + console.log("车数数量改变") + console.log(num) + + // 请先输入订单数量 + if (this.splitForm.splitNum == null) { + this.$message({ + message: '请先输入拆分数量!', + type: 'warning' + }) + this.splitForm.carNum = null; + return + } + // 车数不能超过拆分数量 + if (Number(this.splitForm.splitNum) - Number(num) < 0) { + this.$message({ + message: '车数不能超过拆分数量!', + type: 'warning' + }) + this.splitForm.carNum = this.splitForm.splitNum; + } + // 不能为负数 + if (num <= 0) { + this.$message({ + message: '车数数量不能小于0!', + type: 'warning' + }) + this.splitForm.carNum = 1; + } + this.splitForm.carNum = num; + }, // 派发-工单派发按钮操作 handleUpdateDown(row) { var statusesArray = this.statuses; @@ -695,18 +735,37 @@ export default { this.splitForm.shiftId = this.splitData[0].shiftDesc // 设置工艺 this.splitForm.routeCode = this.splitData[0].routeCode + // 设置车数 + this.splitForm.carNum = this.splitData[0].carNum - // 递归将拆分数量还原 - function setAtrr1(order, work) { - order.quantitySplit = Number(order.quantitySplit) - Number(work.quantitySplit); - order.atrr1 = work.quantitySplit; + // 订单为白坯 + if (this.productData[0].prodType == 'white'){ + // 递归将拆分数量还原 + function setAtrr1(order, work) { + order.quantitySplit = Number(order.quantitySplit) - Number(work.quantitySplit); + order.atrr1 = work.quantitySplit; - if (order.children !== undefined && work.children !== undefined) { - setAtrr1(order.children[0], work.children[0]); + if (order.children !== undefined && work.children !== undefined) { + setAtrr1(order.children[0], work); + } } + + setAtrr1(this.productData[0], this.splitData[0]); } + // 订单为成品 + if (this.productData[0],prototype != 'white'){ + // 递归将拆分数量还原 + function setAtrr1(order, work) { + order.quantitySplit = Number(order.quantitySplit) - Number(work.quantitySplit); + order.atrr1 = work.quantitySplit; + + if (order.children !== undefined && work.children !== undefined) { + setAtrr1(order.children[0], work.children[0]); + } + } - setAtrr1(this.productData[0], this.splitData[0]); + setAtrr1(this.productData[0], this.splitData[0]); + } }) @@ -739,11 +798,15 @@ export default { }, // 变更-拆分数量变更 splitNumChange(e) { -//不能为负数 + console.log(this.productData) + //不能为负数 if (e <= 0) { e = 1 this.splitForm.splitNum = 1 - } else { + } + // 订单为成品 + if (this.productData[0].prodType != 'white') { + console.log("成品逻辑") // 获取最大值,拆分数量不得超过最大值 let max = Number(this.productData[0].quantity) - Number(this.productData[0].quantitySplit) // 超过最大值,给用户提醒 @@ -782,6 +845,45 @@ export default { this.workForm.splitNum = this.splitForm.splitNum } + // 订单为白坯 + if (this.productData[0].prodType == 'white') { + console.log("白坯逻辑") + // 获取最大值,拆分数量不得超过最大值 + let max = Number(this.productData[0].quantity) - Number(this.productData[0].quantitySplit) + // 超过最大值,给用户提醒 + if (e > max) { + this.$message({ + message: '最大值不能超过' + max + '!', + type: 'warning' + }) + this.splitForm.splitNum = max + } + //前端数据同步 + // 在获取到新的数据后执行以下代码 + this.proLoading = true // 设置加载状态为true,表示正在加载 + + // 递归操作动态显示拆分数量 + function setAtrr1(data, splitNum) { + if (data.children !== undefined) { + for (let i = 0; i < data.children.length; i++) { + data.children[i].atrr1 = splitNum + setAtrr1(data.children[i], splitNum) + } + } + } + + this.productData[0].atrr1 = this.splitForm.splitNum + setAtrr1(this.productData[0], this.splitForm.splitNum) + + this.refreshProTable = false // 先将refreshProTable设置为false,隐藏表格 + this.$nextTick(() => { + // 使用$nextTick来等待DOM更新完成 + this.refreshProTable = true // 立即将refreshProTable设置为true,显示表格 + this.proLoading = false // 设置加载状态为false,表示加载完成 + }) + + this.workForm.splitNum = this.splitForm.splitNum + } this.product = this.productData[0] }, // 变更-工单日期变更