| | |
| | | :data="donorchargeList" |
| | | tooltip-effect="dark" |
| | | style="width: 100%" |
| | | @select="handleSelect" |
| | | @select-all="handleSelectAll" |
| | | @selection-change="handleSelectionChange" |
| | | > |
| | | <el-table-column class="checkall" type="selection" width="55"> |
| | | <el-table-column |
| | | class="checkall" |
| | | type="selection" |
| | | width="55" |
| | | :selectable="checkSelectable" |
| | | > |
| | | </el-table-column> |
| | | <el-table-column |
| | | prop="icdid" |
| | |
| | | }, |
| | | donorchargeList: [], |
| | | donorchargeanlList: [], //案例列表 |
| | | // 新增:是否正在处理全选操作的标志 |
| | | isSelectAllProcessing: false, |
| | | }; |
| | | }, |
| | | |
| | |
| | | this.Restorecheck(); |
| | | }); |
| | | }, |
| | | // 多选框选中数据 |
| | | handleSelectionChange(selection) { |
| | | if (this.decision) return; |
| | | // 判断是否有删除 |
| | | if (this.multipleSelection.length <= selection.length) { |
| | | this.multipleSelection = selection; |
| | | } else { |
| | | this.multipleSelection.forEach((item) => { |
| | | if (selection.includes(item)) { |
| | | } else { |
| | | if (this.multipleSelection.length == 1) { |
| | | this.multipleSelection = []; |
| | | } else { |
| | | this.multipleSelection.splice( |
| | | this.multipleSelection.indexOf(item), |
| | | 1 |
| | | ); |
| | | } |
| | | if (this.overallCase.length == 1) { |
| | | this.overallCase = []; |
| | | } else { |
| | | this.overallCase.splice(this.overallCase.indexOf(item), 1); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | // 赋值给整体选中数组 |
| | | this.multipleSelection.forEach((item) => { |
| | | |
| | | if (this.overallCase.every((obj) => obj.icdname != item.icdname)) { |
| | | this.overallCase.push(item); |
| | | } |
| | | }); |
| | | console.log(this.multipleSelection, "触发选择后multipleSelection"); |
| | | // 新增:处理单个选择 |
| | | handleSelect(selection, row) { |
| | | if (this.isSelectAllProcessing) return; |
| | | |
| | | const isSelected = selection.includes(row); |
| | | this.handleItemSelection(row, isSelected); |
| | | }, |
| | | |
| | | // 新增:处理全选/全不选 |
| | | handleSelectAll(selection) { |
| | | this.isSelectAllProcessing = true; |
| | | |
| | | if (selection.length === 0) { |
| | | // 全不选:移除当前页所有数据 |
| | | this.donorchargeList.forEach(item => { |
| | | this.removeFromSelections(item); |
| | | }); |
| | | } else { |
| | | // 全选:添加当前页所有数据 |
| | | this.donorchargeList.forEach(item => { |
| | | this.addToSelections(item); |
| | | }); |
| | | } |
| | | |
| | | this.$nextTick(() => { |
| | | this.isSelectAllProcessing = false; |
| | | }); |
| | | }, |
| | | |
| | | // 新增:处理单个项目的选择/取消选择 |
| | | handleItemSelection(row, isSelected) { |
| | | if (isSelected) { |
| | | this.addToSelections(row); |
| | | } else { |
| | | this.removeFromSelections(row); |
| | | } |
| | | }, |
| | | |
| | | // 新增:添加到选中列表 |
| | | addToSelections(row) { |
| | | // 如果已经在多选数组中,不再添加 |
| | | if (this.multipleSelection.some(item => item.icdid === row.icdid)) { |
| | | return; |
| | | } |
| | | |
| | | this.multipleSelection.push(row); |
| | | |
| | | // 添加到总数组 |
| | | if (this.overallCase.every(item => item.icdid !== row.icdid)) { |
| | | this.overallCase.push({...row}); |
| | | } |
| | | }, |
| | | |
| | | // 新增:从选中列表移除 |
| | | removeFromSelections(row) { |
| | | const index = this.multipleSelection.findIndex(item => item.icdid === row.icdid); |
| | | if (index > -1) { |
| | | this.multipleSelection.splice(index, 1); |
| | | } |
| | | |
| | | // 从总数组中移除 |
| | | const overallIndex = this.overallCase.findIndex(item => item.icdid === row.icdid); |
| | | if (overallIndex > -1) { |
| | | this.overallCase.splice(overallIndex, 1); |
| | | } |
| | | }, |
| | | |
| | | // 保留原有的selection-change事件处理,但简化逻辑 |
| | | handleSelectionChange(selection) { |
| | | // 如果正在处理全选操作,不执行这里的逻辑 |
| | | if (this.isSelectAllProcessing) return; |
| | | |
| | | // 原有的复杂逻辑可以保留,但为了清晰,建议使用上面的新方法 |
| | | console.log('selection changed:', selection.length); |
| | | }, |
| | | |
| | | // 切换页后恢复选中 |
| | | Restorecheck() { |
| | | console.log(this.overallCase, "this.overallCase"); |
| | |
| | | AddDispatchpatients() { |
| | | this.$emit("addoption"); |
| | | }, |
| | | |
| | | // 新增:检查是否可以选择(可选,用于控制某些行不可选) |
| | | checkSelectable(row, index) { |
| | | return true; // 所有行都可选 |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | } |
| | | } |
| | | ::v-deep.el-table .el-table__header th:first-child .el-checkbox { |
| | | display: none; |
| | | display: inline-block; /* 修改这里,显示全选复选框 */ |
| | | } |
| | | .el-tag + .el-tag { |
| | | margin-left: 10px; |