| | |
| | | storage: true |
| | | }, |
| | | sortConfig: { |
| | | multiple: true |
| | | multiple: true, |
| | | chronological: true |
| | | }, |
| | | editConfig: { |
| | | trigger: 'click', |
| | |
| | | width: '70px' |
| | | }, |
| | | { |
| | | field: 'longSide', |
| | | title: t('processCard.longSide'), |
| | | sortable: true, |
| | | filters: [{data: ''}], |
| | | slots: {filter: 'num1_filter'}, |
| | | filterMethod: filterChanged, |
| | | width: '90px' |
| | | }, |
| | | { |
| | | field: 'shortSide', |
| | | title: t('processCard.shortSide'), |
| | | sortable: true, |
| | | filters: [{data: ''}], |
| | | slots: {filter: 'num1_filter'}, |
| | | filterMethod: filterChanged, |
| | | width: '90px' |
| | | }, |
| | | |
| | | { |
| | | field: 'buildingNumber', |
| | | title: t('order.buildingNumber'), |
| | | sortable: true, |
| | | filters: [{data: ''}], |
| | | slots: {filter: 'num1_filter'}, |
| | | filterMethod: filterChanged, |
| | | width: '120px' |
| | | }, |
| | | {field: 'baiscQuantity', title: t('processCard.quantityToDivided'), showOverflow: "ellipsis", width: '80px'}, |
| | | { |
| | | field: 'width', |
| | | title: t('order.width'), |
| | | sortable: true, |
| | |
| | | filterMethod: filterChanged, |
| | | width: '78px' |
| | | }, |
| | | { |
| | | field: 'building_number', |
| | | title: t('order.buildingNumber'), |
| | | sortable: true, |
| | | filters: [{data: ''}], |
| | | slots: {filter: 'num1_filter'}, |
| | | filterMethod: filterChanged, |
| | | width: '120px' |
| | | }, |
| | | {field: 'baiscQuantity', title: t('processCard.quantityToDivided'), showOverflow: "ellipsis", width: '80px'}, |
| | | {field: 'computeGrossArea', title: t('processCard.areaToDivided'), width: '80px'}, |
| | | {field: 'totalThickness', title: t('processCard.totalThickness'), width: '80px'}, |
| | | {field: 'thickness', title: t('processCard.glassThickness'), width: '80px'}, |
| | |
| | | ],//表头按钮 |
| | | |
| | | toolbarConfig: { |
| | | slots:{ |
| | | buttons: "toolbar_buttons" |
| | | }, |
| | | buttons: [{ |
| | | |
| | | }], |
| | | // import: false, |
| | | // export: true, |
| | | // print: true, |
| | |
| | | |
| | | }) |
| | | const gridEventsRight = { |
| | | toolbarButtonClick({code}) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | | switch (code) { |
| | | case 'sorting': { |
| | | const rightData = $grid.getTableData().fullData |
| | | let sortedRule = optionVal.value // "0 宽高" 或 "1 高宽" |
| | | let sortedData = [] |
| | | if (sortedRule == 0) { |
| | | sortedData = rightData.sort((a, b) => { |
| | | if (a.width === b.width) { |
| | | return a.height - b.height |
| | | } |
| | | return a.width - b.width |
| | | }) |
| | | } else if (sortedRule == 1) { |
| | | sortedData = rightData.sort((a, b) => { |
| | | if (a.height === b.height) { |
| | | return a.width - b.width |
| | | } |
| | | return a.height - b.height |
| | | }) |
| | | } |
| | | // 排序后更新表格数据 |
| | | $grid.loadData(sortedData) |
| | | return |
| | | } |
| | | |
| | | } |
| | | } |
| | | }, |
| | | formSubmit () { |
| | | let form = gridOptions.formConfig.data |
| | | form.orderId =orderId |
| | | form.productionId = productionId |
| | | request.post(`/processCard/processCardAutoRack`,form).then(res => { |
| | | xGridLeft.value.reloadData(res.data.orderDetailList) |
| | | console.log(res.data.orderDetailList) |
| | | xGrid.value.reloadData(res.data.orderDetailsNotScope) |
| | | }) |
| | | }, |
| | |
| | | filterMethod: filterChanged, |
| | | width: 99 |
| | | }, |
| | | {field: 'quantity', title: t('order.quantity'),width:70}, |
| | | { |
| | | field: 'shape', |
| | | title: t('order.shape'), |
| | |
| | | }, |
| | | {field: 'width', title: t('order.width'), showOverflow: "ellipsis",width:70}, |
| | | {field: 'height', title: t('order.height'),width:70}, |
| | | {field: 'quantity', title: t('order.quantity'),width:70}, |
| | | |
| | | {field: 'totalThickness', title: t('processCard.totalThickness'),width:70}, |
| | | ],//表头按钮 |
| | | |
| | |
| | | } |
| | | |
| | | const newItem = JSON.parse(JSON.stringify(item)) |
| | | |
| | | //更新key |
| | | newItem._X_ROW_KEY = `${processId}_${newItem.orderNumber}_${Date.now()}_${Math.random()}` |
| | | newItem.quantity = checkedNum.value * 1 |
| | | newItem.processId = processId |
| | | newItem.landingSequence = index |
| | |
| | | const currentLeft = $gridLeft.getTableData().fullData |
| | | $gridLeft.clearSort() |
| | | $gridLeft.loadData([...currentLeft, newItem]) |
| | | $grid.refreshColumn() |
| | | |
| | | }) |
| | | } else if (checkedNum.value === '') { |
| | | // 未输入数量 |
| | |
| | | checkedNum.value = '' |
| | | |
| | | } catch (e) { |
| | | ElMessage.warning(e.message || '流程卡创建失败') |
| | | ElMessage.warning(e.message || t('processCard.msg.msg1')) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | //向右边表格添加数据 |
| | | //向右2 |
| | | const addRight = () => { |
| | | try { |
| | | //左边表格定义 |
| | | // 左边表格定义 |
| | | const $gridLeft = xGridLeft.value |
| | | //右边表格定义 |
| | | // 右边表格定义 |
| | | const $grid = xGrid.value |
| | | //获取左边表格checkbox选中的数据 |
| | | // 获取左边表格checkbox选中的数据 |
| | | const checkedList = $gridLeft.getCheckboxRecords() |
| | | //判断左边表格是否有选中的数据 |
| | | |
| | | // 判断左边表格是否有选中的数据 |
| | | if (checkedList.length === 0) { |
| | | ElMessage.warning(t('processCard.schedulingArea')) |
| | | return |
| | | } |
| | | const regex = /^(\d+|)$/; |
| | | |
| | | const regex = /^(\d+|)$/ |
| | | if (!regex.test(checkedNum.value)) { |
| | | ElMessage.warning(t('processCard.schedulingNo')) |
| | | return |
| | | } |
| | | //判断正整数 |
| | | |
| | | // 判断正整数 |
| | | if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | //对选中的左边表格数据进行循环 |
| | | // 对选中的左边表格数据进行循环 |
| | | checkedList.forEach((item) => { |
| | | //判断可用数量是否大于等于输入的数量,不满足则抛出异常 |
| | | // if (item.quantity < checkedNum.value*1) throw new Error(t('processCard.schedulingQuantity')); |
| | | // 判断可用数量是否大于等于输入的数量, 不满足则提示 |
| | | if (item.quantity < checkedNum.value * 1) { |
| | | ElMessage.warning(t('processCard.schedulingQuantity')) |
| | | } |
| | | //左边表格可用数量减去输入的数量 |
| | | |
| | | // 左边表格可用数量减去输入的数量 |
| | | item.quantity = item.quantity - checkedNum.value |
| | | //右边表格数据 |
| | | let rightData = $grid.getTableData().fullData |
| | | //右边表格数据中查找当前数据下标 |
| | | let filterIndex = rightData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | //如果右边表格数据中存在当前数据则数量相加 |
| | | |
| | | // 右边表格数据 |
| | | const rightData = $grid.getTableData().fullData |
| | | // 右边表格数据中查找当前数据下标(以 orderNumber 匹配) |
| | | const filterIndex = rightData.findIndex(d => d.orderNumber === item.orderNumber) |
| | | |
| | | if (filterIndex >= 0) { |
| | | //数量 |
| | | // 数量叠加 |
| | | rightData[filterIndex].baiscQuantity = rightData[filterIndex].baiscQuantity * 1 + checkedNum.value * 1 |
| | | //面积 |
| | | rightData[filterIndex].computeGrossArea = (rightData[filterIndex].width * rightData[filterIndex].height * rightData[filterIndex].baiscQuantity / 1000000).toFixed(2) |
| | | //如果左边数量为0时删除此条数据 |
| | | //删除key |
| | | let key = item._X_ROW_KEY |
| | | // 面积重算 |
| | | rightData[filterIndex].computeGrossArea = ( |
| | | rightData[filterIndex].width * rightData[filterIndex].height * rightData[filterIndex].baiscQuantity / 1000000 |
| | | ).toFixed(2) |
| | | |
| | | // 如果左边数量为0时删除此条数据 |
| | | const key = item._X_ROW_KEY |
| | | delete item._X_ROW_KEY |
| | | if (item.baiscQuantity === 0) { |
| | | $grid.remove(item) |
| | | if (item.baiscQuantity === 0 || item.quantity === 0) { |
| | | $gridLeft.remove(item) |
| | | } |
| | | item._X_ROW_KEY = key |
| | | } else { |
| | | //右边表格没有此条数据则往右边表格插入数据 |
| | | // 右边表格没有此条数据则往右边表格插入数据 |
| | | item.baiscQuantity = checkedNum.value |
| | | item.computeGrossArea = (item.width * item.height * checkedNum.value / 1000000).toFixed(2) |
| | | if (item.quantity === 0) { |
| | |
| | | } |
| | | $grid.insert(item) |
| | | } |
| | | |
| | | if (item.quantity === 0) { |
| | | $gridLeft.remove(item) |
| | | } |
| | | }) |
| | | } else if (checkedNum.value === '') {//判断数量输入框无输入数字 |
| | | |
| | | } else if (checkedNum.value === '') { // 数量输入框无输入数字:全量移动 |
| | | checkedList.forEach((item) => { |
| | | //右侧表格 |
| | | let rightData = $grid.getTableData().fullData |
| | | let filterIndex = rightData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | //左侧表格 |
| | | let leftData = $gridLeft.getTableData().fullData |
| | | let leftfilterIndex = leftData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | //无输入并且如果右边表格数据中存在当前数据则数量相加 |
| | | // 右侧表格 |
| | | const rightData = $grid.getTableData().fullData |
| | | const filterIndex = rightData.findIndex(d => d.orderNumber === item.orderNumber) |
| | | |
| | | if (filterIndex > -1) { |
| | | rightData[filterIndex].baiscQuantity = rightData[filterIndex].baiscQuantity * 1 + item.quantity * 1 |
| | | //面积 |
| | | rightData[filterIndex].computeGrossArea = (rightData[filterIndex].width * rightData[filterIndex].height * rightData[filterIndex].baiscQuantity / 1000000).toFixed(2) |
| | | |
| | | rightData[filterIndex].computeGrossArea = ( |
| | | rightData[filterIndex].width * rightData[filterIndex].height * rightData[filterIndex].baiscQuantity / 1000000 |
| | | ).toFixed(2) |
| | | } else { |
| | | |
| | | item.baiscQuantity = item.quantity * 1 |
| | | delete item._X_ROW_KEY |
| | | $grid.insert(item) |
| | | |
| | | } |
| | | |
| | | $gridLeft.remove(item) |
| | | }) |
| | | |
| | | } |
| | | |
| | | let leftDataList = $gridLeft.getTableData().fullData; |
| | | let baseProcessId = productionId; // 固定的前缀 |
| | | // ===== 下面这部分:把“倒序”改成“顺序” ===== |
| | | |
| | | // 统计所有不重复的 processId |
| | | let uniqueProcessIds = new Set(leftDataList.map(item => item.processId)); |
| | | // 不重复的 processId 的总个数 |
| | | let totalUniqueCount = uniqueProcessIds.size; |
| | | // 用于记录已经分配的 processId |
| | | let usedProcessIds = new Set(); |
| | | // 获取左表剩余数据 |
| | | const leftDataList = $gridLeft.getTableData().fullData |
| | | const baseProcessId = productionId // 固定前缀 |
| | | |
| | | leftDataList.forEach((item) => { |
| | | let newProcessId; |
| | | // 如果该 processId 是第一次出现,使用递减的编号生成新的 processId |
| | | if (!usedProcessIds.has(item.processId)) { |
| | | newProcessId = `${baseProcessId}${(totalUniqueCount).toString().padStart(3, '0')}`; |
| | | usedProcessIds.add(item.processId); // 标记该 processId 已使用 |
| | | totalUniqueCount--; // 递减 |
| | | // 取ID末尾数字(没有数字则返回极大值,防止相减 NaN/错序) |
| | | const tailNum = (id) => { |
| | | const m = String(id ?? '').match(/(\d+)$/) |
| | | return m ? parseInt(m[1], 10) : Number.MAX_SAFE_INTEGER |
| | | } |
| | | |
| | | } else { |
| | | // 如果该 processId 已经使用过,继续使用已分配的编号 |
| | | newProcessId = `${baseProcessId}${(totalUniqueCount + 1).toString().padStart(3, '0')}`; |
| | | // 先按原 processId 分组 |
| | | const groupedByOld = leftDataList.reduce((acc, row) => { |
| | | const pid = row.processId |
| | | if (!acc[pid]) acc[pid] = [] |
| | | acc[pid].push(row) |
| | | return acc |
| | | }, {}) |
| | | |
| | | } |
| | | // 更新 item.processId |
| | | item.processId = newProcessId; |
| | | }); |
| | | // 获取剩余数据,用于对落架顺序重新赋值 |
| | | let remainingData = $gridLeft.getTableData().fullData; |
| | | // 按 processId 分组 |
| | | let groupedData = remainingData.reduce((acc, curr) => { |
| | | if (!acc[curr.processId]) { |
| | | acc[curr.processId] = []; |
| | | } |
| | | acc[curr.processId].push(curr); |
| | | return acc; |
| | | }, {}); |
| | | // 拿到去重后的旧 processId 列表,并按“末尾数字”正序(小到大)排列 |
| | | const oldIds = Object.keys(groupedByOld).sort((a, b) => { |
| | | const da = tailNum(a) |
| | | const db = tailNum(b) |
| | | if (da !== db) return da - db |
| | | // 尾数相同再按字典序兜底,确保稳定 |
| | | return String(a).localeCompare(String(b)) |
| | | }) |
| | | |
| | | // 按 processId 排序(倒序) |
| | | let sortedProcessIds = Object.keys(groupedData).sort((a, b) => b - a); |
| | | // 构建从旧 processId -> 新 processId 的映射:001, 002, ... 正序递增 |
| | | const pidMap = new Map() |
| | | oldIds.forEach((oldId, idx) => { |
| | | const newPid = `${baseProcessId}${String(idx + 1).padStart(3, '0')}` |
| | | pidMap.set(oldId, newPid) |
| | | }) |
| | | |
| | | // 更新每个分组的 landingSequence |
| | | sortedProcessIds.forEach((processId, index) => { |
| | | let group = groupedData[processId]; |
| | | |
| | | // 对每个 processId 分组内的数据,不改变顺序,直接赋相同的 landingSequence |
| | | group.forEach((item) => { |
| | | item.landingSequence = sortedProcessIds.length - index; // 按倒序设置 landingSequence |
| | | }); |
| | | }); |
| | | //清除两边复选框 |
| | | oldIds.forEach((oldId, idx) => { |
| | | const group = groupedByOld[oldId] |
| | | const newPid = pidMap.get(oldId) |
| | | const seq = idx + 1 |
| | | group.forEach((row) => { |
| | | row.processId = newPid |
| | | row.landingSequence = seq |
| | | }) |
| | | }) |
| | | |
| | | // 清除两边复选框 & 刷新列 |
| | | $gridLeft.clearCheckboxRow() |
| | | $grid.clearCheckboxRow() |
| | | |
| | | $grid.refreshColumn() |
| | | } catch (e) { |
| | | ElMessage.warning(e.message) |
| | | } |
| | | //每次点击情况输入框 |
| | | if (checkedNum.value){ |
| | | checkedNum.value ='' |
| | | |
| | | // 每次点击清空输入框 |
| | | if (checkedNum.value) { |
| | | checkedNum.value = '' |
| | | } |
| | | } |
| | | |
| | | //向右边表格添加数据 |
| | | // const addRight = () => { |
| | | // try { |
| | | // //左边表格定义 |
| | | // const $gridLeft = xGridLeft.value |
| | | // //右边表格定义 |
| | | // const $grid = xGrid.value |
| | | // //获取左边表格checkbox选中的数据 |
| | | // const checkedList = $gridLeft.getCheckboxRecords() |
| | | // //判断左边表格是否有选中的数据 |
| | | // if (checkedList.length === 0) { |
| | | // ElMessage.warning(t('processCard.schedulingArea')) |
| | | // return |
| | | // } |
| | | // const regex = /^(\d+|)$/; |
| | | // if (!regex.test(checkedNum.value)) { |
| | | // ElMessage.warning(t('processCard.schedulingNo')) |
| | | // return |
| | | // } |
| | | // //判断正整数 |
| | | // if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | // //对选中的左边表格数据进行循环 |
| | | // checkedList.forEach((item) => { |
| | | // //判断可用数量是否大于等于输入的数量,不满足则抛出异常 |
| | | // // if (item.quantity < checkedNum.value*1) throw new Error(t('processCard.schedulingQuantity')); |
| | | // if (item.quantity < checkedNum.value * 1) { |
| | | // ElMessage.warning(t('processCard.schedulingQuantity')) |
| | | // } |
| | | // //左边表格可用数量减去输入的数量 |
| | | // item.quantity = item.quantity - checkedNum.value |
| | | // //右边表格数据 |
| | | // let rightData = $grid.getTableData().fullData |
| | | // //右边表格数据中查找当前数据下标 |
| | | // let filterIndex = rightData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | // //如果右边表格数据中存在当前数据则数量相加 |
| | | // if (filterIndex >= 0) { |
| | | // //数量 |
| | | // rightData[filterIndex].baiscQuantity = rightData[filterIndex].baiscQuantity * 1 + checkedNum.value * 1 |
| | | // //面积 |
| | | // rightData[filterIndex].computeGrossArea = (rightData[filterIndex].width * rightData[filterIndex].height * rightData[filterIndex].baiscQuantity / 1000000).toFixed(2) |
| | | // //如果左边数量为0时删除此条数据 |
| | | // //删除key |
| | | // let key = item._X_ROW_KEY |
| | | // delete item._X_ROW_KEY |
| | | // if (item.baiscQuantity === 0) { |
| | | // $grid.remove(item) |
| | | // } |
| | | // item._X_ROW_KEY = key |
| | | // } else { |
| | | // //右边表格没有此条数据则往右边表格插入数据 |
| | | // item.baiscQuantity = checkedNum.value |
| | | // item.computeGrossArea = (item.width * item.height * checkedNum.value / 1000000).toFixed(2) |
| | | // if (item.quantity === 0) { |
| | | // $gridLeft.remove(item) |
| | | // } |
| | | // $grid.insert(item) |
| | | // } |
| | | // if (item.quantity === 0) { |
| | | // $gridLeft.remove(item) |
| | | // } |
| | | // }) |
| | | // } else if (checkedNum.value === '') {//判断数量输入框无输入数字 |
| | | // |
| | | // checkedList.forEach((item) => { |
| | | // //右侧表格 |
| | | // let rightData = $grid.getTableData().fullData |
| | | // let filterIndex = rightData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | // //左侧表格 |
| | | // let leftData = $gridLeft.getTableData().fullData |
| | | // let leftfilterIndex = leftData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | // //无输入并且如果右边表格数据中存在当前数据则数量相加 |
| | | // if (filterIndex > -1) { |
| | | // rightData[filterIndex].baiscQuantity = rightData[filterIndex].baiscQuantity * 1 + item.quantity * 1 |
| | | // //面积 |
| | | // rightData[filterIndex].computeGrossArea = (rightData[filterIndex].width * rightData[filterIndex].height * rightData[filterIndex].baiscQuantity / 1000000).toFixed(2) |
| | | // |
| | | // } else { |
| | | // |
| | | // item.baiscQuantity = item.quantity * 1 |
| | | // delete item._X_ROW_KEY |
| | | // $grid.insert(item) |
| | | // |
| | | // } |
| | | // |
| | | // $gridLeft.remove(item) |
| | | // }) |
| | | // |
| | | // } |
| | | // |
| | | // let leftDataList = $gridLeft.getTableData().fullData; |
| | | // let baseProcessId = productionId; // 固定的前缀 |
| | | // |
| | | // // 统计所有不重复的 processId |
| | | // let uniqueProcessIds = new Set(leftDataList.map(item => item.processId)); |
| | | // // 不重复的 processId 的总个数 |
| | | // let totalUniqueCount = uniqueProcessIds.size; |
| | | // // 用于记录已经分配的 processId |
| | | // let usedProcessIds = new Set(); |
| | | // |
| | | // leftDataList.forEach((item) => { |
| | | // let newProcessId; |
| | | // // 如果该 processId 是第一次出现,使用递减的编号生成新的 processId |
| | | // if (!usedProcessIds.has(item.processId)) { |
| | | // newProcessId = `${baseProcessId}${(totalUniqueCount).toString().padStart(3, '0')}`; |
| | | // usedProcessIds.add(item.processId); // 标记该 processId 已使用 |
| | | // totalUniqueCount--; // 递减 |
| | | // |
| | | // } else { |
| | | // // 如果该 processId 已经使用过,继续使用已分配的编号 |
| | | // newProcessId = `${baseProcessId}${(totalUniqueCount + 1).toString().padStart(3, '0')}`; |
| | | // |
| | | // } |
| | | // // 更新 item.processId |
| | | // item.processId = newProcessId; |
| | | // }); |
| | | // // 获取剩余数据,用于对落架顺序重新赋值 |
| | | // let remainingData = $gridLeft.getTableData().fullData; |
| | | // // 按 processId 分组 |
| | | // let groupedData = remainingData.reduce((acc, curr) => { |
| | | // if (!acc[curr.processId]) { |
| | | // acc[curr.processId] = []; |
| | | // } |
| | | // acc[curr.processId].push(curr); |
| | | // return acc; |
| | | // }, {}); |
| | | // |
| | | // // 按 processId 排序(倒序) |
| | | // let sortedProcessIds = Object.keys(groupedData).sort((a, b) => b - a); |
| | | // |
| | | // // 更新每个分组的 landingSequence |
| | | // sortedProcessIds.forEach((processId, index) => { |
| | | // let group = groupedData[processId]; |
| | | // |
| | | // // 对每个 processId 分组内的数据,不改变顺序,直接赋相同的 landingSequence |
| | | // group.forEach((item) => { |
| | | // item.landingSequence = sortedProcessIds.length - index; // 按倒序设置 landingSequence |
| | | // }); |
| | | // }); |
| | | // //清除两边复选框 |
| | | // $gridLeft.clearCheckboxRow() |
| | | // $grid.clearCheckboxRow() |
| | | // $grid.refreshColumn() |
| | | // } catch (e) { |
| | | // ElMessage.warning(e.message) |
| | | // } |
| | | // //每次点击情况输入框 |
| | | // if (checkedNum.value){ |
| | | // checkedNum.value ='' |
| | | // } |
| | | // } |
| | | |
| | | //向左边表格添加数据 |
| | | |
| | | //向左2 |
| | | const addLeft = () => { |
| | | try { |
| | | //左边表格定义 |
| | | const $gridLeft = xGridLeft.value |
| | | //右边表格定义 |
| | | const $grid = xGrid.value |
| | | //获取右边表格checkbox选中的数据 |
| | | |
| | | // 右表选中 |
| | | const checkedList = $grid.getCheckboxRecords() |
| | | //获取左边表格checkbox选中的数据 |
| | | // 左表选中(要求只能选 1 条,用于确定目标流程卡) |
| | | const checkedListLeft = $gridLeft.getCheckboxRecords() |
| | | //判断右边表格是否有选中的数据 |
| | | if (checkedList.length * 1 === 0) { |
| | | |
| | | // 基本校验 |
| | | if (!checkedList.length) { |
| | | ElMessage.warning(t('processCard.schedulingOk')) |
| | | return |
| | | } |
| | |
| | | ElMessage.warning(t('processCard.schedulingTime')) |
| | | return |
| | | } |
| | | const regex = /^(\d+|)$/; |
| | | const regex = /^(\d+|)$/ |
| | | if (!regex.test(checkedNum.value)) { |
| | | ElMessage.warning(t('processCard.schedulingNo')) |
| | | return |
| | | } |
| | | //判断正整数 |
| | | if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | |
| | | const isValidNum = /^[1-9]\d*$/.test(checkedNum.value) |
| | | const targetProcId = checkedListLeft[0].processId |
| | | const targetLandingSeq = checkedListLeft[0].landingSequence |
| | | |
| | | // 工具:把记录塞到左表表尾(存在相同 orderNumber+processId 就只合并数量) |
| | | const upsertToLeftTail = (srcRow, qtyToMove) => { |
| | | // 目标行应具有的键值 |
| | | const keyOrder = srcRow.orderNumber |
| | | const keyProc = targetProcId |
| | | |
| | | // 先找是否已有同 orderNumber + processId 的行 |
| | | const leftFull = $gridLeft.getTableData().fullData |
| | | const existIdx = leftFull.findIndex(r => r.orderNumber === keyOrder && r.processId === keyProc) |
| | | |
| | | if (existIdx >= 0) { |
| | | // 合并数量 |
| | | leftFull[existIdx].quantity = (leftFull[existIdx].quantity || 0) * 1 + qtyToMove * 1 |
| | | // 这里不额外扣 left 行的 computeGrossArea,避免重复扣减(扣减只在右侧减出时做) |
| | | // 如需左侧也扣,请按你的口径在此处补上 |
| | | // 不需要 reload,这里直接改 fullData,最后统一 refresh |
| | | } else { |
| | | // 新建一条放到表尾 |
| | | // 克隆一个干净对象,避免 _X_ROW_KEY 冲突 |
| | | const { _X_ROW_KEY, ...plain } = srcRow |
| | | const newRow = { |
| | | ...plain, |
| | | processId: targetProcId, |
| | | landingSequence: targetLandingSeq, |
| | | quantity: qtyToMove, |
| | | // 如果你希望新行也同步扣减自身面积,可以打开下面这一行; |
| | | // 否则注释保持只在右侧扣减一次 |
| | | // computeGrossArea: ( |
| | | // (plain.computeGrossArea || 0) - (plain.width * plain.height * qtyToMove) / 1000000 |
| | | // ).toFixed(2) |
| | | } |
| | | $gridLeft.insertAt(newRow, -1) // 永远插到表尾 |
| | | } |
| | | } |
| | | |
| | | if (isValidNum) { |
| | | // 移动「指定数量」 |
| | | const moveQty = checkedNum.value * 1 |
| | | |
| | | checkedList.forEach((item) => { |
| | | //判断可用数量是否大于等于输入的数量,不满足则抛出异常 |
| | | if (item.baiscQuantity * 1 < checkedNum.value * 1) throw new Error("请输入小于等于待分数量的数字"); |
| | | item.baiscQuantity = item.baiscQuantity - checkedNum.value |
| | | item.computeGrossArea = (item.computeGrossArea - item.width * item.height * checkedNum.value / 1000000).toFixed(2) |
| | | //定义key值保持 |
| | | let key = item._X_ROW_KEY |
| | | //左边表格数据 |
| | | let leftData = $gridLeft.getTableData().fullData |
| | | //左边表格数据中查找当前数据下标 |
| | | let filterIndex = leftData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | //判断右侧勾选值与左侧是否相同 |
| | | if (checkedListLeft[0].orderNumber === item.orderNumber) { |
| | | |
| | | //如果右边表格数据中存在当前数据则数量相加 |
| | | if (filterIndex >= 0) { |
| | | leftData[filterIndex].quantity = leftData[filterIndex].quantity * 1 + checkedNum.value * 1 |
| | | leftData[filterIndex].computeGrossArea = (leftData[filterIndex].computeGrossArea - leftData[filterIndex].width * leftData[filterIndex].height * leftData[filterIndex].baiscQuantity / 1000000).toFixed(2) |
| | | |
| | | if (item.baiscQuantity === 0) { |
| | | $grid.remove(item) |
| | | } |
| | | $gridLeft.reloadData([...$gridLeft.getTableData().fullData]) |
| | | //delete item._X_ROW_KEY |
| | | } else { |
| | | item.quantity = checkedNum.value |
| | | item.processId = checkedListLeft[0].processId |
| | | item.landingSequence = checkedListLeft[0].landingSequence |
| | | item.computeGrossArea = (item.computeGrossArea - checkedListLeft[0].width * checkedListLeft[0].height * checkedNum.value / 1000000).toFixed(2) |
| | | delete item._X_ROW_KEY |
| | | $gridLeft.insert(item) |
| | | item._X_ROW_KEY = key |
| | | } |
| | | } else { |
| | | |
| | | //如果勾选两个值不同则插入同流程卡 |
| | | item.quantity = checkedNum.value |
| | | item.processId = checkedListLeft[0].processId |
| | | item.landingSequence = checkedListLeft[0].landingSequence |
| | | // /item.computeGrossArea=item.computeGrossArea |
| | | if (item.baiscQuantity === 0) { |
| | | $grid.remove(item) |
| | | |
| | | } |
| | | for (let i = 0; i < leftData.length; i++) { |
| | | if (leftData[i].orderNumber === item.orderNumber && leftData[i].processId === item.processId) { |
| | | leftData[i].quantity = leftData[i].quantity * 1 + checkedNum.value * 1 |
| | | leftData[i].computeGrossArea = (leftData[i].computeGrossArea - leftData[i].width * leftData[i].height * leftData[i].baiscQuantity / 1000000).toFixed(2) |
| | | break |
| | | } else if (leftData[i].orderNumber === item.orderNumber && leftData[i].processId !== item.processId) { |
| | | delete item._X_ROW_KEY |
| | | $gridLeft.insert(item) |
| | | item._X_ROW_KEY = key |
| | | break |
| | | } else if (leftData[i].orderNumber !== item.orderNumber && leftData[i].processId !== item.processId) { |
| | | delete item._X_ROW_KEY |
| | | $gridLeft.insert(item) |
| | | item._X_ROW_KEY = key |
| | | break |
| | | } else if (leftData[i].orderNumber !== item.orderNumber && leftData[i].processId == item.processId) { |
| | | delete item._X_ROW_KEY |
| | | $gridLeft.insert(item) |
| | | item._X_ROW_KEY = key |
| | | break |
| | | } |
| | | |
| | | } |
| | | if ((item.baiscQuantity * 1) < moveQty) { |
| | | throw new Error(t('processCard.msg.msg2')) |
| | | } |
| | | |
| | | // 右表扣数量、扣面积(只扣一次,避免左表再扣重复) |
| | | item.baiscQuantity = item.baiscQuantity * 1 - moveQty |
| | | item.computeGrossArea = ( |
| | | (item.computeGrossArea * 1) - (item.width * item.height * moveQty) / 1000000 |
| | | ).toFixed(2) |
| | | |
| | | // 写入左表(表尾),或合并 |
| | | upsertToLeftTail(item, moveQty) |
| | | |
| | | // 右表该行分完清零就删掉 |
| | | if (item.baiscQuantity * 1 === 0) { |
| | | $grid.remove(item) |
| | | } |
| | | }) |
| | | } else if (checkedNum.value === '') {//判断数量输入框无输入数字 |
| | | } else if (checkedNum.value === '') { |
| | | // 移动「全部待分数量」 |
| | | checkedList.forEach((item) => { |
| | | item.processId = checkedListLeft[0].processId |
| | | item.landingSequence = checkedListLeft[0].landingSequence |
| | | item.quantity = item.baiscQuantity |
| | | item.computeGrossArea = (item.computeGrossArea - checkedListLeft[0].width * checkedListLeft[0].height * checkedListLeft[0].baiscQuantity / 1000000).toFixed(2) |
| | | delete item._X_ROW_KEY |
| | | const moveQtyAll = item.baiscQuantity * 1 |
| | | if (moveQtyAll <= 0) return |
| | | |
| | | // 右表扣到 0,扣面积 |
| | | item.baiscQuantity = 0 |
| | | item.computeGrossArea = ( |
| | | (item.computeGrossArea * 1) - (item.width * item.height * moveQtyAll) / 1000000 |
| | | ).toFixed(2) |
| | | |
| | | // 写入左表(表尾),或合并 |
| | | upsertToLeftTail(item, moveQtyAll) |
| | | |
| | | // 移除右表该行 |
| | | $grid.remove(item) |
| | | }) |
| | | $gridLeft.insertAt(checkedList) |
| | | $grid.remove(checkedList) |
| | | } |
| | | //清除两边复选框 |
| | | if ($gridLeft || $grid) { |
| | | $gridLeft.clearCheckboxRow() |
| | | $grid.clearCheckboxRow() |
| | | } |
| | | |
| | | // 清勾选 & 刷新 |
| | | if ($gridLeft) $gridLeft.clearCheckboxRow() |
| | | if ($grid) $grid.clearCheckboxRow() |
| | | $grid.refreshColumn() |
| | | |
| | | } catch (e) { |
| | | ElMessage.warning(e.message) |
| | | } |
| | | if (checkedNum.value){ |
| | | checkedNum.value ='' |
| | | |
| | | // 清空输入 |
| | | if (checkedNum.value) { |
| | | checkedNum.value = '' |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //向左边表格添加数据 |
| | | // const addLeft = () => { |
| | | // try { |
| | | // //左边表格定义 |
| | | // const $gridLeft = xGridLeft.value |
| | | // //右边表格定义 |
| | | // const $grid = xGrid.value |
| | | // //获取右边表格checkbox选中的数据 |
| | | // const checkedList = $grid.getCheckboxRecords() |
| | | // //获取左边表格checkbox选中的数据 |
| | | // const checkedListLeft = $gridLeft.getCheckboxRecords() |
| | | // //判断右边表格是否有选中的数据 |
| | | // if (checkedList.length * 1 === 0) { |
| | | // ElMessage.warning(t('processCard.schedulingOk')) |
| | | // return |
| | | // } |
| | | // if (checkedListLeft.length !== 1) { |
| | | // ElMessage.warning(t('processCard.schedulingTime')) |
| | | // return |
| | | // } |
| | | // const regex = /^(\d+|)$/; |
| | | // if (!regex.test(checkedNum.value)) { |
| | | // ElMessage.warning(t('processCard.schedulingNo')) |
| | | // return |
| | | // } |
| | | // //判断正整数 |
| | | // if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | // checkedList.forEach((item) => { |
| | | // //判断可用数量是否大于等于输入的数量,不满足则抛出异常 |
| | | // if (item.baiscQuantity * 1 < checkedNum.value * 1) throw new Error("请输入小于等于待分数量的数字"); |
| | | // item.baiscQuantity = item.baiscQuantity - checkedNum.value |
| | | // item.computeGrossArea = (item.computeGrossArea - item.width * item.height * checkedNum.value / 1000000).toFixed(2) |
| | | // //定义key值保持 |
| | | // let key = item._X_ROW_KEY |
| | | // //左边表格数据 |
| | | // let leftData = $gridLeft.getTableData().fullData |
| | | // //左边表格数据中查找当前数据下标 |
| | | // let filterIndex = leftData.findIndex(item1 => item1.orderNumber === item.orderNumber) |
| | | // //判断右侧勾选值与左侧是否相同 |
| | | // if (checkedListLeft[0].orderNumber === item.orderNumber) { |
| | | // |
| | | // //如果右边表格数据中存在当前数据则数量相加 |
| | | // if (filterIndex >= 0) { |
| | | // leftData[filterIndex].quantity = leftData[filterIndex].quantity * 1 + checkedNum.value * 1 |
| | | // leftData[filterIndex].computeGrossArea = (leftData[filterIndex].computeGrossArea - leftData[filterIndex].width * leftData[filterIndex].height * leftData[filterIndex].baiscQuantity / 1000000).toFixed(2) |
| | | // |
| | | // if (item.baiscQuantity === 0) { |
| | | // $grid.remove(item) |
| | | // } |
| | | // $gridLeft.reloadData([...$gridLeft.getTableData().fullData]) |
| | | // //delete item._X_ROW_KEY |
| | | // } else { |
| | | // item.quantity = checkedNum.value |
| | | // item.processId = checkedListLeft[0].processId |
| | | // item.landingSequence = checkedListLeft[0].landingSequence |
| | | // item.computeGrossArea = (item.computeGrossArea - checkedListLeft[0].width * checkedListLeft[0].height * checkedNum.value / 1000000).toFixed(2) |
| | | // delete item._X_ROW_KEY |
| | | // $gridLeft.insert(item) |
| | | // item._X_ROW_KEY = key |
| | | // } |
| | | // } else { |
| | | // |
| | | // //如果勾选两个值不同则插入同流程卡 |
| | | // item.quantity = checkedNum.value |
| | | // item.processId = checkedListLeft[0].processId |
| | | // item.landingSequence = checkedListLeft[0].landingSequence |
| | | // // /item.computeGrossArea=item.computeGrossArea |
| | | // if (item.baiscQuantity === 0) { |
| | | // $grid.remove(item) |
| | | // |
| | | // } |
| | | // for (let i = 0; i < leftData.length; i++) { |
| | | // if (leftData[i].orderNumber === item.orderNumber && leftData[i].processId === item.processId) { |
| | | // leftData[i].quantity = leftData[i].quantity * 1 + checkedNum.value * 1 |
| | | // leftData[i].computeGrossArea = (leftData[i].computeGrossArea - leftData[i].width * leftData[i].height * leftData[i].baiscQuantity / 1000000).toFixed(2) |
| | | // break |
| | | // } else if (leftData[i].orderNumber === item.orderNumber && leftData[i].processId !== item.processId) { |
| | | // delete item._X_ROW_KEY |
| | | // $gridLeft.insert(item) |
| | | // item._X_ROW_KEY = key |
| | | // break |
| | | // } else if (leftData[i].orderNumber !== item.orderNumber && leftData[i].processId !== item.processId) { |
| | | // delete item._X_ROW_KEY |
| | | // $gridLeft.insert(item) |
| | | // item._X_ROW_KEY = key |
| | | // break |
| | | // } else if (leftData[i].orderNumber !== item.orderNumber && leftData[i].processId == item.processId) { |
| | | // delete item._X_ROW_KEY |
| | | // $gridLeft.insert(item) |
| | | // item._X_ROW_KEY = key |
| | | // break |
| | | // } |
| | | // |
| | | // } |
| | | // } |
| | | // |
| | | // }) |
| | | // } else if (checkedNum.value === '') {//判断数量输入框无输入数字 |
| | | // checkedList.forEach((item) => { |
| | | // item.processId = checkedListLeft[0].processId |
| | | // item.landingSequence = checkedListLeft[0].landingSequence |
| | | // item.quantity = item.baiscQuantity |
| | | // item.computeGrossArea = (item.computeGrossArea - checkedListLeft[0].width * checkedListLeft[0].height * checkedListLeft[0].baiscQuantity / 1000000).toFixed(2) |
| | | // delete item._X_ROW_KEY |
| | | // }) |
| | | // $gridLeft.insertAt(checkedList) |
| | | // $grid.remove(checkedList) |
| | | // } |
| | | // //清除两边复选框 |
| | | // if ($gridLeft || $grid) { |
| | | // $gridLeft.clearCheckboxRow() |
| | | // $grid.clearCheckboxRow() |
| | | // } |
| | | // $grid.refreshColumn() |
| | | // } catch (e) { |
| | | // ElMessage.warning(e.message) |
| | | // } |
| | | // if (checkedNum.value){ |
| | | // checkedNum.value ='' |
| | | // } |
| | | // } |
| | | |
| | | |
| | | //保存流程卡数据 |
| | |
| | | if ($grid) { |
| | | switch (code) { |
| | | case 'saveFlowCard': { |
| | | |
| | | gridLeftOptions.toolbarConfig.buttons[0].disabled=true |
| | | const $table = xGridLeft.value |
| | | const $tableRight = xGrid.value |
| | | if ($table) { |
| | | const selectRecords = $table.getCheckboxRecords() |
| | | // const selectRight = $tableRight.getCheckboxRecords() |
| | | let leftData = $tableRight.getTableData().fullData |
| | | if (selectRecords.length === 0) { |
| | | ElMessage.warning(t('processCard.pleaseSelectTheSavedDataFirst')) |
| | | gridLeftOptions.toolbarConfig.buttons[0].disabled=false |
| | | return |
| | | } |
| | | |
| | | let data = $table.getTableData().fullData |
| | | if (leftData.length > 0) { |
| | | ElMessage.warning(t('processCard.pleaseFirstCreateAProcessCardForAllTheDataOnTheRightSideAndSaveIt')) |
| | | gridLeftOptions.toolbarConfig.buttons[0].disabled=false |
| | |
| | | } |
| | | |
| | | // 计算 $table 里 quantity 字段的总和 |
| | | let totalQuantity = selectRecords.reduce((sum, record) => sum + (Number(record.quantity) || 0), 0); |
| | | let totalQuantity = data.reduce((sum, record) => sum + (Number(record.quantity) || 0), 0); |
| | | // 对比全局变量 orderQuantity |
| | | if (totalQuantity !== orderQuantity*1) { |
| | | ElMessage.warning(`所选数据的数量总和 (${totalQuantity}) 与订单数量 (${orderQuantity}) 不匹配,请检查后重试!`); |
| | | ElMessage.warning(`${t('processCard.msg.msg3')} (${totalQuantity}) ${t('processCard.msg.msg4')} (${orderQuantity}) ${t('processCard.msg.msg5')}`); |
| | | gridLeftOptions.toolbarConfig.buttons[0].disabled = false; |
| | | return; |
| | | } |
| | | // if (leftData.length!=selectRecords.length){ |
| | | // ElMessage.warning('请勾选所有数据进行保存') |
| | | // gridLeftOptions.toolbarConfig.buttons[0].disabled=false |
| | | // return; |
| | | // } |
| | | gridOptions.loading=true |
| | | gridLeftOptions.loading=true |
| | | let flowCardData = ref({ |
| | | flowCard: selectRecords, |
| | | flowCard: data, |
| | | userName: username, |
| | | productionId: productionId, |
| | | userId:user.user.userId |
| | |
| | | request.post(`/processCard/addFlowCard/${orderId}`, flowCardData.value).then((res) => { |
| | | if (res.code == 200) { |
| | | ElMessage.success(t('basicData.msg.saveSuccess')) |
| | | //router.push('/main/processCard/SplittingDetails?orderId=${orderId}') |
| | | router.push({ |
| | | path: '/main/processCard/AddProcessCard', |
| | | query: {orderId: orderId, productionId: productionId, random: Math.random()} |
| | | }) |
| | | |
| | | //location.reload(); |
| | | gridOptions.loading=false |
| | | gridLeftOptions.loading=false |
| | | } else { |
| | | gridOptions.loading=false |
| | | gridLeftOptions.loading=false |
| | | ElMessage.warning(res.msg) |
| | | } |
| | | }) |
| | |
| | | @checkbox-all="handleCheckboxChange" |
| | | @checkbox-range-end="handleCheckboxChange" |
| | | > |
| | | |
| | | <!-- 自定义 toolbar_buttons 插槽 --> |
| | | <template #toolbar_buttons="{ $grid }"> |
| | | |
| | | |
| | | <!-- 手动写出所有按钮 --> |
| | | |
| | | <el-select |
| | | :default-first-option="true" |
| | | ref="getSelect" style="width: 80px" |
| | | v-model="optionVal" |
| | | class="m-2" |
| | | > |
| | | <el-option |
| | | v-for="item in options" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | |
| | | <el-button |
| | | type="primary" |
| | | style="margin-right:8px;width: 50px" |
| | | @click="$grid.dispatchEvent('toolbar-button-click', { code: 'sorting' })" |
| | | > |
| | | {{ t('processCard.sorting') }} |
| | | </el-button> |
| | | |
| | | <!-- <el-checkbox--> |
| | | <!-- :model-value="flashback === 0"--> |
| | | <!-- @change="onFlashbackChange"--> |
| | | <!-- >--> |
| | | <!-- {{ t('processCard.flashback') }}--> |
| | | <!-- </el-checkbox>--> |
| | | |
| | | |
| | | </template> |
| | | |
| | | |
| | | |
| | | <!-- @toolbar-button-click="toolbarButtonClickEvent"--> |
| | | <!-- 下拉显示所有信息插槽--> |