@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,424 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { animateScroll } from './utils/animate'
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
data() {
|
|
6
|
-
return {
|
|
7
|
-
isScrolling: false,
|
|
8
|
-
transientScrollOffsetY: 0,
|
|
9
|
-
transientScrollOffsetX: 0,
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
mounted() {
|
|
13
|
-
// 添加滚动条到网格容器
|
|
14
|
-
this.refreshThumb()
|
|
15
|
-
|
|
16
|
-
// 绑定事件
|
|
17
|
-
// this.$refs.trackX.addEventListener('mousemove', this.onTrackMouseMoveX)
|
|
18
|
-
// this.$refs.trackX.addEventListener('mousedown', this.onTrackMouseDownX)
|
|
19
|
-
// this.$refs.trackY.addEventListener('mousemove', this.onTrackMouseMoveY)
|
|
20
|
-
// this.$refs.trackY.addEventListener('mousedown', this.onTrackMouseDownY)
|
|
21
|
-
// this.$refs.thumbX.addEventListener('mousedown', this.onThumbMouseDownX)
|
|
22
|
-
// this.$refs.thumbY.addEventListener('mousedown', this.onThumbMouseDownY)
|
|
23
|
-
this.$refs.container.addEventListener('wheel', this.onContainerWheel)
|
|
24
|
-
},
|
|
25
|
-
beforeDestroy() {
|
|
26
|
-
// 移除事件监听器
|
|
27
|
-
this.$refs.trackX.removeEventListener('mousemove', this.onTrackMouseMoveX)
|
|
28
|
-
this.$refs.trackX.removeEventListener('mousedown', this.onTrackMouseDownX)
|
|
29
|
-
this.$refs.trackY.removeEventListener('mousemove', this.onTrackMouseMoveY)
|
|
30
|
-
this.$refs.trackY.removeEventListener('mousedown', this.onTrackMouseDownY)
|
|
31
|
-
this.$refs.thumbX.removeEventListener('mousedown', this.onThumbMouseDownX)
|
|
32
|
-
this.$refs.thumbY.removeEventListener('mousedown', this.onThumbMouseDownY)
|
|
33
|
-
this.$refs.container.removeEventListener('wheel', this.onContainerWheel)
|
|
34
|
-
},
|
|
35
|
-
methods: {
|
|
36
|
-
renderViewportCellsColumns() {
|
|
37
|
-
return [...this.renderCellsColumns.filter(col => col.fixed), ...this.renderCellsColumns.slice(this.state.startCell, this.state.endCell + 1)]
|
|
38
|
-
},
|
|
39
|
-
renderScollXTable(x) {
|
|
40
|
-
this.setScrollOffsetX(x);
|
|
41
|
-
this.createHeader();
|
|
42
|
-
this.renderViewportCells();
|
|
43
|
-
this.emitScroll()
|
|
44
|
-
},
|
|
45
|
-
renderScrollYTable(y) {
|
|
46
|
-
this.setScrollOffsetY(y)
|
|
47
|
-
this.renderViewportRows()
|
|
48
|
-
this.emitScroll()
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* 垂直滚动到指定行
|
|
52
|
-
* @param {Number} rowKey 数据源中的行Key(从0开始)
|
|
53
|
-
* @param {Number} [offset=0] 额外偏移量(像素)
|
|
54
|
-
* @param {Number} [duration] 动画持续时间(毫秒)
|
|
55
|
-
*/
|
|
56
|
-
scrollToColumn(key, offset = 0, duration) {
|
|
57
|
-
const state = this.getState();
|
|
58
|
-
const maxScrollLeft = state.scrollableWidth;
|
|
59
|
-
const column = this.mainColumns.find(col => col.key === key);
|
|
60
|
-
|
|
61
|
-
if (!column) return;
|
|
62
|
-
|
|
63
|
-
const fixedList = this.mainColumns.filter(col => col.fixed === 'left' || col.fixed);
|
|
64
|
-
|
|
65
|
-
const fixedWidth = fixedList.reduce((acc, col) => acc + col.width, 0);
|
|
66
|
-
|
|
67
|
-
const targetScrollLeft = Math.min(
|
|
68
|
-
Math.max(0, column.offsetX - fixedWidth - offset),
|
|
69
|
-
maxScrollLeft
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (duration) {
|
|
73
|
-
animateScroll({
|
|
74
|
-
from: this.offsetX,
|
|
75
|
-
to: targetScrollLeft,
|
|
76
|
-
duration,
|
|
77
|
-
onUpdate: (currentPos) => {
|
|
78
|
-
this.renderScollXTable(currentPos)
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
} else {
|
|
82
|
-
this.renderScollXTable(targetScrollLeft)
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* 垂直滚动到指定行
|
|
87
|
-
* @param {Number} rowIndex 数据源中的行索引(从0开始)
|
|
88
|
-
* @param {Number} [offset=0] 额外偏移量(像素)
|
|
89
|
-
* @param {Number} [duration] 动画持续时间(毫秒)
|
|
90
|
-
*/
|
|
91
|
-
scrollToRow(targetIndex, offset = 0, duration) {
|
|
92
|
-
const targetScrollTop = this.getTargetScrollTop(targetIndex, offset)
|
|
93
|
-
if (duration) {
|
|
94
|
-
animateScroll({
|
|
95
|
-
from: this.offsetY,
|
|
96
|
-
to: targetScrollTop,
|
|
97
|
-
duration,
|
|
98
|
-
onUpdate: (currentPos) => {
|
|
99
|
-
this.renderScrollYTable(currentPos)
|
|
100
|
-
},
|
|
101
|
-
})
|
|
102
|
-
} else {
|
|
103
|
-
this.renderScrollYTable(targetScrollTop)
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
// 获取Y轴滚动距离
|
|
107
|
-
getTargetScrollTop(targetIndex, offset = 0) {
|
|
108
|
-
// 边界处理(确保索引在有效范围内)
|
|
109
|
-
const maxIndex = this.tableData.length - 1
|
|
110
|
-
const safeIndex = Math.max(0, Math.min(targetIndex, maxIndex))
|
|
111
|
-
|
|
112
|
-
// 核心计算参数
|
|
113
|
-
const rowHeight = this.$props.rowHeight
|
|
114
|
-
const availableHeight = this.viewportHeight - this.headerTotalHeight // 实际可用高度
|
|
115
|
-
const totalRowHeight = this.tableData.length * rowHeight // 总行高(不含表头)
|
|
116
|
-
|
|
117
|
-
// 计算基础偏移量
|
|
118
|
-
let baseOffset = safeIndex * rowHeight
|
|
119
|
-
|
|
120
|
-
// 最终偏移量计算(包含边界限制)
|
|
121
|
-
const maxScrollTop = Math.max(0, totalRowHeight - availableHeight)
|
|
122
|
-
return Math.max(0, Math.min(baseOffset + offset, maxScrollTop))
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
resetStretch(timeout = 100) {
|
|
126
|
-
setTimeout(() => {
|
|
127
|
-
const maxScrollTop = this.getTargetScrollTop(this.tableData.length - 1, 0)
|
|
128
|
-
if (this.offsetY >= maxScrollTop) {
|
|
129
|
-
animateScroll({
|
|
130
|
-
from: this.offsetY,
|
|
131
|
-
to: maxScrollTop,
|
|
132
|
-
duration: 10,
|
|
133
|
-
onUpdate: (currentPos) => {
|
|
134
|
-
this.renderScrollYTable(currentPos)
|
|
135
|
-
},
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
}, timeout);
|
|
139
|
-
|
|
140
|
-
},
|
|
141
|
-
refreshThumb() {
|
|
142
|
-
const state = this.getState()
|
|
143
|
-
this.translateThumbY(state.thumbOffsetY)
|
|
144
|
-
this.setThumbSizeY(state.thumbSizeY - this.headerTotalHeight)
|
|
145
|
-
this.translateThumbX(state.thumbOffsetX)
|
|
146
|
-
this.setThumbSizeX(state.thumbSizeX)
|
|
147
|
-
},
|
|
148
|
-
clampThumbIfNeeded() {
|
|
149
|
-
const state = this.getState()
|
|
150
|
-
let shouldTranslateThumb = false
|
|
151
|
-
if (this.offsetY != null && (this.offsetY < 0 || this.offsetY > state.scrollableHeight)) {
|
|
152
|
-
const clampedOffsetY = Math.max(0, Math.min(this.offsetY, state.scrollableHeight))
|
|
153
|
-
this.offsetY = clampedOffsetY
|
|
154
|
-
shouldTranslateThumb = true
|
|
155
|
-
}
|
|
156
|
-
if (this.offsetX != null && (this.offsetX < 0 || this.offsetX > state.scrollableWidth)) {
|
|
157
|
-
const clampedOffsetX = Math.max(0, Math.min(this.offsetX, state.scrollableWidth))
|
|
158
|
-
this.offsetX = clampedOffsetX
|
|
159
|
-
shouldTranslateThumb = true
|
|
160
|
-
}
|
|
161
|
-
if (shouldTranslateThumb) {
|
|
162
|
-
const state2 = this.getState()
|
|
163
|
-
this.translateThumbX(state2.thumbOffsetX)
|
|
164
|
-
this.translateThumbY(state2.thumbOffsetY)
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
setScrollOffsetX(x) {
|
|
168
|
-
const state = this.getState()
|
|
169
|
-
const clampedOffsetX = Math.max(0, Math.min(x, state.scrollableWidth))
|
|
170
|
-
this.offsetX = clampedOffsetX
|
|
171
|
-
|
|
172
|
-
const state2 = this.getState()
|
|
173
|
-
this.translateThumbX(state2.thumbOffsetX)
|
|
174
|
-
},
|
|
175
|
-
ease(currentScroll, distance) {
|
|
176
|
-
// 最大距离
|
|
177
|
-
const maxScrollY = this.state.tableHeight - this.viewportHeight + this.loadMoreHeight
|
|
178
|
-
let damping = 1
|
|
179
|
-
// 剩余距离
|
|
180
|
-
const remainingDistance = maxScrollY - currentScroll
|
|
181
|
-
damping = remainingDistance / maxScrollY
|
|
182
|
-
|
|
183
|
-
let newDistance = distance * damping * 10
|
|
184
|
-
|
|
185
|
-
return newDistance
|
|
186
|
-
},
|
|
187
|
-
setScrollOffsetY(y) {
|
|
188
|
-
const state = this.getState()
|
|
189
|
-
let scrollableHeight = state.scrollableHeight
|
|
190
|
-
// 如果开启了上拉加载更多,这里最大滚动高度加上上拉加载更多的高度
|
|
191
|
-
if (this.enableLoadMore) {
|
|
192
|
-
const loadMoreHeight = this.loadMoreHeight || 0
|
|
193
|
-
// const dyc = (this.isHasOffsetY && this.isLoadFinished) ? 0 : loadMoreHeight
|
|
194
|
-
const dyc = loadMoreHeight
|
|
195
|
-
// 表格条数加上加载更多的距离够才需要加可滚动距离
|
|
196
|
-
if ((state.tableHeight + dyc) > this.viewportHeight) {
|
|
197
|
-
scrollableHeight += dyc
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
const clampedOffsetY = Math.max(0, Math.min(y, scrollableHeight))
|
|
201
|
-
this.offsetY = clampedOffsetY
|
|
202
|
-
const state2 = this.getState()
|
|
203
|
-
this.translateThumbY(state2.thumbOffsetY)
|
|
204
|
-
},
|
|
205
|
-
emitScroll() {
|
|
206
|
-
// const renderViewportCellsColumns = [...this.renderCellsColumns.filter(col => col.fixed), ...this.renderCellsColumns.slice(this.state.startCell, this.state.endCell + 1)]
|
|
207
|
-
const params = {
|
|
208
|
-
direction: this.scrollDirection,
|
|
209
|
-
scrollLeft: this.offsetX,
|
|
210
|
-
scrollTop: this.offsetY,
|
|
211
|
-
startRow: this.state.startRow,
|
|
212
|
-
endRow: this.state.endRow,
|
|
213
|
-
startCell: this.state.startCell,
|
|
214
|
-
endCell: this.state.endCell,
|
|
215
|
-
rowsPerViewport: this.state.rowsPerViewport,
|
|
216
|
-
viewportEndRowIndex: this.getViewportEndRowIndex(),
|
|
217
|
-
// renderViewportCellsColumns
|
|
218
|
-
}
|
|
219
|
-
this.$emit('scroll', params)
|
|
220
|
-
if (this.isScrollShowTotal) {
|
|
221
|
-
this.showTotalView()
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
scrollBy(x, y) {
|
|
225
|
-
// console.log(x, y, 'scrollBy')
|
|
226
|
-
|
|
227
|
-
let renderRows = false
|
|
228
|
-
let renderCells = false
|
|
229
|
-
|
|
230
|
-
// 仅处理垂直滚动
|
|
231
|
-
if (y != null && y !== 0) {
|
|
232
|
-
if (!this.$props.scrollY && this.scrollDirection === 'Y' && !this.isShowHorizontal) {
|
|
233
|
-
return
|
|
234
|
-
}
|
|
235
|
-
if (this.offsetY + y > (this.state.tableHeight - this.viewportHeight + 100)) {
|
|
236
|
-
y = this.ease(this.offsetY + y, y)
|
|
237
|
-
}
|
|
238
|
-
this.setScrollOffsetY(this.offsetY + y)
|
|
239
|
-
renderRows = true
|
|
240
|
-
}
|
|
241
|
-
// 仅处理水平滚动
|
|
242
|
-
if (x != null && x !== 0) {
|
|
243
|
-
if (!this.$props.scrollX && this.scrollDirection === 'X') {
|
|
244
|
-
return
|
|
245
|
-
}
|
|
246
|
-
this.setScrollOffsetX(this.offsetX + x)
|
|
247
|
-
renderCells = true
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// 根据滚动方向渲染对应的部分
|
|
251
|
-
if (renderRows) {
|
|
252
|
-
this.renderViewportRows()
|
|
253
|
-
}
|
|
254
|
-
if (renderCells) {
|
|
255
|
-
this.renderViewportCells()
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
this.emitScroll()
|
|
259
|
-
},
|
|
260
|
-
getViewportEndRowIndex() {
|
|
261
|
-
if (this.state.endRow === this.tableData.length) {
|
|
262
|
-
return this.state.endRow
|
|
263
|
-
}
|
|
264
|
-
return this.state.endRow - Math.floor(this.headerTotalHeight / this.$props.rowHeight)
|
|
265
|
-
},
|
|
266
|
-
onContainerWheel(e) {
|
|
267
|
-
e.preventDefault()
|
|
268
|
-
e.stopPropagation()
|
|
269
|
-
|
|
270
|
-
let deltaY = e.deltaY
|
|
271
|
-
let deltaX = e.deltaX
|
|
272
|
-
if (Math.abs(deltaY) > 30 && Math.abs(deltaX) < 15) {
|
|
273
|
-
deltaX = 0
|
|
274
|
-
} else if (Math.abs(deltaX) > 30 && Math.abs(deltaY) < 15) {
|
|
275
|
-
deltaY = 0
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// 判断滚动方向
|
|
279
|
-
const isHorizontal = Math.abs(deltaX) > Math.abs(deltaY) // 水平滚动
|
|
280
|
-
const isVertical = Math.abs(deltaY) > Math.abs(deltaX) // 垂直滚动
|
|
281
|
-
|
|
282
|
-
// 如果是水平滚动,则忽略垂直滚动
|
|
283
|
-
if (isHorizontal) {
|
|
284
|
-
this.scrollDirection = 'X'
|
|
285
|
-
deltaY = 0
|
|
286
|
-
}
|
|
287
|
-
// 如果是垂直滚动,则忽略水平滚动
|
|
288
|
-
if (isVertical) {
|
|
289
|
-
this.scrollDirection = 'Y'
|
|
290
|
-
deltaX = 0
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
this.transientScrollOffsetX += deltaX
|
|
294
|
-
this.transientScrollOffsetY += deltaY
|
|
295
|
-
if (this.isScrolling) {
|
|
296
|
-
return
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
this.isScrolling = true
|
|
300
|
-
window.requestAnimationFrame(() => {
|
|
301
|
-
const scrollX = this.transientScrollOffsetX !== 0 ? this.transientScrollOffsetX : undefined
|
|
302
|
-
const scrollY = this.transientScrollOffsetY !== 0 ? this.transientScrollOffsetY : undefined
|
|
303
|
-
this.scrollBy(scrollX, scrollY)
|
|
304
|
-
this.isScrolling = false
|
|
305
|
-
this.transientScrollOffsetX = 0
|
|
306
|
-
this.transientScrollOffsetY = 0
|
|
307
|
-
})
|
|
308
|
-
},
|
|
309
|
-
onThumbMouseDownY(e) {
|
|
310
|
-
e.preventDefault()
|
|
311
|
-
e.stopPropagation()
|
|
312
|
-
document.body.style.setProperty('cursor', 'grabbing', 'important')
|
|
313
|
-
document.addEventListener('mousemove', this.onThumbDragY)
|
|
314
|
-
document.addEventListener('mouseup', this.onThumbMouseUpY)
|
|
315
|
-
},
|
|
316
|
-
onThumbDragY(e) {
|
|
317
|
-
e.preventDefault()
|
|
318
|
-
e.stopPropagation()
|
|
319
|
-
const state = this.getState()
|
|
320
|
-
|
|
321
|
-
// 仅处理垂直滚动
|
|
322
|
-
this.transientScrollOffsetY += (e.movementY / this.viewportHeight) * state.tableHeight
|
|
323
|
-
if (this.isScrolling) {
|
|
324
|
-
return
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
this.isScrolling = true
|
|
328
|
-
window.requestAnimationFrame(() => {
|
|
329
|
-
this.scrollBy(undefined, this.transientScrollOffsetY) // 仅滚动垂直方向
|
|
330
|
-
this.isScrolling = false
|
|
331
|
-
this.transientScrollOffsetY = 0
|
|
332
|
-
})
|
|
333
|
-
},
|
|
334
|
-
onThumbMouseUpY() {
|
|
335
|
-
document.body.style.removeProperty('cursor')
|
|
336
|
-
document.removeEventListener('mousemove', this.onThumbDragY)
|
|
337
|
-
document.removeEventListener('mouseup', this.onThumbMouseUpY)
|
|
338
|
-
this.isScrolling = false
|
|
339
|
-
if (this.transientScrollOffsetY > 0) {
|
|
340
|
-
this.scrollBy(undefined, this.transientScrollOffsetY)
|
|
341
|
-
}
|
|
342
|
-
this.transientScrollOffsetY = 0
|
|
343
|
-
},
|
|
344
|
-
onThumbMouseDownX(e) {
|
|
345
|
-
e.preventDefault()
|
|
346
|
-
e.stopPropagation()
|
|
347
|
-
document.body.style.setProperty('cursor', 'grabbing', 'important')
|
|
348
|
-
document.addEventListener('mousemove', this.onThumbDragX)
|
|
349
|
-
document.addEventListener('mouseup', this.onThumbMouseUpX)
|
|
350
|
-
},
|
|
351
|
-
onThumbDragX(e) {
|
|
352
|
-
e.stopPropagation()
|
|
353
|
-
e.preventDefault()
|
|
354
|
-
const state = this.getState()
|
|
355
|
-
// 仅处理垂直滚动
|
|
356
|
-
this.transientScrollOffsetX += (e.movementX / this.viewportWidth) * state.tableWidth
|
|
357
|
-
if (this.isScrolling) {
|
|
358
|
-
return
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
this.isScrolling = true
|
|
362
|
-
window.requestAnimationFrame(() => {
|
|
363
|
-
this.scrollBy(this.transientScrollOffsetX, undefined) // 仅滚动水平方向
|
|
364
|
-
this.isScrolling = false
|
|
365
|
-
this.transientScrollOffsetX = 0
|
|
366
|
-
})
|
|
367
|
-
},
|
|
368
|
-
onThumbMouseUpX() {
|
|
369
|
-
document.body.style.removeProperty('cursor')
|
|
370
|
-
document.removeEventListener('mousemove', this.onThumbDragX)
|
|
371
|
-
document.removeEventListener('mouseup', this.onThumbMouseUpX)
|
|
372
|
-
this.isScrolling = false
|
|
373
|
-
if (this.transientScrollOffsetX > 0) {
|
|
374
|
-
this.scrollBy(this.transientScrollOffsetX, undefined)
|
|
375
|
-
}
|
|
376
|
-
this.transientScrollOffsetX = 0
|
|
377
|
-
},
|
|
378
|
-
onTrackMouseMoveY(e) {
|
|
379
|
-
e.preventDefault()
|
|
380
|
-
},
|
|
381
|
-
onTrackMouseMoveX(e) {
|
|
382
|
-
e.preventDefault()
|
|
383
|
-
},
|
|
384
|
-
// 滚动到指定的top值
|
|
385
|
-
scrollToTop(scrollTop = 0) {
|
|
386
|
-
const state = this.getState()
|
|
387
|
-
const relativeOffset = (scrollTop / this.viewportHeight) * state.tableHeight
|
|
388
|
-
this.setScrollOffsetY(relativeOffset)
|
|
389
|
-
this.renderViewportRows()
|
|
390
|
-
},
|
|
391
|
-
onTrackMouseDownY(e) {
|
|
392
|
-
e.preventDefault()
|
|
393
|
-
this.scrollToTop(e.offsetY - this.headerTotalHeight) // 仅滚动垂直方向
|
|
394
|
-
},
|
|
395
|
-
onTrackMouseDownX(e) {
|
|
396
|
-
e.preventDefault()
|
|
397
|
-
this.scrollToLeft(e.offsetX, false) // 仅滚动水平方向
|
|
398
|
-
},
|
|
399
|
-
// 滚动到指定的left值
|
|
400
|
-
scrollToLeft(scrollLeft = 0, createHeader = true) {
|
|
401
|
-
const state = this.getState()
|
|
402
|
-
const relativeOffset = (scrollLeft / this.viewportWidth) * state.tableWidth
|
|
403
|
-
createHeader && this.createHeader()
|
|
404
|
-
this.setScrollOffsetX(relativeOffset)
|
|
405
|
-
this.renderViewportCells()
|
|
406
|
-
},
|
|
407
|
-
translateThumbY(offset) {
|
|
408
|
-
this.$refs.thumbY.style.transform = `translateY(${offset + this.headerTotalHeight}px)`
|
|
409
|
-
},
|
|
410
|
-
translateThumbX(offset) {
|
|
411
|
-
if (this.$refs.thumbX) {
|
|
412
|
-
this.$refs.thumbX.style.transform = `translateX(${offset}px)`
|
|
413
|
-
}
|
|
414
|
-
},
|
|
415
|
-
setThumbSizeY(height) {
|
|
416
|
-
// const _height = height < 0 ? 60 : height
|
|
417
|
-
// TODO 数据超出太多时,此时的滑块高度为负数,需要处理极致情况。
|
|
418
|
-
this.$refs.thumbY.style.height = `${height}px`
|
|
419
|
-
},
|
|
420
|
-
setThumbSizeX(width) {
|
|
421
|
-
this.$refs.thumbX.style.width = `${width}px`
|
|
422
|
-
},
|
|
423
|
-
},
|
|
424
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取元素的 transform 属性值
|
|
3
|
-
* @param {HTMLElement} element - 需要获取 transform 的元素
|
|
4
|
-
* @param {*} element
|
|
5
|
-
* @returns
|
|
6
|
-
*/
|
|
7
|
-
function getMatrixTransform (element) {
|
|
8
|
-
const computedStyle = window.getComputedStyle(element)
|
|
9
|
-
const transformValue = computedStyle.transform
|
|
10
|
-
|
|
11
|
-
if (transformValue && transformValue!== 'none') {
|
|
12
|
-
const matrix = new DOMMatrix(transformValue)
|
|
13
|
-
return matrix.m42
|
|
14
|
-
}
|
|
15
|
-
return 0
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
computed: {
|
|
20
|
-
useStretchFeature() {
|
|
21
|
-
return this.$props.stretchEnabled && !!this.$props.scrollY && this.isHasOffsetY
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
data() {
|
|
25
|
-
return {
|
|
26
|
-
// 是否正在拖动
|
|
27
|
-
isDragging: false,
|
|
28
|
-
// 记录手指开始触摸时的Y坐标
|
|
29
|
-
startY: 0,
|
|
30
|
-
startTime: 0,
|
|
31
|
-
// 当前的translateY值
|
|
32
|
-
currentTranslateY: 0,
|
|
33
|
-
maxTranslateY: 120,
|
|
34
|
-
isMoving: false
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
/**
|
|
39
|
-
* 触摸开始事件处理
|
|
40
|
-
* @param {*} event
|
|
41
|
-
*/
|
|
42
|
-
containerHandleTouchStart(event) {
|
|
43
|
-
if (!this.useStretchFeature) return
|
|
44
|
-
// const touch = event.changedTouches[0]
|
|
45
|
-
this.startY = event.touches[0].clientY
|
|
46
|
-
this.startTime = Date.now()
|
|
47
|
-
this.isMoving = true
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* 仅 y 轴滚动执行
|
|
51
|
-
* @param {*} event
|
|
52
|
-
*/
|
|
53
|
-
containerHandleTouchMove(event) {
|
|
54
|
-
if (!this.useStretchFeature || !this.isMoving) return
|
|
55
|
-
|
|
56
|
-
// const touch = event.changedTouches[0]
|
|
57
|
-
const currentY = event.touches[0].clientY
|
|
58
|
-
const distance = this.startY - currentY
|
|
59
|
-
|
|
60
|
-
// 滚动到底部执行(滚动偏移量 = 表格高度 - 可视口高度)
|
|
61
|
-
if (this.offsetY === (this.state.tableHeight - this.viewportHeight) && distance > 0) {
|
|
62
|
-
|
|
63
|
-
const currentTime = Date.now()
|
|
64
|
-
const duration = currentTime - this.startTime
|
|
65
|
-
|
|
66
|
-
// 计算速度(距离差/时间差)
|
|
67
|
-
const speed = distance / duration
|
|
68
|
-
|
|
69
|
-
// 计算阻尼系数,越接近最大偏移距离阻尼越大
|
|
70
|
-
let damping = 1
|
|
71
|
-
const container = this.$refs.container
|
|
72
|
-
const currentTranslateY = getMatrixTransform(container)
|
|
73
|
-
const remainingDistance = this.maxTranslateY - currentTranslateY
|
|
74
|
-
damping = remainingDistance / this.maxTranslateY
|
|
75
|
-
|
|
76
|
-
// 计算新的 translateY
|
|
77
|
-
let newTranslateY = currentTranslateY + (distance * speed * damping)
|
|
78
|
-
newTranslateY = Math.min(newTranslateY, this.maxTranslateY)
|
|
79
|
-
newTranslateY = Math.max(newTranslateY, 0)
|
|
80
|
-
|
|
81
|
-
container.style.transform = `translateY(${-newTranslateY}px)`
|
|
82
|
-
container.style.transition = 'transform 0.2s ease'
|
|
83
|
-
} else {
|
|
84
|
-
// 如果没有到达底部,重置 translateY
|
|
85
|
-
this.resetStretch()
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* 松开手势时 清空动画数据
|
|
90
|
-
* @param {*} event
|
|
91
|
-
*/
|
|
92
|
-
containerHandleTouchEnd(event) {
|
|
93
|
-
|
|
94
|
-
if (!this.useStretchFeature) return
|
|
95
|
-
|
|
96
|
-
this.resetStretch()
|
|
97
|
-
},
|
|
98
|
-
/**
|
|
99
|
-
* 重置各种参数
|
|
100
|
-
*/
|
|
101
|
-
resetStretch () {
|
|
102
|
-
|
|
103
|
-
this.isMoving = false
|
|
104
|
-
this.startY = 0
|
|
105
|
-
this.startTime = 0
|
|
106
|
-
|
|
107
|
-
const container = this.$refs.container
|
|
108
|
-
container.style.transform = 'translateY(0px)'
|
|
109
|
-
container.style.transition = 'transform 0.3s ease'
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
.pe-table-cell {
|
|
2
|
-
position: absolute;
|
|
3
|
-
left: 0;
|
|
4
|
-
display: flex;
|
|
5
|
-
align-items: center;
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
font-size: 13PX;
|
|
8
|
-
padding: 0 8PX;
|
|
9
|
-
height: 100%;
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
background-color: transparent;
|
|
12
|
-
// transform: translateZ(0);
|
|
13
|
-
// will-change: transform; 单元格会发生偏移
|
|
14
|
-
}
|
|
15
|
-
.ks-multi-screen .pe-table-cell {
|
|
16
|
-
font-size: 14PX !important;
|
|
17
|
-
}
|
|
18
|
-
.pe-table-cell::after {
|
|
19
|
-
content: '';
|
|
20
|
-
position: absolute;
|
|
21
|
-
bottom: 0;
|
|
22
|
-
left: 0;
|
|
23
|
-
width: 100%;
|
|
24
|
-
height: 1px;
|
|
25
|
-
background-color: #F1F1F1;
|
|
26
|
-
transform-origin: bottom;
|
|
27
|
-
transform: scaleY(0.5);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.pe-table-cell.overflow span {
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
white-space: nowrap;
|
|
33
|
-
text-overflow: ellipsis;
|
|
34
|
-
}
|
|
35
|
-
.pe-table-cell_label {
|
|
36
|
-
width: 100%;
|
|
37
|
-
}
|
|
38
|
-
.pe-table-cell.right .pe-table-cell_label {
|
|
39
|
-
text-align: right;
|
|
40
|
-
}
|
|
41
|
-
.pe-table-cell.left .pe-table-cell_label {
|
|
42
|
-
text-align: left;
|
|
43
|
-
}
|
|
44
|
-
.pe-table-cell.center .pe-table-cell_label {
|
|
45
|
-
text-align: center;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.pe-table-cell.collapse-bg {
|
|
49
|
-
// background: rgba(21, 88, 202, 0.04);
|
|
50
|
-
background-color: #F8FAFD;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.pe-table-scrolling__x {
|
|
54
|
-
.pe-table-cell__last-fixed {
|
|
55
|
-
// border-right: none;
|
|
56
|
-
box-shadow: 4px 0 6px -4px rgba(28, 32, 35, 0.1);
|
|
57
|
-
// background-color: #fff;
|
|
58
|
-
}
|
|
59
|
-
.pe-table-cell__fixed {
|
|
60
|
-
background-color: #fff;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.pe-table-header_cell[data-cellkey="$index"] {
|
|
65
|
-
padding-right: 4PX;
|
|
66
|
-
white-space: nowrap;
|
|
67
|
-
}
|
|
68
|
-
.pe-table-cell[data-cellkey="$index"] {
|
|
69
|
-
padding-right: 4PX;
|
|
70
|
-
white-space: nowrap;
|
|
71
|
-
font-size: 12PX;
|
|
72
|
-
}
|
|
73
|
-
.ks-multi-screen {
|
|
74
|
-
.pe-table-cell[data-cellkey="$index"] {
|
|
75
|
-
font-size: 13PX;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
.pe-table-show-index {
|
|
79
|
-
.pe-table-cell[data-cellkey="name"] {
|
|
80
|
-
padding-left: 0;
|
|
81
|
-
padding-right: 2PX;
|
|
82
|
-
.collect-icon-area {
|
|
83
|
-
margin-left: -12PX;
|
|
84
|
-
.collect-icon-wrap {
|
|
85
|
-
padding-left: 8PX;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
.pe-table-empty {
|
|
2
|
-
display: flex;
|
|
3
|
-
width: 100PX;
|
|
4
|
-
// height: 118PX;
|
|
5
|
-
flex-direction: column;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
align-items: center;
|
|
8
|
-
position: absolute;
|
|
9
|
-
// top: 40PX;
|
|
10
|
-
left: 50%;
|
|
11
|
-
transform: translateX(-50%)
|
|
12
|
-
}
|
|
13
|
-
.pe-table-empty_label {
|
|
14
|
-
margin-top: 12PX;
|
|
15
|
-
color: #888B92;
|
|
16
|
-
font-size: 13PX;
|
|
17
|
-
line-height: 1;
|
|
18
|
-
}
|
|
19
|
-
.pe-table-empty_bg {
|
|
20
|
-
width: 100PX;
|
|
21
|
-
height: 80PX;
|
|
22
|
-
background: url('../images/empty.png');
|
|
23
|
-
background-size: contain;
|
|
24
|
-
}
|
|
25
|
-
.abnormal {
|
|
26
|
-
width: 130PX;
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-direction: column;
|
|
29
|
-
align-items: center;
|
|
30
|
-
.abnormal-img {
|
|
31
|
-
width: 108PX;
|
|
32
|
-
height: 69PX;
|
|
33
|
-
margin-bottom: 10PX;
|
|
34
|
-
font-size: 0;
|
|
35
|
-
background: url('../images/abnormal.png');
|
|
36
|
-
background-size: 108PX 69PX;
|
|
37
|
-
background-repeat: no-repeat;
|
|
38
|
-
}
|
|
39
|
-
.abnormal-desc {
|
|
40
|
-
margin-bottom: 8PX;
|
|
41
|
-
font-size: 12PX;
|
|
42
|
-
font-weight: normal;
|
|
43
|
-
line-height: 18PX;
|
|
44
|
-
text-align: center;
|
|
45
|
-
letter-spacing: 0em;
|
|
46
|
-
color: #888B92;
|
|
47
|
-
}
|
|
48
|
-
}
|