umy-ui-table 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/lib/button.js +1 -0
  4. package/lib/icon.js +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/locale/format.js +56 -0
  7. package/lib/locale/index.js +72 -0
  8. package/lib/locale/lang/en.js +123 -0
  9. package/lib/locale/lang/zh-CN.js +119 -0
  10. package/lib/mixins/locale.js +17 -0
  11. package/lib/theme-chalk/base.css +0 -0
  12. package/lib/theme-chalk/button.css +1 -0
  13. package/lib/theme-chalk/fonts/element-icons.ttf +0 -0
  14. package/lib/theme-chalk/fonts/element-icons.woff +0 -0
  15. package/lib/theme-chalk/fonts/iconfont.1785562768224.ttf +0 -0
  16. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff +0 -0
  17. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff2 +0 -0
  18. package/lib/theme-chalk/icon.css +1 -0
  19. package/lib/theme-chalk/index.css +1 -0
  20. package/lib/theme-chalk/u-table-column.css +0 -0
  21. package/lib/theme-chalk/u-table.css +1 -0
  22. package/lib/theme-chalk/ux-grid.css +1 -0
  23. package/lib/theme-chalk/ux-table-column.css +0 -0
  24. package/lib/u-table-column.js +1 -0
  25. package/lib/u-table.js +1 -0
  26. package/lib/umd/locale/en.js +139 -0
  27. package/lib/umd/locale/zh-CN.js +135 -0
  28. package/lib/umy-ui.common.js +1 -0
  29. package/lib/utils/svg.js +33 -0
  30. package/lib/utils/types.js +35 -0
  31. package/lib/utils/util.js +268 -0
  32. package/lib/ux-grid.js +1 -0
  33. package/lib/ux-table-column.js +1 -0
  34. package/package.json +117 -0
  35. package/packages/button/index.js +7 -0
  36. package/packages/button/src/button-group.vue +10 -0
  37. package/packages/button/src/button.vue +166 -0
  38. package/packages/checkbox/index.js +8 -0
  39. package/packages/checkbox/src/checkbox-button.vue +199 -0
  40. package/packages/checkbox/src/checkbox-group.vue +48 -0
  41. package/packages/checkbox/src/checkbox.vue +222 -0
  42. package/packages/checkbox-button/index.js +8 -0
  43. package/packages/checkbox-group/index.js +8 -0
  44. package/packages/icon/index.js +7 -0
  45. package/packages/icon/src/icon.vue +40 -0
  46. package/packages/input/index.js +2 -0
  47. package/packages/input/src/calcTextareaHeight.js +104 -0
  48. package/packages/input/src/input.vue +424 -0
  49. package/packages/option/index.js +2 -0
  50. package/packages/pagination/index.js +2 -0
  51. package/packages/pagination/src/pager.vue +163 -0
  52. package/packages/pagination/src/pagination.js +386 -0
  53. package/packages/scrollbar/index.js +8 -0
  54. package/packages/scrollbar/src/bar.js +92 -0
  55. package/packages/scrollbar/src/main.js +130 -0
  56. package/packages/scrollbar/src/util.js +34 -0
  57. package/packages/select/index.js +2 -0
  58. package/packages/select/src/navigation-mixin.js +54 -0
  59. package/packages/select/src/option-group.vue +60 -0
  60. package/packages/select/src/option.vue +163 -0
  61. package/packages/select/src/select-dropdown.vue +74 -0
  62. package/packages/select/src/select.vue +889 -0
  63. package/packages/table/index.js +8 -0
  64. package/packages/table/src/config.js +123 -0
  65. package/packages/table/src/dropdown.js +28 -0
  66. package/packages/table/src/filter-panel.vue +194 -0
  67. package/packages/table/src/layout-observer.js +68 -0
  68. package/packages/table/src/store/current.js +71 -0
  69. package/packages/table/src/store/expand.js +65 -0
  70. package/packages/table/src/store/helper.js +37 -0
  71. package/packages/table/src/store/index.js +145 -0
  72. package/packages/table/src/store/tree.js +208 -0
  73. package/packages/table/src/store/watcher.js +448 -0
  74. package/packages/table/src/table-body.js +493 -0
  75. package/packages/table/src/table-column.js +381 -0
  76. package/packages/table/src/table-footer.js +174 -0
  77. package/packages/table/src/table-header.js +537 -0
  78. package/packages/table/src/table-layout.js +231 -0
  79. package/packages/table/src/table.vue +741 -0
  80. package/packages/table/src/util.js +256 -0
  81. package/packages/tag/index.js +8 -0
  82. package/packages/tag/src/tag.vue +58 -0
  83. package/packages/tools/directives/mousewheel.js +18 -0
  84. package/packages/tools/directives/repeat-click.js +24 -0
  85. package/packages/tools/locale/format.js +46 -0
  86. package/packages/tools/locale/index.js +48 -0
  87. package/packages/tools/locale/lang/en.js +120 -0
  88. package/packages/tools/locale/lang/zh-CN.js +116 -0
  89. package/packages/tools/mixins/emitter.js +33 -0
  90. package/packages/tools/mixins/focus.js +9 -0
  91. package/packages/tools/mixins/locale.js +9 -0
  92. package/packages/tools/mixins/migrating.js +54 -0
  93. package/packages/tools/transitions/collapse-transition.js +77 -0
  94. package/packages/tools/utils/after-leave.js +27 -0
  95. package/packages/tools/utils/aria-dialog.js +90 -0
  96. package/packages/tools/utils/aria-utils.js +122 -0
  97. package/packages/tools/utils/clickoutside.js +76 -0
  98. package/packages/tools/utils/date-util.js +292 -0
  99. package/packages/tools/utils/date.js +368 -0
  100. package/packages/tools/utils/dom.js +227 -0
  101. package/packages/tools/utils/menu/aria-menubar.js +14 -0
  102. package/packages/tools/utils/menu/aria-menuitem.js +49 -0
  103. package/packages/tools/utils/menu/aria-submenu.js +59 -0
  104. package/packages/tools/utils/merge.js +15 -0
  105. package/packages/tools/utils/popper.js +1276 -0
  106. package/packages/tools/utils/popup/index.js +218 -0
  107. package/packages/tools/utils/popup/popup-manager.js +194 -0
  108. package/packages/tools/utils/resize-event.js +35 -0
  109. package/packages/tools/utils/scroll-into-view.js +27 -0
  110. package/packages/tools/utils/scrollbar-width.js +29 -0
  111. package/packages/tools/utils/shared.js +7 -0
  112. package/packages/tools/utils/svg.js +1 -0
  113. package/packages/tools/utils/types.js +28 -0
  114. package/packages/tools/utils/util.js +241 -0
  115. package/packages/tools/utils/vdom.js +5 -0
  116. package/packages/tools/utils/vue-popper.js +198 -0
  117. package/packages/tooltip/index.js +8 -0
  118. package/packages/tooltip/src/main.js +241 -0
  119. package/packages/u-table/index.js +4 -0
  120. package/packages/u-table/revise-el-table-mixins/index.js +10 -0
  121. package/packages/u-table/revise-el-table-mixins/table-extend.js +60 -0
  122. package/packages/u-table/revise-el-table-mixins/table.mixins.js +261 -0
  123. package/packages/u-table/revise-el-table-mixins/virtual-table-body-render.js +132 -0
  124. package/packages/u-table/src/u-table.vue +248 -0
  125. package/packages/u-table/u-table-mixins/index.js +483 -0
  126. package/packages/u-table/u-table-tree-mixins/methods.js +120 -0
  127. package/packages/u-table/u-table-tree-mixins/u-table-tree-mixins.js +161 -0
  128. package/packages/u-table-column/index.js +8 -0
  129. package/packages/utils/common.js +27 -0
  130. package/packages/ux-grid/index.js +6 -0
  131. package/packages/ux-grid/mixins/index.js +707 -0
  132. package/packages/ux-grid/src/interceptor.js +6 -0
  133. package/packages/ux-grid/src/ux-grid.vue +301 -0
  134. package/packages/ux-table-column/index.js +10 -0
  135. package/tools/locale/format.js +46 -0
  136. package/tools/locale/index.js +54 -0
  137. package/tools/locale/lang/en.js +120 -0
  138. package/tools/locale/lang/zh-CN.js +116 -0
  139. package/tools/mixins/locale.js +9 -0
  140. package/tools/utils/svg.js +1 -0
  141. package/tools/utils/types.js +28 -0
  142. package/tools/utils/util.js +241 -0
