@kyfe/ks-query-table 0.0.2 → 0.0.3
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.
- package/index.js +35386 -7
- package/package.json +7 -5
- package/query-table.common.js.map +1 -0
- package/query-table.css +1 -0
- package/query-table.umd.js +35396 -0
- package/query-table.umd.js.map +1 -0
- package/query-table.umd.min.js +11 -0
- package/query-table.umd.min.js.map +1 -0
- package/README.md +0 -45
- package/api/index.js +0 -12
- package/assets/horizontal-back.svg +0 -1
- package/components/pe-table/cell.js +0 -184
- package/components/pe-table/collapse.js +0 -334
- package/components/pe-table/empty.vue +0 -48
- package/components/pe-table/header.js +0 -328
- package/components/pe-table/images/abnormal.png +0 -0
- package/components/pe-table/images/empty.png +0 -0
- package/components/pe-table/images/fold.svg +0 -1
- package/components/pe-table/images/sort.svg +0 -1
- package/components/pe-table/images/sorting.svg +0 -1
- package/components/pe-table/images/unfold.svg +0 -1
- package/components/pe-table/index.vue +0 -837
- package/components/pe-table/load-more.js +0 -46
- package/components/pe-table/props/index.js +0 -183
- package/components/pe-table/row.vue +0 -118
- package/components/pe-table/scrollbar.js +0 -424
- package/components/pe-table/stretch-damping.js +0 -112
- package/components/pe-table/style/cell.less +0 -89
- package/components/pe-table/style/empty.less +0 -48
- package/components/pe-table/style/header.less +0 -141
- package/components/pe-table/style/index.less +0 -88
- package/components/pe-table/style/load-more.less +0 -61
- package/components/pe-table/style/row.less +0 -6
- package/components/pe-table/table-loading.vue +0 -119
- package/components/pe-table/table-total.vue +0 -53
- package/components/pe-table/utils/animate.js +0 -80
- package/components/pe-table/utils/columns.js +0 -290
- package/components/pe-table/utils/data.js +0 -12
- package/components/pe-table/utils/fixed.js +0 -69
- package/components/pe-table/utils/formatter.js +0 -327
- package/components/pe-table/utils/render-cells.js +0 -424
- package/components/pe-table/utils/slot.js +0 -28
- package/components/pe-table/utils/tools.js +0 -84
- package/components/pe-table/utils/touch-scroll.js +0 -417
- package/components/query-table/index.vue +0 -492
- package/components/query-table/mixins/column-mixin.js +0 -102
- package/components/query-table/mixins/column-setting.js +0 -143
- package/components/query-table/mixins/data-mixin.js +0 -502
- package/components/query-table/mixins/pagination-mixin.js +0 -25
- package/components/query-table/mixins/table-fixed.js +0 -111
- package/components/query-table/mixins/table-horizontal.js +0 -119
- package/components/table-horizontal.vue +0 -99
- package/components/table-pagination.vue +0 -32
- package/components/table-settings/assets/arrpw-up.svg +0 -1
- package/components/table-settings/assets/disabled-down.svg +0 -1
- package/components/table-settings/assets/disabled-up.svg +0 -1
- package/components/table-settings/assets/down.svg +0 -1
- package/components/table-settings/assets/up.svg +0 -1
- package/components/table-settings/index.less +0 -294
- package/components/table-settings/index.vue +0 -260
- package/components/table-settings/settings.vue +0 -479
- package/components/table-settings/test.js +0 -626
- package/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
- package/components/tooltip.js +0 -124
- package/hooks/use-cache-promise.js +0 -27
- package/hooks/use-column-config.js +0 -186
- package/hooks/use-encryption.js +0 -0
- package/hooks/use-generic-search.js +0 -95
- package/store/column-store.js +0 -0
- package/styles/table.less +0 -24
- package/utils/column.js +0 -36
- package/utils/config.js +0 -12
- package/utils/encryption.js +0 -32
- package/utils/http.js +0 -1
- package/utils/localStorage.js +0 -35
|
@@ -1,837 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="pe-table-wrap"
|
|
3
|
-
ref="root"
|
|
4
|
-
:style="rootStyle"
|
|
5
|
-
:class="rootClassName">
|
|
6
|
-
<div ref="container"
|
|
7
|
-
class="pe-table-container">
|
|
8
|
-
<div ref="trackX"
|
|
9
|
-
class="pe-table-scrollbar_horizontal-track"
|
|
10
|
-
:style="state.trackXStyle">
|
|
11
|
-
<div ref="thumbX"
|
|
12
|
-
class="pe-table-scrollbar_horizontal-thumb"
|
|
13
|
-
:class="scrollbarClass" />
|
|
14
|
-
</div>
|
|
15
|
-
<div ref="trackY"
|
|
16
|
-
class="pe-table-scrollbar_vertical-track"
|
|
17
|
-
:style="state.trackYStyle">
|
|
18
|
-
<div ref="thumbY"
|
|
19
|
-
class="pe-table-scrollbar_vertical-thumb"
|
|
20
|
-
:class="scrollbarClass" />
|
|
21
|
-
</div>
|
|
22
|
-
<Empty v-if="isEmpty"
|
|
23
|
-
:isAbnormal="isAbnormal"
|
|
24
|
-
:headerTotalHeight="headerTotalHeight"
|
|
25
|
-
:emptyText="emptyText"
|
|
26
|
-
@abnormal="abnormal"></Empty>
|
|
27
|
-
<TableLoading v-if="isLoading"
|
|
28
|
-
:delayLoading="delayLoading"
|
|
29
|
-
:headerTotalHeight="headerTotalHeight" />
|
|
30
|
-
<TableTotal v-if="isScrollShowTotal"
|
|
31
|
-
:show="isShowTotal"
|
|
32
|
-
:endRow="state.showEndRow"
|
|
33
|
-
:total="total || curMaxIndexVal" />
|
|
34
|
-
<div ref="loadMroe"
|
|
35
|
-
class="load-more"
|
|
36
|
-
v-if="!isEmpty && !isLoading && isHasOffsetY">
|
|
37
|
-
<LoadMore :isLoadFinished="isLoadFinished"
|
|
38
|
-
:loadOptions="loadOptions">
|
|
39
|
-
<slot name="loadMroe"></slot>
|
|
40
|
-
</LoadMore>
|
|
41
|
-
</div>
|
|
42
|
-
<div class="pe-table-resize_line"
|
|
43
|
-
style="display: none;">
|
|
44
|
-
<div class="pe-table-resize_line-thumb"></div>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</div>
|
|
48
|
-
</template>
|
|
49
|
-
|
|
50
|
-
<script>
|
|
51
|
-
// import Vue from 'vue'
|
|
52
|
-
const Vue = window.Vue // 在此项目中,Vue使用的是public下的运行时的vue.reuntime.min.js。所以此时需要保持一致
|
|
53
|
-
import debounce from 'lodash/debounce'
|
|
54
|
-
import throttle from 'lodash/throttle'
|
|
55
|
-
import CollapseMixin from './collapse.js'
|
|
56
|
-
import Empty from './empty.vue'
|
|
57
|
-
import LoadMore from './load-more'
|
|
58
|
-
import { PE_TABLE_PROPS } from './props/index.js'
|
|
59
|
-
import Row from './row.vue'
|
|
60
|
-
import ScrollbarMixin from './scrollbar.js'
|
|
61
|
-
import TableLoading from './table-loading.vue'
|
|
62
|
-
import TableTotal from './table-total.vue'
|
|
63
|
-
import { createColumns, createFlatColumns, createRenderColumnOption } from './utils/columns.js'
|
|
64
|
-
import { createTableData } from './utils/data'
|
|
65
|
-
import { getRenderRange } from './utils/tools.js'
|
|
66
|
-
import { TouchScrolling } from './utils/touch-scroll.js'
|
|
67
|
-
const RowConstructor = Vue.extend(Row)
|
|
68
|
-
|
|
69
|
-
export default {
|
|
70
|
-
name: 'PeTable',
|
|
71
|
-
mixins: [ScrollbarMixin, CollapseMixin],
|
|
72
|
-
props: PE_TABLE_PROPS,
|
|
73
|
-
components: {
|
|
74
|
-
Empty,
|
|
75
|
-
LoadMore,
|
|
76
|
-
TableLoading,
|
|
77
|
-
TableTotal,
|
|
78
|
-
},
|
|
79
|
-
computed: {
|
|
80
|
-
headerTotalHeight() {
|
|
81
|
-
return this.maxLevel * this.$props.headerRowHeight
|
|
82
|
-
},
|
|
83
|
-
scrollbarClass() {
|
|
84
|
-
if (this.$props.autoHideScrollbars) {
|
|
85
|
-
return [this.isScrolling ? 'visible' : 'hidden']
|
|
86
|
-
} else {
|
|
87
|
-
return ['visible']
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
rootStyle() {
|
|
91
|
-
return {
|
|
92
|
-
'--peHScrollbarSize': this.$props.hScrollbarSize + 'PX',
|
|
93
|
-
'--peVScrollbarSize': this.$props.vScrollbarSize + 'PX',
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
isEmpty() {
|
|
97
|
-
if (!Array.isArray(this.data)) return true
|
|
98
|
-
return !this.data.length && !this.isLoading
|
|
99
|
-
},
|
|
100
|
-
rootClassName() {
|
|
101
|
-
return {
|
|
102
|
-
'pe-table-scrolling__x': this.offsetX,
|
|
103
|
-
'pe-table-show-index': this.$props.showIndex,
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
isHasOffsetY() {
|
|
107
|
-
return this.offsetY > 0
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
// 数据必须存在唯一值 默认为id.否则渲染出现问题。。。不存在就生成 默认使用索引值
|
|
111
|
-
watch: {
|
|
112
|
-
width() {
|
|
113
|
-
this.changeSize()
|
|
114
|
-
},
|
|
115
|
-
height() {
|
|
116
|
-
this.changeSize()
|
|
117
|
-
},
|
|
118
|
-
scrollX(val) {
|
|
119
|
-
this.touchScroll.setScroll('unScrollX', !val)
|
|
120
|
-
},
|
|
121
|
-
scrollY(val) {
|
|
122
|
-
this.touchScroll.setScroll('unScrollY', !val)
|
|
123
|
-
},
|
|
124
|
-
isShowHorizontal(val) {
|
|
125
|
-
this.touchScroll.setScroll('isShowHorizontal', val)
|
|
126
|
-
},
|
|
127
|
-
columns: {
|
|
128
|
-
immediate: true,
|
|
129
|
-
deep: true,
|
|
130
|
-
handler() {
|
|
131
|
-
this.flatColumns()
|
|
132
|
-
this.updateColumns()
|
|
133
|
-
this.updateTableData()
|
|
134
|
-
this.$nextTick(() => {
|
|
135
|
-
this.createHeader()
|
|
136
|
-
this.renderViewportCells()
|
|
137
|
-
if (this.isUpdateOffset) {
|
|
138
|
-
this.scrollToLeft()
|
|
139
|
-
this.scrollToTop()
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
data: {
|
|
145
|
-
handler() {
|
|
146
|
-
this.updateRender()
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
headerTotalHeight() {
|
|
150
|
-
this.$nextTick(() => {
|
|
151
|
-
this.refreshThumb()
|
|
152
|
-
})
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
data() {
|
|
156
|
-
this.rowComponentMap = {}
|
|
157
|
-
return {
|
|
158
|
-
state: {
|
|
159
|
-
endRow: 0, // 可视区域内渲染的结束行
|
|
160
|
-
startRow: 0, // 可视区域的开始行
|
|
161
|
-
showEndRow: 0, // 用户可见的最后一行
|
|
162
|
-
rowOffset: 0, // 偏移量
|
|
163
|
-
|
|
164
|
-
startCell: 0, // 可视区域的开始单元格
|
|
165
|
-
endCell: 0, // 可是区域内的结束单元格
|
|
166
|
-
|
|
167
|
-
scrollableHeight: 0, // 纵向滚动条高度
|
|
168
|
-
tableHeight: 0, // 表格高度
|
|
169
|
-
thumbOffsetY: 0, // 纵向滚动条偏移值
|
|
170
|
-
thumbSizeY: 0,
|
|
171
|
-
trackYStyle: {
|
|
172
|
-
// 纵向滚动条的样式
|
|
173
|
-
right: 0,
|
|
174
|
-
opacity: 1,
|
|
175
|
-
},
|
|
176
|
-
trackXStyle: {
|
|
177
|
-
opacity: 1,
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
scrollableWidth: 0, // 横向滚动条宽度
|
|
181
|
-
tableWidth: 0, // 表格宽度
|
|
182
|
-
thumbOffsetX: 0,
|
|
183
|
-
thumbSizeX: 0,
|
|
184
|
-
|
|
185
|
-
rowsPerViewport: 0, // 缓冲区的行
|
|
186
|
-
},
|
|
187
|
-
viewportWidth: window.innerWidth, // 可视区域宽度
|
|
188
|
-
// 可视区域高度
|
|
189
|
-
viewportHeight: window.innerHeight - this.$props.columns.length * this.$props.rowHeight,
|
|
190
|
-
offsetY: 0, // 纵向偏移值
|
|
191
|
-
offsetX: 0, // 水平偏移值
|
|
192
|
-
// windowHeight: window.innerHeight, //
|
|
193
|
-
// windowWidth: window.innerWidth,
|
|
194
|
-
mainColumns: [], // 所有列配置,包含左侧固定列
|
|
195
|
-
renderCellsColumns: [], // 表体单元格渲染的列集合
|
|
196
|
-
maxLevel: 1, // 最大层级,存在多级表头时则是children的递归集合
|
|
197
|
-
tableData: [], // 表格数据,仅存在渲染的列的数据
|
|
198
|
-
|
|
199
|
-
// 排序相关参数
|
|
200
|
-
sortMap: {
|
|
201
|
-
order: undefined, // 排序方式
|
|
202
|
-
key: undefined, // 排序的列的key
|
|
203
|
-
column: undefined, // 排序的列
|
|
204
|
-
},
|
|
205
|
-
collapsedMap: {},
|
|
206
|
-
visibility: true,
|
|
207
|
-
activate: false,
|
|
208
|
-
loadMoreHeight: 0,
|
|
209
|
-
isShowTotal: false,
|
|
210
|
-
timerMore: null,
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
mounted() {
|
|
214
|
-
this.init()
|
|
215
|
-
},
|
|
216
|
-
beforeDestroy() {
|
|
217
|
-
if (this.resizeObserver) {
|
|
218
|
-
this.resizeObserver.disconnect()
|
|
219
|
-
this.resizeObserver = null
|
|
220
|
-
}
|
|
221
|
-
// window.removeEventListener('resize', this.throttleHandleResize)
|
|
222
|
-
},
|
|
223
|
-
activated() {
|
|
224
|
-
/*
|
|
225
|
-
释放掉,存在一个页面多个表格,路由回来A表格从新被activate挂起,handleVisibility没有走,
|
|
226
|
-
B表格这时候也会被activate = true给锁死,导致没办法更新白屏问题,比如一个页面存在tabs的场景
|
|
227
|
-
*/
|
|
228
|
-
const isVisible = this.isVisible()
|
|
229
|
-
if (isVisible) {
|
|
230
|
-
this.activate = true
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
methods: {
|
|
234
|
-
init() {
|
|
235
|
-
let $container = this.$refs.container
|
|
236
|
-
this.changeSize()
|
|
237
|
-
this.resizeObserver = new ResizeObserver(this.handleVisibility)
|
|
238
|
-
this.resizeObserver.observe($container)
|
|
239
|
-
this.scrollbar = this.$refs.scrollbar
|
|
240
|
-
this.touchScroll = new TouchScrolling($container, {
|
|
241
|
-
unScrollY: !this.scrollY,
|
|
242
|
-
unScrollX: !this.scrollX,
|
|
243
|
-
isShowHorizontal: this.isShowHorizontal,
|
|
244
|
-
handlerTouchStar: () => {
|
|
245
|
-
this.$emit('scrollTouchstar', {
|
|
246
|
-
scrollTop: this.offsetY,
|
|
247
|
-
})
|
|
248
|
-
},
|
|
249
|
-
handlerTouchend: finaloffsetY => {
|
|
250
|
-
// 因为当刻所获取的offsetY 并不准确, 前后多的行数数据作为冗余值提前加载
|
|
251
|
-
const rowHeight = this.$props.rowHeight
|
|
252
|
-
let startRow = Math.floor((this.offsetY + finaloffsetY) / rowHeight)
|
|
253
|
-
const numRows = this.tableData.length
|
|
254
|
-
const rowsPerViewport = this.state.rowsPerViewport
|
|
255
|
-
const endRow = Math.min(startRow + rowsPerViewport * 2, numRows)
|
|
256
|
-
// 把其实行设置为当前行,前后多的行数数据作为冗余值提前加载
|
|
257
|
-
startRow = Math.floor(this.offsetY / rowHeight)
|
|
258
|
-
this.$emit('scrollTouchend', {
|
|
259
|
-
startRow,
|
|
260
|
-
endRow,
|
|
261
|
-
rowsPerViewport,
|
|
262
|
-
})
|
|
263
|
-
},
|
|
264
|
-
handlerTouchmove: () => {},
|
|
265
|
-
handlerScrollEnd: parmas => {
|
|
266
|
-
if (!this.$props.isSorbentColumm) return
|
|
267
|
-
if (parmas.y === 0) {
|
|
268
|
-
const state = this.getState()
|
|
269
|
-
const scrollX = this.offsetX
|
|
270
|
-
const width = this.getViewportWidth()
|
|
271
|
-
if (Math.abs(state.tableWidth - width - scrollX) < 2) {
|
|
272
|
-
return
|
|
273
|
-
}
|
|
274
|
-
const fixedList = this.mainColumns.filter(col => col.fixed === 'left' || col.fixed)
|
|
275
|
-
const fixedWidth = fixedList.reduce((acc, col) => acc + col.width, 0) // 计算左边固定距离
|
|
276
|
-
// 非固定和非group的列
|
|
277
|
-
const noFixedAndParentsColums = this.mainColumns.filter(item => item.children.length === 0 && !item.fixed)
|
|
278
|
-
for (let i = 0; i < noFixedAndParentsColums.length - 1; i++) {
|
|
279
|
-
const beginOffsetX = noFixedAndParentsColums[i].offsetX - fixedWidth
|
|
280
|
-
const endOffsetX = noFixedAndParentsColums[i + 1].offsetX - fixedWidth
|
|
281
|
-
// 滚动距离在滑动距离之内,离哪个近,则吸附相近的列
|
|
282
|
-
if (beginOffsetX <= scrollX && scrollX <= endOffsetX) {
|
|
283
|
-
const isNextColumn = endOffsetX - scrollX < scrollX - beginOffsetX
|
|
284
|
-
const scrollToColumnKey = noFixedAndParentsColums[isNextColumn ? i + 1 : i].key
|
|
285
|
-
this.scrollToColumn(scrollToColumnKey, 0, 300)
|
|
286
|
-
break
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
handlerBeforeAnimation: isYAndDownToTop => {
|
|
292
|
-
const isBottom = this.offsetY + this.viewportHeight > this.state.tableHeight
|
|
293
|
-
if (isYAndDownToTop && isBottom) {
|
|
294
|
-
this.scrollHiddenMore()
|
|
295
|
-
}
|
|
296
|
-
return isBottom
|
|
297
|
-
},
|
|
298
|
-
})
|
|
299
|
-
this.renderViewportRows()
|
|
300
|
-
this.createHeader()
|
|
301
|
-
},
|
|
302
|
-
updateRender() {
|
|
303
|
-
// if (this.columns && !this.mainColumns.length) {
|
|
304
|
-
// }
|
|
305
|
-
// this.updateTableData()
|
|
306
|
-
// this.curMaxIndexVal = this.tableData.length
|
|
307
|
-
// this.updateColumnsIndexWidth()
|
|
308
|
-
// this.$nextTick(() => {
|
|
309
|
-
// // 数据变化之后,y轴归零
|
|
310
|
-
// if (this.$props.autoResetScrollTop) {
|
|
311
|
-
// // 重置滚动位置
|
|
312
|
-
// this.scrollToTop()
|
|
313
|
-
// } else {
|
|
314
|
-
// this.renderViewportRows()
|
|
315
|
-
// }
|
|
316
|
-
// // 滚动条发生改变
|
|
317
|
-
// this.refreshThumb()
|
|
318
|
-
// })
|
|
319
|
-
|
|
320
|
-
this.updateTableData()
|
|
321
|
-
this.curMaxIndexVal = this.tableData.length
|
|
322
|
-
this.updateColumnsIndexWidth()
|
|
323
|
-
// 数据变化之后,y轴归零
|
|
324
|
-
if (this.$props.autoResetScrollTop) {
|
|
325
|
-
// 重置滚动位置
|
|
326
|
-
this.scrollToTop()
|
|
327
|
-
} else {
|
|
328
|
-
this.renderViewportRows()
|
|
329
|
-
}
|
|
330
|
-
this.$nextTick(() => {
|
|
331
|
-
// 滚动条发生改变
|
|
332
|
-
this.refreshThumb()
|
|
333
|
-
this.renderViewportCells()
|
|
334
|
-
})
|
|
335
|
-
},
|
|
336
|
-
flatColumns() {
|
|
337
|
-
const { collapsedMap, visibleFlatColumns } = createFlatColumns({
|
|
338
|
-
columns: this.columns,
|
|
339
|
-
rowCellRender: this.$props.rowCellRender,
|
|
340
|
-
headerCellRender: this.$props.headerCellRender,
|
|
341
|
-
showIndex: this.$props.showIndex,
|
|
342
|
-
})
|
|
343
|
-
this.collapsedMap = collapsedMap
|
|
344
|
-
this.visibleFlatColumns = visibleFlatColumns
|
|
345
|
-
},
|
|
346
|
-
updateColumnsIndexWidth() {
|
|
347
|
-
const indexCol = String(this.curMaxIndexVal).length * 10
|
|
348
|
-
const indexColumn = this.mainColumns.find(column => column.key === '$index')
|
|
349
|
-
if (indexColumn && indexColumn.width !== indexCol) {
|
|
350
|
-
this.updateColumns()
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
updateColumns() {
|
|
354
|
-
const { columns, maxLevel } = createColumns({
|
|
355
|
-
visibleFlatColumns: this.visibleFlatColumns,
|
|
356
|
-
collapsedMap: this.collapsedMap,
|
|
357
|
-
rowKey: this.$props.rowKey,
|
|
358
|
-
headerRowHeight: this.$props.headerRowHeight,
|
|
359
|
-
curMaxIndexVal: this.curMaxIndexVal,
|
|
360
|
-
})
|
|
361
|
-
this.maxLevel = maxLevel
|
|
362
|
-
this.mainColumns = columns
|
|
363
|
-
// this.collapseKeysMap = collapseKeysMap
|
|
364
|
-
},
|
|
365
|
-
updateTableData() {
|
|
366
|
-
const params = {
|
|
367
|
-
data: this.$props.data,
|
|
368
|
-
columns: this.visibleFlatColumns,
|
|
369
|
-
rowKey: this.$props.rowKey,
|
|
370
|
-
}
|
|
371
|
-
this.tableData = createTableData(params, this.$props.indexFormat)
|
|
372
|
-
},
|
|
373
|
-
isVisible() {
|
|
374
|
-
const status = this.$el && this.$el.checkVisibility && this.$el.checkVisibility()
|
|
375
|
-
return status === undefined ? this.$el.offsetParent !== null : status
|
|
376
|
-
},
|
|
377
|
-
handleVisibility() {
|
|
378
|
-
// 在A页面切换到B页面,B页面这时候属于一个激活状态,不需要重新计算
|
|
379
|
-
if (this.activate) {
|
|
380
|
-
this.activate = false
|
|
381
|
-
return
|
|
382
|
-
}
|
|
383
|
-
const isVisible = this.isVisible()
|
|
384
|
-
if (!isVisible) {
|
|
385
|
-
this.visibility = false
|
|
386
|
-
}
|
|
387
|
-
if (this.visibility === false && isVisible) {
|
|
388
|
-
this.visibility = true
|
|
389
|
-
this.onResize()
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
changeSize() {
|
|
393
|
-
// 表格被隐藏。不应该被计算
|
|
394
|
-
const isVisible = this.isVisible()
|
|
395
|
-
if (!isVisible) {
|
|
396
|
-
this.visibility = false
|
|
397
|
-
return
|
|
398
|
-
}
|
|
399
|
-
const width = this.getViewportWidth()
|
|
400
|
-
const height = this.getViewportHeight()
|
|
401
|
-
this.viewportWidth = width
|
|
402
|
-
this.viewportHeight = height
|
|
403
|
-
this.$refs.container.style.width = width + 'PX'
|
|
404
|
-
this.$refs.container.style.height = height + 'PX'
|
|
405
|
-
this.$refs.root.style.width = width + 'PX'
|
|
406
|
-
this.$refs.root.style.height = height + 'PX'
|
|
407
|
-
this.$nextTick(() => {
|
|
408
|
-
this.renderViewportRows()
|
|
409
|
-
this.renderViewportCells()
|
|
410
|
-
this.refreshThumb()
|
|
411
|
-
})
|
|
412
|
-
},
|
|
413
|
-
// 修改 getViewportHeight 方法
|
|
414
|
-
getViewportHeight() {
|
|
415
|
-
// 计算实际内容高度
|
|
416
|
-
const contentHeight = this.$props.rowHeight * this.tableData.length + this.headerTotalHeight
|
|
417
|
-
// 如果有设置最大高度,取较小值
|
|
418
|
-
if (this.$props.maxHeight) {
|
|
419
|
-
return Math.min(contentHeight, parseInt(this.$props.maxHeight))
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// 原有逻辑保持不变
|
|
423
|
-
if (this.$props.height) {
|
|
424
|
-
return parseInt(this.$props.height)
|
|
425
|
-
}
|
|
426
|
-
return this.$refs.container.clientHeight
|
|
427
|
-
},
|
|
428
|
-
getViewportWidth() {
|
|
429
|
-
if (this.$props.width) {
|
|
430
|
-
return parseInt(this.$props.width)
|
|
431
|
-
}
|
|
432
|
-
return this.$refs.container.clientWidth
|
|
433
|
-
},
|
|
434
|
-
getState() {
|
|
435
|
-
const numRows = this.tableData.length
|
|
436
|
-
// 增加行渲染的冗余,保证触底时的效果
|
|
437
|
-
const rowsPerViewport = Math.ceil((this.viewportHeight - this.headerTotalHeight) / this.$props.rowHeight) + 1
|
|
438
|
-
const tableHeight = numRows * this.$props.rowHeight + this.headerTotalHeight
|
|
439
|
-
const mainColumns = this.mainColumns
|
|
440
|
-
const { tableWidth, renderCellsColumns, renderCellsColumnsWidths } = createRenderColumnOption({
|
|
441
|
-
mainColumns,
|
|
442
|
-
maxLevel: this.maxLevel,
|
|
443
|
-
headerRowHeight: this.$props.headerRowHeight,
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
// 为什么这里还需要再算一次?因为如果直接把父节点的子节点都塞进去,那么子节点就会全部渲染,子节点个数得不到渲染。
|
|
447
|
-
// 所以这里还需要再算一次。
|
|
448
|
-
const { startIndex: startCell, endIndex: endCell } = getRenderRange(this.offsetX, this.viewportWidth, renderCellsColumnsWidths)
|
|
449
|
-
this.renderCellsColumns = renderCellsColumns
|
|
450
|
-
|
|
451
|
-
const startRow = Math.floor(this.offsetY / this.$props.rowHeight)
|
|
452
|
-
const endRow = Math.min(startRow + rowsPerViewport, numRows)
|
|
453
|
-
// const showRowsPerViewport = Math.max(0, rowsPerViewport - 1)
|
|
454
|
-
// const showEndRow = Math.min(startRow + showRowsPerViewport, numRows)
|
|
455
|
-
const tableHeightNoHeader = this.offsetY + this.viewportHeight - this.headerTotalHeight
|
|
456
|
-
// const showEndRow = Math.min(Math.ceil(tableHeightNoHeader / this.$props.rowHeight ), numRows)
|
|
457
|
-
const showEndRow = Math.min(Math.floor((tableHeightNoHeader + this.$props.rowHeight / 2) / this.$props.rowHeight), numRows)
|
|
458
|
-
const rowOffset = -Math.floor(this.offsetY % this.$props.rowHeight)
|
|
459
|
-
|
|
460
|
-
// 滚动条的计算逻辑
|
|
461
|
-
const scrollableHeight = Math.max(tableHeight - this.viewportHeight, 0)
|
|
462
|
-
const scrollThumbYPct = tableHeight === 0 ? 1 : 0.97 * Math.sqrt(this.viewportHeight / tableHeight) + 0.03
|
|
463
|
-
const thumbSizeY = Math.round(Math.max(Math.min(scrollThumbYPct * this.viewportHeight, this.viewportHeight), 0))
|
|
464
|
-
let thumbOffsetY
|
|
465
|
-
if (scrollableHeight === 0) {
|
|
466
|
-
thumbOffsetY = 0
|
|
467
|
-
} else {
|
|
468
|
-
thumbOffsetY = (this.offsetY / scrollableHeight) * this.viewportHeight - thumbSizeY * (this.offsetY / scrollableHeight)
|
|
469
|
-
}
|
|
470
|
-
const scrollableWidth = Math.max(tableWidth - this.viewportWidth, 0)
|
|
471
|
-
const scrollThumbXPct = tableWidth === 0 ? 100 : this.viewportWidth / tableWidth
|
|
472
|
-
const thumbSizeX = Math.round(Math.max(Math.min(scrollThumbXPct * this.viewportWidth, this.viewportWidth), 30))
|
|
473
|
-
const thumbOffsetX = (this.offsetX / scrollableWidth) * this.viewportWidth - thumbSizeX * (this.offsetX / scrollableWidth)
|
|
474
|
-
const trackYStyle = {
|
|
475
|
-
right: Math.max(0, this.viewportWidth - tableWidth) + 'px',
|
|
476
|
-
opacity: tableHeight > this.viewportHeight ? 1 : 0,
|
|
477
|
-
}
|
|
478
|
-
const trackXStyle = {
|
|
479
|
-
opacity: tableWidth > this.viewportWidth && numRows ? 1 : 0,
|
|
480
|
-
}
|
|
481
|
-
if (this.state != null) {
|
|
482
|
-
this.state.showEndRow = showEndRow
|
|
483
|
-
this.state.endRow = endRow
|
|
484
|
-
this.state.startRow = startRow
|
|
485
|
-
this.state.rowOffset = rowOffset + this.headerTotalHeight
|
|
486
|
-
|
|
487
|
-
this.state.startCell = startCell
|
|
488
|
-
this.state.endCell = endCell
|
|
489
|
-
|
|
490
|
-
this.state.scrollableHeight = scrollableHeight
|
|
491
|
-
this.state.tableHeight = tableHeight
|
|
492
|
-
this.state.thumbOffsetY = thumbOffsetY
|
|
493
|
-
this.state.thumbSizeY = thumbSizeY
|
|
494
|
-
|
|
495
|
-
this.state.scrollableWidth = scrollableWidth
|
|
496
|
-
this.state.tableWidth = tableWidth
|
|
497
|
-
this.state.thumbOffsetX = thumbOffsetX
|
|
498
|
-
this.state.thumbSizeX = thumbSizeX
|
|
499
|
-
this.state.trackYStyle = trackYStyle
|
|
500
|
-
this.state.trackXStyle = trackXStyle
|
|
501
|
-
|
|
502
|
-
this.state.rowsPerViewport = rowsPerViewport
|
|
503
|
-
return this.state
|
|
504
|
-
}
|
|
505
|
-
const state = {
|
|
506
|
-
showEndRow,
|
|
507
|
-
endRow,
|
|
508
|
-
startRow,
|
|
509
|
-
rowOffset,
|
|
510
|
-
|
|
511
|
-
startCell,
|
|
512
|
-
endCell,
|
|
513
|
-
|
|
514
|
-
scrollableHeight,
|
|
515
|
-
tableHeight,
|
|
516
|
-
thumbOffsetY,
|
|
517
|
-
thumbSizeY,
|
|
518
|
-
|
|
519
|
-
scrollableWidth,
|
|
520
|
-
tableWidth,
|
|
521
|
-
thumbOffsetX,
|
|
522
|
-
thumbSizeX,
|
|
523
|
-
|
|
524
|
-
rowsPerViewport,
|
|
525
|
-
trackYStyle,
|
|
526
|
-
trackXStyle,
|
|
527
|
-
}
|
|
528
|
-
this.state = state
|
|
529
|
-
return state
|
|
530
|
-
},
|
|
531
|
-
throttleHandleResize: throttle(function () {
|
|
532
|
-
this.onResize()
|
|
533
|
-
}, 30),
|
|
534
|
-
onResize() {
|
|
535
|
-
this.changeSize()
|
|
536
|
-
this.setScrollOffsetY(this.offsetY)
|
|
537
|
-
this.setScrollOffsetX(this.offsetX)
|
|
538
|
-
},
|
|
539
|
-
setScrollToLoadMore() {
|
|
540
|
-
const { scrollableHeight } = this.state
|
|
541
|
-
// 开启了加载更多并且再接近最后一屏进行位置的设置,并回调加载更多函数
|
|
542
|
-
// 有表格高度,并且非加载完成,且滚动到需要触发的距离
|
|
543
|
-
if (this.enableLoadMore && !this.isLoadFinished && scrollableHeight - this.offsetY <= this.loadOptions.offset) {
|
|
544
|
-
// console.log('触发 loadMore, 距离底部距离:', scrollableHeight - this.offsetY)
|
|
545
|
-
this.callbackLoadMore()
|
|
546
|
-
}
|
|
547
|
-
this.setLoadMroeOffset()
|
|
548
|
-
},
|
|
549
|
-
// 设置加载更多组件的位置
|
|
550
|
-
async setLoadMroeOffset() {
|
|
551
|
-
const { startRow, rowsPerViewport, rowOffset } = this.state
|
|
552
|
-
// 为了减少过度计算,判断在末屏才进行计算
|
|
553
|
-
let dataCount = this.data.length
|
|
554
|
-
let offset = -9999
|
|
555
|
-
if (startRow >= dataCount - rowsPerViewport) {
|
|
556
|
-
this.getLoadmoreHeight()
|
|
557
|
-
// 把加载更多当作最后一行计算起始位置
|
|
558
|
-
offset = rowOffset + (dataCount - startRow) * this.$props.rowHeight
|
|
559
|
-
} else {
|
|
560
|
-
offset = -9999
|
|
561
|
-
}
|
|
562
|
-
await this.$nextTick()
|
|
563
|
-
let $loadMore = this.$refs.loadMroe
|
|
564
|
-
if ($loadMore) {
|
|
565
|
-
$loadMore.style.transform = `translateY(${offset}px)`
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
// 获取该组件高度
|
|
569
|
-
getLoadmoreHeight() {
|
|
570
|
-
if (!this.loadMoreHeight && this.$refs.loadMroe) {
|
|
571
|
-
this.loadMoreHeight = this.$refs.loadMroe.offsetHeight || 0
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
callbackLoadMore: throttle(function () {
|
|
575
|
-
this.$emit('loadMore')
|
|
576
|
-
}, 100),
|
|
577
|
-
clearSortMap() {
|
|
578
|
-
this.sortMap = {
|
|
579
|
-
order: undefined, // 排序方式
|
|
580
|
-
key: undefined, // 排序的列的key
|
|
581
|
-
column: undefined, // 排序的列
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
renderViewportRows() {
|
|
585
|
-
if (!this.sortMap.order && this.defaultSort.order) {
|
|
586
|
-
this.sortMap.order = this.defaultSort.order
|
|
587
|
-
this.sortMap.key = this.defaultSort.key
|
|
588
|
-
}
|
|
589
|
-
// 获取渲染需要的对象
|
|
590
|
-
const state = this.getState()
|
|
591
|
-
// 渲染对象集合以id为key
|
|
592
|
-
const renderRows = {}
|
|
593
|
-
// rowsArr 只有在$props.data 在watch监听发生变更时,才会更新,遇到单元格渲染异常时,优先考虑此变量异常
|
|
594
|
-
const rowsArr = this.tableData
|
|
595
|
-
// 当前渲染的行
|
|
596
|
-
for (let i = state.startRow; i < state.endRow; i++) {
|
|
597
|
-
const rowId = rowsArr[i][this.$props.rowKey]
|
|
598
|
-
renderRows[rowId] = true
|
|
599
|
-
}
|
|
600
|
-
// 需要移出的行
|
|
601
|
-
const removeRows = []
|
|
602
|
-
// 遍历复用的组件对象
|
|
603
|
-
for (const id in this.rowComponentMap) {
|
|
604
|
-
// 存在与渲染的,跳过
|
|
605
|
-
if (id in renderRows) {
|
|
606
|
-
continue
|
|
607
|
-
}
|
|
608
|
-
// 否则记录在需要移出的行
|
|
609
|
-
const rowComponent = this.rowComponentMap[id]
|
|
610
|
-
removeRows.push(rowComponent)
|
|
611
|
-
}
|
|
612
|
-
const columns = this.renderCellsColumns || []
|
|
613
|
-
for (let i = state.startRow; i < state.endRow; i++) {
|
|
614
|
-
let row = rowsArr[i]
|
|
615
|
-
let originRowData = this.$props.data[i]
|
|
616
|
-
// 行数据不存在跳过
|
|
617
|
-
if (row == null) {
|
|
618
|
-
// eslint-disable-next-line
|
|
619
|
-
console.error('cannot find row', i)
|
|
620
|
-
continue
|
|
621
|
-
}
|
|
622
|
-
const rowId = row[this.$props.rowKey]
|
|
623
|
-
const cells = columns.reduce((obj, col, index) => {
|
|
624
|
-
obj[index] = {
|
|
625
|
-
[col.key]: originRowData[col.key],
|
|
626
|
-
id: `${rowId}_${i}_${col.key}_ ${index}`,
|
|
627
|
-
}
|
|
628
|
-
if (col.key === '$index') {
|
|
629
|
-
obj[index][col.key] = row[col.key]
|
|
630
|
-
}
|
|
631
|
-
return obj
|
|
632
|
-
}, [])
|
|
633
|
-
// 每一行的行高之间的偏移值
|
|
634
|
-
const offset = state.rowOffset + (i - state.startRow) * this.$props.rowHeight
|
|
635
|
-
const rowParams = {
|
|
636
|
-
rowIndex: i,
|
|
637
|
-
id: rowId, // 行数据中的唯一值
|
|
638
|
-
cells, // 行内的列的数据集合
|
|
639
|
-
rowData: row, // 行数据
|
|
640
|
-
offset, // 偏移量。这里是等高。暂不支持动态
|
|
641
|
-
rowHeight: this.$props.rowHeight, // 行高
|
|
642
|
-
type: 'row', // 行组件类型。渲染表头行和表体行
|
|
643
|
-
columns,
|
|
644
|
-
originRowData,
|
|
645
|
-
}
|
|
646
|
-
// 是否为已存在的的行组件
|
|
647
|
-
const existingRow = this.rowComponentMap[rowId]
|
|
648
|
-
// 存在直接改偏移值
|
|
649
|
-
if (existingRow != null) {
|
|
650
|
-
existingRow.reuse(rowParams)
|
|
651
|
-
existingRow.renderCells()
|
|
652
|
-
continue
|
|
653
|
-
}
|
|
654
|
-
// 需要移除的行数据。但是此处可复用行组件。
|
|
655
|
-
const reuseRow = removeRows.pop()
|
|
656
|
-
if (reuseRow != null) {
|
|
657
|
-
// 每个行组件都存在id属性。id的值为行数据必须唯一,为了检查是否复用,更新,或删除
|
|
658
|
-
delete this.rowComponentMap[reuseRow.id]
|
|
659
|
-
reuseRow.reuse(rowParams)
|
|
660
|
-
reuseRow.renderCells()
|
|
661
|
-
this.rowComponentMap[rowId] = reuseRow
|
|
662
|
-
continue
|
|
663
|
-
}
|
|
664
|
-
// 新增的行组件
|
|
665
|
-
const rowComponent = new RowConstructor({
|
|
666
|
-
el: document.createElement('div'),
|
|
667
|
-
})
|
|
668
|
-
// 行组件设置对应的属性
|
|
669
|
-
rowComponent.grid = this // 父组件实例
|
|
670
|
-
for (let prop in rowParams) {
|
|
671
|
-
rowComponent[prop] = rowParams[prop]
|
|
672
|
-
}
|
|
673
|
-
// rowComponent.renderCells()
|
|
674
|
-
// 直接追加到容器的dom中。不走vue的虚拟dom,减少计算开销
|
|
675
|
-
this.$refs.container.appendChild(rowComponent.$el)
|
|
676
|
-
this.rowComponentMap[rowId] = rowComponent
|
|
677
|
-
}
|
|
678
|
-
// 销毁并移出不需要的行
|
|
679
|
-
for (const rowComponent of removeRows) {
|
|
680
|
-
rowComponent.destroy() // 销毁
|
|
681
|
-
delete this.rowComponentMap[rowComponent.id] // 销毁内存中的行组件
|
|
682
|
-
}
|
|
683
|
-
// 渲染行之后看是否需要处理加载更多组件的位置
|
|
684
|
-
this.setScrollToLoadMore()
|
|
685
|
-
},
|
|
686
|
-
renderViewportCells() {
|
|
687
|
-
const state = this.getState()
|
|
688
|
-
// 更新视口区域的行组件
|
|
689
|
-
for (let i = state.startRow; i < state.endRow; i++) {
|
|
690
|
-
let row = this.tableData[i]
|
|
691
|
-
const rowId = row[this.$props.rowKey]
|
|
692
|
-
let rowComponent = this.rowComponentMap[rowId]
|
|
693
|
-
if (!rowComponent) {
|
|
694
|
-
// console.error('row should exist. did you render rows first?')
|
|
695
|
-
continue
|
|
696
|
-
}
|
|
697
|
-
// 更新行内的列(单元格)组件
|
|
698
|
-
rowComponent.renderCells.call(rowComponent)
|
|
699
|
-
}
|
|
700
|
-
this.headersComponent && this.headersComponent.renderCells()
|
|
701
|
-
// for (const row of Object.values(this.headerRows)) {
|
|
702
|
-
// row.renderCells.call(row)
|
|
703
|
-
// }
|
|
704
|
-
},
|
|
705
|
-
createHeader() {
|
|
706
|
-
this.getState()
|
|
707
|
-
if (this.headersComponent) {
|
|
708
|
-
// 存在时,直接销毁头。
|
|
709
|
-
this.$refs.container.removeChild(this.headersComponent.$el)
|
|
710
|
-
this.headersComponent.$destroy()
|
|
711
|
-
}
|
|
712
|
-
let offset = 0
|
|
713
|
-
const HEADER_ID = 'inner_header_in_99999999999999' // very dumb
|
|
714
|
-
const headersComponent = new RowConstructor({
|
|
715
|
-
el: document.createElement('div'),
|
|
716
|
-
})
|
|
717
|
-
const columns = this.renderCellsColumns
|
|
718
|
-
// 行数据设置
|
|
719
|
-
headersComponent.grid = this
|
|
720
|
-
const headerParams = {
|
|
721
|
-
id: HEADER_ID,
|
|
722
|
-
rowHeight: this.headerTotalHeight,
|
|
723
|
-
cells: columns,
|
|
724
|
-
columns,
|
|
725
|
-
offset: offset,
|
|
726
|
-
type: 'header',
|
|
727
|
-
}
|
|
728
|
-
for (let prop in headerParams) {
|
|
729
|
-
headersComponent[prop] = headerParams[prop]
|
|
730
|
-
}
|
|
731
|
-
// 直接追加到容器的dom中。不走vue的虚拟dom,减少计算开销
|
|
732
|
-
this.$refs.container.appendChild(headersComponent.$el)
|
|
733
|
-
this.headersComponent = headersComponent
|
|
734
|
-
},
|
|
735
|
-
|
|
736
|
-
handleEvent(event, params) {
|
|
737
|
-
const { name, ...reset } = params
|
|
738
|
-
this.$emit(name, { event, ...reset })
|
|
739
|
-
},
|
|
740
|
-
|
|
741
|
-
// 排序操作
|
|
742
|
-
sortChange(column) {
|
|
743
|
-
const execulteHanlder = () => {
|
|
744
|
-
if (!this.sortMap.order) {
|
|
745
|
-
this.sortMap.order = 'ascending'
|
|
746
|
-
} else {
|
|
747
|
-
this.sortMap.order = this.sortMap.order === 'ascending' ? 'descending' : 'ascending'
|
|
748
|
-
}
|
|
749
|
-
this.sortMap.key = column.key
|
|
750
|
-
// 真实请求用的排序字段,用于实现表格列的展示字段与排序请求字段不同的场景,比如:name 字段展示的列用 code 字段进行排序;
|
|
751
|
-
// 一般情况下,表格列的展示字段与排序请求字段是一致的,此时可以直接用 sortMap.key 字段
|
|
752
|
-
this.sortMap.reqKey = (Array.isArray(column.sortKeys) && column.sortKeys[0]) || column.key
|
|
753
|
-
this.sortMap.column = column.column
|
|
754
|
-
this.$emit('sort-change', {
|
|
755
|
-
order: this.sortMap.order,
|
|
756
|
-
column,
|
|
757
|
-
prop: this.sortMap.key,
|
|
758
|
-
reqProp: this.sortMap.reqKey,
|
|
759
|
-
})
|
|
760
|
-
this.renderViewportCells()
|
|
761
|
-
}
|
|
762
|
-
let fn = this.$props.beforeSort
|
|
763
|
-
if (fn && typeof fn === 'function') {
|
|
764
|
-
const beforeSort = fn({
|
|
765
|
-
column,
|
|
766
|
-
order: this.sortMap.order,
|
|
767
|
-
prop: column.key,
|
|
768
|
-
})
|
|
769
|
-
if (beforeSort && beforeSort.then) {
|
|
770
|
-
beforeSort.then(allow => {
|
|
771
|
-
allow !== false && execulteHanlder()
|
|
772
|
-
})
|
|
773
|
-
} else {
|
|
774
|
-
beforeSort !== false && execulteHanlder()
|
|
775
|
-
}
|
|
776
|
-
} else {
|
|
777
|
-
execulteHanlder()
|
|
778
|
-
}
|
|
779
|
-
},
|
|
780
|
-
// 排序相关操作
|
|
781
|
-
clearSort() {
|
|
782
|
-
this.$emit('sort-change', {})
|
|
783
|
-
},
|
|
784
|
-
// 断网
|
|
785
|
-
abnormal() {
|
|
786
|
-
this.$emit('abnormal')
|
|
787
|
-
},
|
|
788
|
-
showTotalView() {
|
|
789
|
-
const { showEndRow = 0, rowsPerViewport = 0 } = this.state
|
|
790
|
-
if (showEndRow > rowsPerViewport) {
|
|
791
|
-
this.isShowTotal = true
|
|
792
|
-
setTimeout(() => {
|
|
793
|
-
this.hiddenTotalView()
|
|
794
|
-
}, 1000)
|
|
795
|
-
}
|
|
796
|
-
},
|
|
797
|
-
hiddenTotalView: debounce(function () {
|
|
798
|
-
this.isShowTotal = false
|
|
799
|
-
}, 1000),
|
|
800
|
-
scrollHiddenMore() {
|
|
801
|
-
if (this.timerMore) {
|
|
802
|
-
this.timerMore = null
|
|
803
|
-
clearTimeout(this.timerMore)
|
|
804
|
-
}
|
|
805
|
-
this.timerMore = setTimeout(() => {
|
|
806
|
-
const numRows = this.tableData.length
|
|
807
|
-
this.scrollToRow(numRows - 1, 0, 300)
|
|
808
|
-
}, 0)
|
|
809
|
-
},
|
|
810
|
-
scrollHiddenMoreIfNeeded(isYAndDownToTop = true) {
|
|
811
|
-
const isBottom = this.offsetY + this.viewportHeight > this.state.tableHeight
|
|
812
|
-
if (isYAndDownToTop && isBottom) {
|
|
813
|
-
this.scrollHiddenMore()
|
|
814
|
-
}
|
|
815
|
-
},
|
|
816
|
-
cellResize({ columnKey, width } = {}) {
|
|
817
|
-
const column = this.visibleFlatColumns.find(col => col.key === columnKey)
|
|
818
|
-
column.width = width
|
|
819
|
-
|
|
820
|
-
this.updateColumns()
|
|
821
|
-
this.createHeader()
|
|
822
|
-
this.changeSize()
|
|
823
|
-
this.setScrollOffsetY(this.offsetY)
|
|
824
|
-
this.setScrollOffsetX(this.offsetX)
|
|
825
|
-
|
|
826
|
-
this.$emit('cell-resize', {
|
|
827
|
-
column,
|
|
828
|
-
width,
|
|
829
|
-
})
|
|
830
|
-
},
|
|
831
|
-
},
|
|
832
|
-
}
|
|
833
|
-
</script>
|
|
834
|
-
|
|
835
|
-
<style lang="less" scoped>
|
|
836
|
-
@import url('./style/index.less');
|
|
837
|
-
</style>
|