| | |
| | | const $gridLeft = xGridLeft.value |
| | | const leftData = $gridLeft.getTableData().fullData |
| | | |
| | | //落架顺序 |
| | | // 获取最大落架顺序 |
| | | let index = 1 |
| | | if (leftData.length !== 0) { |
| | | index = Math.max(...leftData.map(d => d.landingSequence || 0)) + 1 |
| | | } |
| | | |
| | | // 流程卡号 |
| | | let processId = null |
| | | if (maxProcseeId) { |
| | | const base = leftData.length !== 0 ? leftData[0].processId : maxProcseeId |
| | | const lastThree = base.slice(-3) |
| | | const result = parseInt(lastThree) + 1 |
| | | processId = productionId + result.toString().padStart(3, '0') |
| | | } else { |
| | | processId = productionId + index.toString().padStart(3, '0') |
| | | // 生成 processId(最大尾号 + 1) |
| | | let maxProcIdNum = 0 |
| | | if (leftData.length > 0) { |
| | | maxProcIdNum = Math.max(...leftData.map(item => { |
| | | const pid = item.processId |
| | | return parseInt(pid?.slice(-3)) || 0 |
| | | })) |
| | | } |
| | | |
| | | const baseIdNum = Math.max( |
| | | maxProcIdNum, |
| | | parseInt(maxProcseeId?.slice(-3) || '0') |
| | | ) + 1 |
| | | |
| | | const processId = productionId + baseIdNum.toString().padStart(3, '0') |
| | | |
| | | // 校验数量 |
| | | const regex = /^(\d+|)$/ |
| | | if (!regex.test(checkedNum.value)) { |
| | | ElMessage.warning(t('processCard.schedulingNo')) |
| | |
| | | |
| | | try { |
| | | if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | //有输入数量 |
| | | // 有输入数量的 |
| | | checkedList.forEach((item) => { |
| | | if (item.baiscQuantity < checkedNum.value * 1) { |
| | | throw new Error(t('processCard.schedulingQuantity')) |
| | | } |
| | | item.quantity = checkedNum.value * 1 |
| | | item.processId = processId |
| | | item.landingSequence = index // ✅ 同一批次,落架顺序一致 |
| | | item.baiscQuantity -= checkedNum.value * 1 |
| | | item.computeGrossArea = ( |
| | | item.computeGrossArea - item.width * item.height * checkedNum.value / 1000000 |
| | | |
| | | const newItem = JSON.parse(JSON.stringify(item)) |
| | | |
| | | newItem.quantity = checkedNum.value * 1 |
| | | newItem.processId = processId |
| | | newItem.landingSequence = index |
| | | newItem.baiscQuantity -= checkedNum.value * 1 |
| | | newItem.computeGrossArea = ( |
| | | newItem.computeGrossArea - newItem.width * newItem.height * checkedNum.value / 1000000 |
| | | ).toFixed(2) |
| | | |
| | | const key = item._X_ROW_KEY |
| | | delete item._X_ROW_KEY |
| | | |
| | | if (item.baiscQuantity === 0) { |
| | | if (item.baiscQuantity === newItem.quantity) { |
| | | $grid.remove(item) |
| | | } else { |
| | | item.baiscQuantity -= newItem.quantity // 保持右表剩余数量正确 |
| | | item.computeGrossArea = ( |
| | | item.computeGrossArea - item.width * item.height * newItem.quantity / 1000000 |
| | | ).toFixed(2) |
| | | } |
| | | |
| | | const currentLeft = $gridLeft.getTableData().fullData |
| | | $gridLeft.clearSort() |
| | | $gridLeft.loadData([...currentLeft, item]) |
| | | item._X_ROW_KEY = key |
| | | $gridLeft.loadData([...currentLeft, newItem]) |
| | | }) |
| | | } else if (checkedNum.value === '') { |
| | | //没有输入数量 |
| | | checkedList.forEach((item) => { |
| | | item.processId = processId |
| | | item.landingSequence = index |
| | | item.quantity = item.baiscQuantity |
| | | delete item._X_ROW_KEY |
| | | // 未输入数量 |
| | | const currentLeft = $gridLeft.getTableData().fullData |
| | | const newList = checkedList.map(item => { |
| | | const newItem = JSON.parse(JSON.stringify(item)) |
| | | newItem.quantity = newItem.baiscQuantity |
| | | newItem.processId = processId |
| | | newItem.landingSequence = index |
| | | return newItem |
| | | }) |
| | | |
| | | $grid.remove(checkedList) |
| | | const currentLeft = $gridLeft.getTableData().fullData |
| | | $gridLeft.clearSort() |
| | | $gridLeft.loadData([...currentLeft, ...checkedList]) |
| | | $gridLeft.loadData([...currentLeft, ...newList]) |
| | | } |
| | | |
| | | // 清空选择和输入 |
| | | $gridLeft.clearCheckboxRow() |
| | | $grid.clearCheckboxRow() |
| | | checkedNum.value = '' |
| | | |
| | | // 插入后视觉排序 |
| | | // $nextTick(() => { |
| | | // $gridLeft.sort('landingSequence', 'asc') |
| | | // }) |
| | | } catch (e) { |
| | | ElMessage.warning(e.message ) |
| | | ElMessage.warning(e.message || '流程卡创建失败') |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //按编号创建流程卡 |
| | | const createProcessCardNo = () => { |
| | | const $grid = xGrid.value |