@@ -0,0 +1,448 @@
1
+ import Vue from 'vue';
2
+ import debounce from 'throttle-debounce/debounce';
3
+ import merge from '../../../tools/utils/merge';
4
+ import { getKeysMap, getRowIdentity, getColumnById, getColumnByKey, orderBy, toggleRowStatus } from '../util';
5
+ import expand from './expand';
6
+ import current from './current';
7
+ import tree from './tree';
8
+ import {isArrayFn} from "../../../utils/common";
9
+
10
+ const sortData = (data, states) => {
11
+ const sortingColumn = states.sortingColumn;
12
+ if (!sortingColumn || typeof sortingColumn.sortable === 'string') {
13
+ return data;
14
+ }
15
+ return orderBy(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy);
16
+ };
17
+
18
+ const doFlattenColumns = (columns) => {
19
+ const result = [];
20
+ columns.forEach((column) => {
21
+ if (column.children) {
22
+ result.push.apply(result, doFlattenColumns(column.children));
23
+ } else {
24
+ result.push(column);
25
+ }
26
+ });
27
+ return result;
28
+ };
29
+
30
+ export default Vue.extend({
31
+ data() {
32
+ return {
33
+ states: {
34
+ // 3.0 版本后要求必须设置该属性
35
+ rowKey: null,
36
+
37
+ // 渲染的数据来源,是对 table 中的 data 过滤排序后的结果
38
+ data: [],
39
+
40
+ // 是否包含固定列
41
+ isComplex: false,
42
+
43
+ // 列
44
+ _columns: [], // 不可响应的
45
+ originColumns: [],
46
+ columns: [],
47
+ fixedColumns: [],
48
+ rightFixedColumns: [],
49
+ leafColumns: [],
50
+ fixedLeafColumns: [],
51
+ rightFixedLeafColumns: [],
52
+ leafColumnsLength: 0,
53
+ fixedLeafColumnsLength: 0,
54
+ rightFixedLeafColumnsLength: 0,
55
+
56
+ // 选择
57
+ isAllSelected: false,
58
+ selection: [],
59
+ reserveSelection: false,
60
+ selectOnIndeterminate: false,
61
+ selectable: null,
62
+
63
+ // 过滤
64
+ filters: {}, // 不可响应的
65
+ filteredData: null,
66
+
67
+ // 排序
68
+ sortingColumn: null,
69
+ sortProp: null,
70
+ sortOrder: null,
71
+
72
+ hoverRow: null,
73
+
74
+ // 修改源码
75
+ useVirtual: false, // 加入是否为渲染大数据模式
76
+ bigDataCheckbox: false, // 大数据下是否更改全选框,单选框卡顿问题
77
+ }
78
+ };
79
+ },
80
+
81
+ mixins: [expand, current, tree],
82
+
83
+ methods: {
84
+ // 检查 rowKey 是否存在
85
+ assertRowKey() {
86
+ const rowKey = this.states.rowKey;
87
+ if (!rowKey) throw new Error('[ElTable] prop row-key is required');
88
+ },
89
+
90
+ // 更新列
91
+ updateColumns() {
92
+ const states = this.states;
93
+ const _columns = states._columns || [];
94
+ states.fixedColumns = _columns.filter((column) => column.fixed === true || column.fixed === 'left');
95
+ states.rightFixedColumns = _columns.filter((column) => column.fixed === 'right');
96
+
97
+ if (states.fixedColumns.length > 0 && _columns[0] && _columns[0].type === 'selection' && !_columns[0].fixed) {
98
+ _columns[0].fixed = true;
99
+ states.fixedColumns.unshift(_columns[0]);
100
+ }
101
+
102
+ const notFixedColumns = _columns.filter(column => !column.fixed);
103
+ states.originColumns = [].concat(states.fixedColumns).concat(notFixedColumns).concat(states.rightFixedColumns);
104
+
105
+ const leafColumns = doFlattenColumns(notFixedColumns);
106
+ const fixedLeafColumns = doFlattenColumns(states.fixedColumns);
107
+ const rightFixedLeafColumns = doFlattenColumns(states.rightFixedColumns);
108
+
109
+ states.leafColumnsLength = leafColumns.length;
110
+ states.fixedLeafColumnsLength = fixedLeafColumns.length;
111
+ states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
112
+
113
+ states.columns = [].concat(fixedLeafColumns).concat(leafColumns).concat(rightFixedLeafColumns);
114
+ states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
115
+ },
116
+
117
+ // 更新 DOM
118
+ scheduleLayout(needUpdateColumns) {
119
+ if (needUpdateColumns) {
120
+ this.updateColumns();
121
+ }
122
+ this.table.debouncedUpdateLayout();
123
+ },
124
+
125
+ // 选择
126
+ isSelected(row) {
127
+ const { selection = [] } = this.states;
128
+ return selection.indexOf(row) > -1;
129
+ },
130
+
131
+ clearSelection() {
132
+ const states = this.states;
133
+ states.isAllSelected = false;
134
+ const oldSelection = states.selection;
135
+ if (oldSelection.length) {
136
+ states.selection = [];
137
+ this.table.$emit('selection-change', []);
138
+ }
139
+ },
140
+
141
+ cleanSelection() {
142
+ const states = this.states;
143
+ const { data, rowKey, selection } = states;
144
+ let deleted;
145
+ if (rowKey) {
146
+ deleted = [];
147
+ const selectedMap = getKeysMap(selection, rowKey);
148
+ const dataMap = getKeysMap(data, rowKey);
149
+ for (let key in selectedMap) {
150
+ if (selectedMap.hasOwnProperty(key) && !dataMap[key]) {
151
+ deleted.push(selectedMap[key].row);
152
+ }
153
+ }
154
+ } else {
155
+ deleted = selection.filter(item => data.indexOf(item) === -1);
156
+ }
157
+ if (deleted.length) {
158
+ const newSelection = selection.filter(item => deleted.indexOf(item) === -1);
159
+ states.selection = newSelection;
160
+ this.table.$emit('selection-change', newSelection.slice());
161
+ }
162
+ },
163
+
164
+ toggleRowSelection(row, selected, emitChange = true) {
165
+ const changed = toggleRowStatus(this.states.selection, row, selected);
166
+ if (changed) {
167
+ const newSelection = (this.states.selection || []).slice();
168
+ // 调用 API 修改选中值,不触发 select 事件
169
+ if (emitChange) {
170
+ this.table.$emit('select', newSelection, row);
171
+ }
172
+ this.table.$emit('selection-change', newSelection);
173
+ }
174
+ },
175
+ removalDataObj (arr, key) {
176
+ if (isArrayFn(arr)) {
177
+ let result = [];
178
+ let obj = {};
179
+ for(let i =0; i<arr.length; i++){
180
+ if(!obj[arr[i][key]]){
181
+ result.push(arr[i]);
182
+ obj[arr[i][key]] = true;
183
+ }
184
+ }
185
+ return result
186
+ } else {
187
+ throw new Error('需要的是数组');
188
+ }
189
+ },
190
+ // 修改源码,选中大量数据
191
+ partRowSelections (datas, flas) {
192
+ const states = this.states;
193
+ const { rowKey } = states;
194
+ if (flas) {
195
+ // 返回值用来决定这一行的 CheckBox 是否可以勾选
196
+ if (states.selectable) {
197
+ // 找出不是禁用的行,然后全选上直接复制给selection,避开循环赋值
198
+ let newData = datas.filter((items,indexs) => states.selectable.call(null, items, indexs))
199
+ states.selection = this.removalDataObj([...newData, ...states.selection], rowKey)
200
+ } else {
201
+ states.selection = this.removalDataObj([...datas, ...states.selection], rowKey)
202
+ }
203
+ } else {
204
+ if (states.selectable) {
205
+ // 找出不是禁用的行,然后全选上直接复制给selection,避开循环赋值
206
+ let newData = datas.filter((items,indexs) => states.selectable.call(null, items, indexs))
207
+ // 从一个数组中删除另一个数组中存在的元素
208
+ // 从数组arr中删除数组to_remove中存在的元素
209
+ states.selection = states.selection.filter((x) => !newData.some((item) => x[rowKey] === item[rowKey]));
210
+ } else {
211
+ states.selection = states.selection.filter((x) => !datas.some((item) => x[rowKey] === item[rowKey]));
212
+ }
213
+ }
214
+ this.table.$emit('selection-change', states.selection ? states.selection.slice() : []);
215
+ },
216
+
217
+ toggleAllSelection: debounce(10, function() {
218
+ const states = this.states;
219
+ const { data = [], selection } = states;
220
+ // when only some rows are selected (but not all), select or deselect all of them
221
+ // depending on the value of selectOnIndeterminate
222
+ const value = states.selectOnIndeterminate
223
+ ? !states.isAllSelected
224
+ : !(states.isAllSelected || selection.length);
225
+ states.isAllSelected = value;
226
+
227
+ let selectionChanged = false;
228
+ // 修改源码 大数据情况下进行全选操作
229
+ if (this.states.useVirtual && this.states.bigDataCheckbox) {
230
+ // 全选
231
+ if (value) {
232
+ // 返回值用来决定这一行的 CheckBox 是否可以勾选
233
+ if (states.selectable) {
234
+ // 找出不是禁用的行,然后全选上直接复制给selection,避开循环赋值
235
+ states.selection = data.filter((item, index) => states.selectable.call(null, item, index))
236
+ } else {
237
+ states.selection = data.filter(item=> item)
238
+ }
239
+ } else {
240
+ // 取消全选
241
+ states.selection = []
242
+ }
243
+ this.table.$emit('selection-change', states.selection ? states.selection.slice() : []);
244
+ this.table.$emit('select-all', states.selection);
245
+ } else {
246
+ // ele源码 大数据全选卡的关键地方
247
+ data.forEach((row, index) => {
248
+ if (states.selectable) {
249
+ // 如果当前列禁用就不需要去加入到选中项 states.selectable.call(null, row, index)
250
+ if (states.selectable.call(null, row, index) && toggleRowStatus(selection, row, value)) {
251
+ selectionChanged = true;
252
+ }
253
+ } else {
254
+ if (toggleRowStatus(selection, row, value)) {
255
+ selectionChanged = true;
256
+ }
257
+ }
258
+ });
259
+ if (selectionChanged) {
260
+ this.table.$emit('selection-change', selection ? selection.slice() : []);
261
+ }
262
+ this.table.$emit('select-all', selection);
263
+ }
264
+ }),
265
+
266
+ updateSelectionByRowKey() {
267
+ const states = this.states;
268
+ const { selection, rowKey, data } = states;
269
+ const selectedMap = getKeysMap(selection, rowKey);
270
+ data.forEach(row => {
271
+ const rowId = getRowIdentity(row, rowKey);
272
+ const rowInfo = selectedMap[rowId];
273
+ if (rowInfo) {
274
+ selection[rowInfo.index] = row;
275
+ }
276
+ });
277
+ },
278
+
279
+ updateAllSelected() {
280
+ const states = this.states;
281
+ const { selection, rowKey, selectable } = states;
282
+ // data 为 null 时,结构时的默认值会被忽略
283
+ const data = states.data || [];
284
+ if (data.length === 0) {
285
+ states.isAllSelected = false;
286
+ return;
287
+ }
288
+
289
+ let selectedMap;
290
+ if (rowKey) {
291
+ selectedMap = getKeysMap(selection, rowKey);
292
+ }
293
+ const isSelected = function(row) {
294
+ if (selectedMap) {
295
+ return !!selectedMap[getRowIdentity(row, rowKey)];
296
+ } else {
297
+ return selection.indexOf(row) !== -1;
298
+ }
299
+ };
300
+ let isAllSelected = true;
301
+ let selectedCount = 0;
302
+ for (let i = 0, j = data.length; i < j; i++) {
303
+ const item = data[i];
304
+ const isRowSelectable = selectable && selectable.call(null, item, i);
305
+ if (!isSelected(item)) {
306
+ if (!selectable || isRowSelectable) {
307
+ isAllSelected = false;
308
+ break;
309
+ }
310
+ } else {
311
+ selectedCount++;
312
+ }
313
+ }
314
+
315
+ if (selectedCount === 0) isAllSelected = false;
316
+ states.isAllSelected = isAllSelected;
317
+ },
318
+
319
+ // 过滤与排序
320
+ updateFilters(columns, values) {
321
+ if (!Array.isArray(columns)) {
322
+ columns = [columns];
323
+ }
324
+ const states = this.states;
325
+ const filters = {};
326
+ columns.forEach(col => {
327
+ states.filters[col.id] = values;
328
+ filters[col.columnKey || col.id] = values;
329
+ });
330
+
331
+ return filters;
332
+ },
333
+
334
+ updateSort(column, prop, order) {
335
+ if (this.states.sortingColumn && this.states.sortingColumn !== column) {
336
+ this.states.sortingColumn.order = null;
337
+ }
338
+ this.states.sortingColumn = column;
339
+ this.states.sortProp = prop;
340
+ this.states.sortOrder = order;
341
+ },
342
+
343
+ execFilter() {
344
+ const states = this.states;
345
+ const { _data, filters } = states;
346
+ let data = _data;
347
+
348
+ Object.keys(filters).forEach((columnId) => {
349
+ const values = states.filters[columnId];
350
+ if (!values || values.length === 0) return;
351
+ const column = getColumnById(this.states, columnId);
352
+ if (column && column.filterMethod) {
353
+ data = data.filter((row) => {
354
+ return values.some(value => column.filterMethod.call(null, value, row, column));
355
+ });
356
+ }
357
+ });
358
+
359
+ states.filteredData = data;
360
+ },
361
+
362
+ execSort() {
363
+ const states = this.states;
364
+ states.data = sortData(states.filteredData, states);
365
+ },
366
+
367
+ // 根据 filters 与 sort 去过滤 data
368
+ execQuery(ignore) {
369
+ if (!(ignore && ignore.filter)) {
370
+ this.execFilter();
371
+ }
372
+ this.execSort();
373
+ },
374
+
375
+ clearFilter(columnKeys) {
376
+ const states = this.states;
377
+ const { tableHeader, fixedTableHeader, rightFixedTableHeader } = this.table.$refs;
378
+
379
+ let panels = {};
380
+ if (tableHeader) panels = merge(panels, tableHeader.filterPanels);
381
+ if (fixedTableHeader) panels = merge(panels, fixedTableHeader.filterPanels);
382
+ if (rightFixedTableHeader) panels = merge(panels, rightFixedTableHeader.filterPanels);
383
+
384
+ const keys = Object.keys(panels);
385
+ if (!keys.length) return;
386
+
387
+ if (typeof columnKeys === 'string') {
388
+ columnKeys = [columnKeys];
389
+ }
390
+
391
+ if (Array.isArray(columnKeys)) {
392
+ const columns = columnKeys.map(key => getColumnByKey(states, key));
393
+ keys.forEach(key => {
394
+ const column = columns.find(col => col.id === key);
395
+ if (column) {
396
+ // TODO: 优化这里的代码
397
+ panels[key].filteredValue = [];
398
+ }
399
+ });
400
+ this.commit('filterChange', {
401
+ column: columns,
402
+ values: [],
403
+ silent: true,
404
+ multi: true
405
+ });
406
+ } else {
407
+ keys.forEach(key => {
408
+ // TODO: 优化这里的代码
409
+ panels[key].filteredValue = [];
410
+ });
411
+
412
+ states.filters = {};
413
+ this.commit('filterChange', {
414
+ column: {},
415
+ values: [],
416
+ silent: true
417
+ });
418
+ }
419
+ },
420
+
421
+ clearSort() {
422
+ const states = this.states;
423
+ if (!states.sortingColumn) return;
424
+
425
+ this.updateSort(null, null, null);
426
+ this.commit('changeSortCondition', {
427
+ silent: true
428
+ });
429
+ },
430
+
431
+ // 适配层,expand-row-keys 在 Expand 与 TreeTable 中都有使用
432
+ setExpandRowKeysAdapter(val) {
433
+ // 这里会触发额外的计算,但为了兼容性,暂时这么做
434
+ this.setExpandRowKeys(val);
435
+ this.updateTreeExpandKeys(val);
436
+ },
437
+
438
+ // 展开行与 TreeTable 都要使用
439
+ toggleRowExpansionAdapter(row, expanded) {
440
+ const hasExpandColumn = this.states.columns.some(({ type }) => type === 'expand');
441
+ if (hasExpandColumn) {
442
+ this.toggleRowExpansion(row, expanded);
443
+ } else {
444
+ this.toggleTreeExpansion(row, expanded);
445
+ }
446
+ }
447
+ }
448
+ });