| | |
| | | |
| | | import request from "@/utils/request" |
| | | import deepClone from "@/utils/deepClone" |
| | | import {ElDatePicker, ElMessage} from "element-plus" |
| | | import {ElCheckbox, ElDatePicker, ElMessage} from "element-plus" |
| | | import useProductGlassTypeStore from "@/stores/sd/product/productGlassType" |
| | | import {nextTick, onMounted, onUnmounted, reactive, ref, watch} from "vue" |
| | | import {ArrowLeftBold, Search} from "@element-plus/icons-vue" |
| | |
| | | } |
| | | flag = !flag |
| | | } |
| | | |
| | | //倒叙 |
| | | let flashback = ref(1) |
| | | |
| | | //定义排序规则 |
| | | const optionVal = ref(0) |
| | | const options = [ |
| | | { |
| | | value: 0, |
| | | label: t('processCard.mainWidth'), |
| | | }, |
| | | { |
| | | value: 1, |
| | | label: t('processCard.mainHeight'), |
| | | }, |
| | | ] |
| | | |
| | | //定义时间 |
| | | const form = reactive({ |
| | |
| | | const {currentRoute} = useRouter() |
| | | const route = currentRoute.value |
| | | |
| | | let orderId = route.query.orderId |
| | | let productionId = route.query.productionId |
| | | const orderId = route.query.orderId |
| | | const productionId = route.query.productionId |
| | | const orderQuantity = route.query.quantity |
| | | |
| | | const orderOtherMoney = ref(null) |
| | | |
| | |
| | | |
| | | }) |
| | | produceList = produceList.value.concat(deepClone(res.data.data)) |
| | | produceList.forEach(item => { |
| | | // 如果 shape 可能是字符串就用 ==,如果一定是数字就用 === |
| | | item.shape = (item.shape == 2) ? t('order.alien') : t('order.universalShape'); |
| | | }); |
| | | xGrid.value.reloadData(produceList) |
| | | gridOptions.loading = false |
| | | } else { |
| | |
| | | filterConfig: { //筛选配置项 |
| | | //remote: true |
| | | }, |
| | | formConfig: { |
| | | data: { |
| | | shelfThickness: 800, |
| | | spacerThickness: 0, |
| | | inWeight: 4000, |
| | | inMaxQuantity: 20, |
| | | inLenMin:350, |
| | | inLenMax:3500, |
| | | inShortMax:2500, |
| | | inShortMin:350 |
| | | }, |
| | | rules:{ |
| | | shelfThickness: [ |
| | | { required: true, message: t('basicData.msg.greater0'),type:'number',pattern:/^[1-9]\d*$/ } |
| | | ], |
| | | spacerThickness: [ |
| | | { required: true, message: t('delivery.pleaseEnterANumericalValueGreaterThanOrEqualTo0'),type:'number',pattern:/^[0-9]\d*$/ } |
| | | ], |
| | | inWeight: [ |
| | | { required: true, message: t('basicData.msg.greater0'),type:'number',pattern:/^[1-9]\d*$/ } |
| | | ], |
| | | inMaxQuantity: [ |
| | | { required: true, message: t('basicData.msg.greater0'),type:'number',pattern:/^[1-9]\d*$/ } |
| | | ] |
| | | }, |
| | | items:[ |
| | | { field: 'shelfThickness', title: t('processCard.depthShelf'), itemRender: { name: 'VxeInput' },span:8,folding: true}, |
| | | { field: 'inWeight', title:t('processCard.shelfCapacity'), itemRender: { name: 'VxeInput' },span:8,folding: true }, |
| | | { field: 'spacerThickness', title: t('processCard.IntervalThickness'), itemRender: { name: 'VxeInput' } ,span:8,folding: true}, |
| | | { field: 'inLenMax', title: t('processCard.LongestLargestMax'), itemRender: { name: 'VxeInput' },span:8,folding: true }, |
| | | { field: 'inLenMin', title: t('processCard.LongestShortestMax'), itemRender: { name: 'VxeInput' },span:8,folding: true }, |
| | | { field: 'inMaxQuantity', title: t('processCard.quantityMax'), itemRender: { name: 'VxeInput' } ,span:8,folding: true}, |
| | | { field: 'inShortMax', title: t('processCard.shortestLongest'), itemRender: { name: 'VxeInput' },span:8,folding: true }, |
| | | { field: 'inShortMin', title: t('processCard.shortestSide'), itemRender: { name: 'VxeInput' },span:8,folding: true }, |
| | | { |
| | | span: 24, |
| | | collapseNode: true, |
| | | align: 'center', |
| | | itemRender: { |
| | | name: 'VxeButtonGroup', |
| | | options: [ |
| | | { type: 'submit', content: t('processCard.intelligentBranching'), status: 'primary' }, |
| | | { type: 'reset', content: t('processCard.reset') } |
| | | ] |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | customConfig: { |
| | | 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: { |
| | | // buttons: [{ |
| | | // |
| | | // }], |
| | | // import: false, |
| | | // export: true, |
| | | // print: true, |
| | |
| | | }) |
| | | return parseFloat(count.toFixed(2)) |
| | | } |
| | | |
| | | return '' |
| | | }) |
| | | ] |
| | | }, |
| | | |
| | | }) |
| | | const gridEventsRight = { |
| | | 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) |
| | | }) |
| | | }, |
| | | formReset () { |
| | | router.push({ |
| | | path: '/main/processCard/AddProcessCard', |
| | | query: {orderId: orderId, |
| | | productionId: productionId, |
| | | quantity: orderQuantity, |
| | | random:Math.random() |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | //左侧子组件接收参数 |
| | | const xGridLeft = ref() |
| | |
| | | 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}, |
| | | ],//表头按钮 |
| | | |
| | |
| | | ElMessage.warning(t('processCard.schedulingOk')) |
| | | return |
| | | } |
| | | //productionId |
| | | |
| | | const $gridLeft = xGridLeft.value |
| | | const leftData = $gridLeft.getTableData().fullData |
| | | |
| | | // 获取最大落架顺序 |
| | | let index = 1 |
| | | if (leftData.length !== 0) { |
| | | index = leftData[0].landingSequence + 1 |
| | | //index = index.toString().padStart(2, '0') |
| | | index = Math.max(...leftData.map(d => d.landingSequence || 0)) + 1 |
| | | } |
| | | let processId= null |
| | | // if (leftData.length !== 0){ |
| | | // processId = productionId + index.toString().padStart(3, '0') |
| | | // } |
| | | // else { |
| | | if (maxProcseeId!== null || maxProcseeId!== undefined|| maxProcseeId!== ''){ |
| | | if (leftData.length !== 0){ |
| | | const str=leftData[0].processId |
| | | const lastThree = str.slice(-3); |
| | | const result = lastThree*1 + 1; |
| | | processId= productionId + result.toString().padStart(3, '0') |
| | | } |
| | | else { |
| | | // 截取后三位 |
| | | const lastThree = maxProcseeId.slice(-3); |
| | | const result = lastThree*1 + 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 regex = /^(\d+|)$/; |
| | | const processId = productionId + baseIdNum.toString().padStart(3, '0') |
| | | |
| | | // 校验数量 |
| | | const regex = /^(\d+|)$/ |
| | | if (!regex.test(checkedNum.value)) { |
| | | ElMessage.warning(t('processCard.schedulingNo')) |
| | | return |
| | | } |
| | | //判断正整数 |
| | | if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | checkedList.forEach((item) => { |
| | | //定义key值保持 |
| | | //判断可用数量是否大于等于输入的数量,不满足则抛出异常 |
| | | if (item.baiscQuantity * 1 < checkedNum.value * 1) throw new Error(t('processCard.schedulingQuantity')); |
| | | item.quantity = checkedNum.value |
| | | item.processId = processId |
| | | item.landingSequence = index |
| | | 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 |
| | | delete item._X_ROW_KEY |
| | | if (item.baiscQuantity === 0) { |
| | | $grid.remove(item) |
| | | } |
| | | $gridLeft.insertAt(item) |
| | | //重新赋值key |
| | | item._X_ROW_KEY = key |
| | | }) |
| | | try { |
| | | if (/^[1-9]\d*$/.test(checkedNum.value)) { |
| | | // 有输入数量的 |
| | | checkedList.forEach((item) => { |
| | | if (item.baiscQuantity < checkedNum.value * 1) { |
| | | throw new Error(t('processCard.schedulingQuantity')) |
| | | } |
| | | |
| | | //清除两边复选框 |
| | | 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 |
| | | newItem.baiscQuantity -= checkedNum.value * 1 |
| | | newItem.computeGrossArea = ( |
| | | newItem.computeGrossArea - newItem.width * newItem.height * checkedNum.value / 1000000 |
| | | ).toFixed(2) |
| | | |
| | | 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, newItem]) |
| | | $grid.refreshColumn() |
| | | |
| | | }) |
| | | } else if (checkedNum.value === '') { |
| | | // 未输入数量 |
| | | 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) |
| | | $gridLeft.clearSort() |
| | | $gridLeft.loadData([...currentLeft, ...newList]) |
| | | } |
| | | |
| | | // 清空选择和输入 |
| | | $gridLeft.clearCheckboxRow() |
| | | $grid.clearCheckboxRow() |
| | | } else if (checkedNum.value === '') {//判断数量输入框无输入数字 |
| | | checkedNum.value = '' |
| | | |
| | | checkedList.forEach((item) => { |
| | | item.processId = processId |
| | | item.landingSequence = index |
| | | item.quantity = item.baiscQuantity |
| | | }) |
| | | //删除key |
| | | checkedList.forEach((item) => { |
| | | delete item._X_ROW_KEY |
| | | }) |
| | | $gridLeft.insertAt(checkedList) |
| | | $grid.remove(checkedList) |
| | | //清除两边复选框 |
| | | $gridLeft.clearCheckboxRow() |
| | | $grid.clearCheckboxRow() |
| | | } catch (e) { |
| | | 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.baiscQuantity * 1 + leftData[leftfilterIndex].quantity * 1 |
| | | // item.computeGrossArea=(item.width*item.height*item.baiscQuantity/1000000).toFixed(2) |
| | | //item.computeGrossArea=(item.width*item.height*item.baiscQuantity/1000000).toFixed(2) |
| | | // for (let i = 0; i <checkedList.length ; i++) { |
| | | // |
| | | // if (checkedList[i].orderNumber === item.orderNumber){ |
| | | // console.log(item.baiscQuantity +"---"+ checkedList[i].quantity ) |
| | | // item.baiscQuantity = item.baiscQuantity * 1 + checkedList[i].quantity * 1 |
| | | // } |
| | | // } |
| | | |
| | | item.baiscQuantity = item.quantity * 1 |
| | | delete item._X_ROW_KEY |
| | | $grid.insert(item) |
| | | |
| | | |
| | | } |
| | | |
| | | $gridLeft.remove(item) |
| | | }) |
| | | |
| | | |
| | | } |
| | | //清除两边复选框 |
| | | |
| | | // ===== 下面这部分:把“倒序”改成“顺序” ===== |
| | | |
| | | // 获取左表剩余数据 |
| | | const leftDataList = $gridLeft.getTableData().fullData |
| | | const baseProcessId = productionId // 固定前缀 |
| | | |
| | | // 取ID末尾数字(没有数字则返回极大值,防止相减 NaN/错序) |
| | | const tailNum = (id) => { |
| | | const m = String(id ?? '').match(/(\d+)$/) |
| | | return m ? parseInt(m[1], 10) : Number.MAX_SAFE_INTEGER |
| | | } |
| | | |
| | | // 先按原 processId 分组 |
| | | const groupedByOld = leftDataList.reduce((acc, row) => { |
| | | const pid = row.processId |
| | | if (!acc[pid]) acc[pid] = [] |
| | | acc[pid].push(row) |
| | | 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 -> 新 processId 的映射:001, 002, ... 正序递增 |
| | | const pidMap = new Map() |
| | | oldIds.forEach((oldId, idx) => { |
| | | const newPid = `${baseProcessId}${String(idx + 1).padStart(3, '0')}` |
| | | pidMap.set(oldId, newPid) |
| | | }) |
| | | |
| | | |
| | | 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 = '' |
| | | } |
| | | } |
| | | //向左边表格添加数据 |
| | | |
| | | //向右边表格添加数据 |
| | | // 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) |
| | | } |
| | | //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')) |
| | | } |
| | | |
| | | }) |
| | | } else if (checkedNum.value === '') {//判断数量输入框无输入数字 |
| | | checkedList.forEach((item) => { |
| | | item.processId = checkedListLeft[0].processId |
| | | item.landingSequence = checkedListLeft[0].landingSequence |
| | | item.quantity = checkedListLeft[0].baiscQuantity |
| | | item.computeGrossArea = (item.computeGrossArea - checkedListLeft[0].width * checkedListLeft[0].height * checkedListLeft[0].baiscQuantity / 1000000).toFixed(2) |
| | | // 右表扣数量、扣面积(只扣一次,避免左表再扣重复) |
| | | item.baiscQuantity = item.baiscQuantity * 1 - moveQty |
| | | item.computeGrossArea = ( |
| | | (item.computeGrossArea * 1) - (item.width * item.height * moveQty) / 1000000 |
| | | ).toFixed(2) |
| | | |
| | | delete item._X_ROW_KEY |
| | | // 写入左表(表尾),或合并 |
| | | upsertToLeftTail(item, moveQty) |
| | | |
| | | // 右表该行分完清零就删掉 |
| | | if (item.baiscQuantity * 1 === 0) { |
| | | $grid.remove(item) |
| | | } |
| | | }) |
| | | $gridLeft.insertAt(checkedList) |
| | | $grid.remove(checkedList) |
| | | } else if (checkedNum.value === '') { |
| | | // 移动「全部待分数量」 |
| | | checkedList.forEach((item) => { |
| | | 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) |
| | | }) |
| | | } |
| | | //清除两边复选框 |
| | | 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 = '' |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //向左边表格添加数据 |
| | | // 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 |
| | | return; |
| | | } |
| | | |
| | | // 计算 $table 里 quantity 字段的总和 |
| | | let totalQuantity = data.reduce((sum, record) => sum + (Number(record.quantity) || 0), 0); |
| | | // 对比全局变量 orderQuantity |
| | | if (totalQuantity !== orderQuantity*1) { |
| | | ElMessage.warning(`${t('processCard.msg.msg3')} (${totalQuantity}) ${t('processCard.msg.msg4')} (${orderQuantity}) ${t('processCard.msg.msg5')}`); |
| | | 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) |
| | | } |
| | | }) |
| | |
| | | |
| | | let quantit = ref('') |
| | | let weight = ref('') |
| | | const handleCheckboxChange = ({row}) => { |
| | | const $grid = xGrid.value |
| | | //获取右边表格checkbox选中的数据 |
| | | const checkedList = $grid.getCheckboxRecords() |
| | | const handleCheckboxChange = ({ row }) => { |
| | | const $grid = xGrid.value; |
| | | // 获取右边表格 checkbox 选中的数据 |
| | | const checkedList = $grid.getCheckboxRecords(); |
| | | let quantitySum = 0; |
| | | let weightsum = 0; |
| | | |
| | | checkedList.forEach(item => { |
| | | quantitySum += item.baiscQuantity; |
| | | quantitySum += Number(item.baiscQuantity) || 0; // 确保转换为数字 |
| | | weightsum += weightSum(item); |
| | | }); |
| | | quantit.value = quantitySum; |
| | | |
| | | quantit.value = Number(quantitySum) || 0; // 确保最终值是数字 |
| | | weight.value = parseFloat(weightsum.toFixed(2)); |
| | | }; |
| | | |
| | | //倒序赋值 |
| | | function onFlashbackChange(checked) { |
| | | flashback.value = checked ? 0 : 1 |
| | | } |
| | | </script> |
| | | |
| | |
| | | <div height="100%" style="margin: 5px" width="11%"> |
| | | <el-main style=""> |
| | | <div> |
| | | <span><el-input v-model="quantit" style="width: 80px;"/></span> |
| | | <span><el-input v-model="weight" style="width: 80px;"/></span> |
| | | <span><el-input :readonly="true" v-model="quantit" style="width: 80px;"/></span> |
| | | <span><el-input :readonly="true" v-model="weight" style="width: 80px;"/></span> |
| | | </div> |
| | | <span>{{ $t('processCard.selectedQuantity') }}:<el-input v-model="checkedNum" clearable |
| | | <span>{{ $t('processCard.selectedQuantity') }}:<el-input id="checkedNum" v-model="checkedNum" clearable |
| | | type="number"></el-input></span><br> |
| | | <el-button style="width: 40px;" type="primary" @click="addRight"> →</el-button> |
| | | <br> |
| | |
| | | <vxe-grid |
| | | id="rightTable" |
| | | ref="xGrid" |
| | | checkbox-config="{ reserve: true, strict: true }" |
| | | :checkbox-config="{labelField: 'name', highlight: true, range: true,reserve: true, strict: true}" |
| | | class="mytable-scrollbar" |
| | | height="100%" |
| | | v-bind="gridOptions" |
| | | v-on="gridEventsRight" |
| | | @checkbox-change="handleCheckboxChange" |
| | | @checkbox-all="handleCheckboxChange" |
| | | @checkbox-range-end="handleCheckboxChange" |
| | | > |
| | | |
| | | <!-- @toolbar-button-click="toolbarButtonClickEvent"--> |
| | | <!-- 下拉显示所有信息插槽--> |
| | | <template #content="{ row }"> |