| | |
| | | } |
| | | } |
| | | |
| | | //复选框触发事件 |
| | | const handleCheckboxChange = ({ records, checked, row }) => { |
| | | const $grid = xGrid.value; |
| | | if (!$grid) return; |
| | | |
| | | // 获取当前所有选中的行(返回数组) |
| | | const allCheckedRows = $grid.getCheckboxRecords(); |
| | | // 获取表格所有数据(visibleData 是当前可见数据,fullData 是全部数据,根据需求选择) |
| | | const tableData = $grid.getTableData().visibleData; |
| | | // 按箱号分组 |
| | | const boxNoGroup = groupByBoxNo(tableData); |
| | | // 当前行的箱号 |
| | | const currentBoxNo = row.finishedGoodsInventory?.boxNo || ''; |
| | | |
| | | // 选中逻辑:如果是“选中”操作,同箱号的行全部选中 |
| | | if (checked && currentBoxNo!="" && currentBoxNo!=null) { |
| | | const sameBoxRows = boxNoGroup[currentBoxNo] || []; |
| | | // 批量设置同箱号的行为选中状态(跳过已选中的行,避免重复触发) |
| | | sameBoxRows.forEach(item => { |
| | | const isAlreadyChecked = allCheckedRows.some(checkedRow => { |
| | | return checkedRow._X_ROW_KEY === item._X_ROW_KEY; |
| | | }); |
| | | // 未选中则设置为选中 |
| | | if (!isAlreadyChecked) { |
| | | $grid.setCheckboxRow(item, true); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | |
| | | |
| | | const groupByBoxNo = (tableData) => { |
| | | return tableData.reduce((group, row) => { |
| | | // 获取当前行的箱号(注意处理 undefined 情况) |
| | | const boxNo = row.finishedGoodsInventory?.boxNo || ''; |
| | | if (!group[boxNo]) { |
| | | group[boxNo] = []; |
| | | } |
| | | group[boxNo].push(row); |
| | | return group; |
| | | }, {}); |
| | | }; |
| | | |
| | | |
| | | //计算金钱 |
| | | const countMoney = (list) => { |
| | | let countMoney = 0 |
| | |
| | | v-on="gridEvents" |
| | | :edit-rules="validRules" |
| | | @edit-closed="editClosedEvent" |
| | | @checkbox-change="handleCheckboxChange" |
| | | |
| | | > |
| | | <template #num1_filter="{ column, $panel }"> |