|
259 | 259 | import VolTableRender from "./VolTable/VolTableRender"; |
260 | 260 | var $vue; |
261 | 261 | let _errMsg; |
262 | | -let selectRows = []; |
263 | 262 | import { defineComponent } from "vue"; |
264 | 263 | export default defineComponent({ |
265 | 264 | //https://github.com/element-plus/element-plus/issues/1483 |
@@ -457,6 +456,7 @@ export default defineComponent({ |
457 | 456 | remoteColumns: [], // 需要每次刷新或分页后从后台加载字典数据源的列配置 |
458 | 457 | cellStyleColumns: {}, // 有背景颜色的配置 |
459 | 458 | fxRight: false, //是否有右边固定表头 |
| 459 | + selectRows:[]//当前选中的行 |
460 | 460 | }; |
461 | 461 | }, |
462 | 462 | created() { |
@@ -551,8 +551,8 @@ export default defineComponent({ |
551 | 551 | }, |
552 | 552 | methods: { |
553 | 553 | watchRowSelectChange(newLen, oldLen) { |
554 | | - if (newLen < oldLen && selectRows.length) { |
555 | | - selectRows = []; |
| 554 | + if (newLen < oldLen && this.selectRows.length) { |
| 555 | + this.selectRows = []; |
556 | 556 | $vue.$refs.table.clearSelection(); |
557 | 557 | } |
558 | 558 | }, |
@@ -947,14 +947,14 @@ export default defineComponent({ |
947 | 947 | this.$props.linkView(row, column); |
948 | 948 | }, |
949 | 949 | getSelected() { |
950 | | - return selectRows; |
| 950 | + return this.selectRows; |
951 | 951 | }, |
952 | 952 | getSelectedIndex() { |
953 | 953 | if (!this.index) { |
954 | 954 | // 只有设置了属性index才有索引行 |
955 | 955 | return []; |
956 | 956 | } |
957 | | - let indexArr = selectRows.map((x) => { |
| 957 | + let indexArr = this.selectRows.map((x) => { |
958 | 958 | return x.elementIndex; |
959 | 959 | }); |
960 | 960 | return indexArr || []; |
@@ -1103,15 +1103,15 @@ export default defineComponent({ |
1103 | 1103 | selectionChange(selection) { |
1104 | 1104 | // console.log(selection); |
1105 | 1105 | // 选择行事件,只有单选才触发 |
1106 | | - selectRows = selection; |
| 1106 | + this.selectRows = selection; |
1107 | 1107 | if (this.single) { |
1108 | 1108 | if (selection.length == 1) { |
1109 | 1109 | this.$emit("rowChange", selection[0]); |
1110 | 1110 | } |
1111 | 1111 | if (selection.length > 1) { |
1112 | 1112 | let _row = selection[selection.length - 1]; |
1113 | 1113 | this.$refs.table.toggleRowSelection(selection[0]); |
1114 | | - selectRows = [_row]; |
| 1114 | + this.selectRows = [_row]; |
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | }, |
@@ -1257,7 +1257,7 @@ export default defineComponent({ |
1257 | 1257 | return column.edit.type == "date" ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm:ss"; |
1258 | 1258 | }, |
1259 | 1259 | userSelect(selection, row) { |
1260 | | - selectRows = selection; |
| 1260 | + this.selectRows = selection; |
1261 | 1261 | if (!this.single) { |
1262 | 1262 | this.$emit("rowChange", { row, selection }); |
1263 | 1263 | } |
|
0 commit comments