vxe-table 3.9.21 → 3.10.0-beta.1
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/es/locale/lang/ja-JP.js +5 -5
- package/es/locale/lang/ko-KR.js +5 -5
- package/es/locale/lang/uk-UA.js +5 -5
- package/es/locale/lang/vi-VN.js +5 -5
- package/es/locale/lang/zh-CHT.js +5 -5
- package/es/locale/lang/zh-CN.js +5 -5
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/edit/mixin.js +3 -3
- package/es/table/src/body.js +53 -115
- package/es/table/src/footer.js +24 -21
- package/es/table/src/methods.js +392 -123
- package/es/table/src/props.js +2 -0
- package/es/table/src/table.js +71 -10
- package/es/table/src/util.js +58 -33
- package/es/table/style.css +47 -7
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +2 -2
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +47 -7
- package/es/vxe-table/style.min.css +1 -1
- package/lib/index.umd.js +682 -361
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ja-JP.js +5 -5
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +5 -5
- package/lib/locale/lang/ko-KR.js +5 -5
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +5 -5
- package/lib/locale/lang/uk-UA.js +5 -5
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +5 -5
- package/lib/locale/lang/vi-VN.js +5 -5
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +5 -5
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +5 -5
- package/lib/locale/lang/zh-CN.js +5 -5
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +5 -5
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/edit/mixin.js +6 -3
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/src/body.js +54 -118
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/footer.js +24 -33
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/methods.js +449 -148
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +2 -0
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +64 -13
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +72 -38
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +47 -7
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +47 -7
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/locale/lang/ja-JP.ts +5 -5
- package/packages/locale/lang/ko-KR.ts +5 -5
- package/packages/locale/lang/uk-UA.ts +5 -5
- package/packages/locale/lang/vi-VN.ts +5 -5
- package/packages/locale/lang/zh-CHT.ts +5 -5
- package/packages/locale/lang/zh-CN.ts +5 -5
- package/packages/table/module/edit/mixin.ts +3 -3
- package/packages/table/src/body.ts +53 -118
- package/packages/table/src/footer.ts +24 -22
- package/packages/table/src/methods.ts +418 -127
- package/packages/table/src/props.ts +10 -8
- package/packages/table/src/table.ts +73 -10
- package/packages/table/src/util.ts +61 -36
- package/packages/ui/index.ts +1 -1
- package/styles/components/table-module/filter.scss +1 -1
- package/styles/components/table.scss +46 -13
- package/styles/modules.scss +0 -2
- package/styles/theme/base.scss +1 -1
- package/styles/theme/dark.scss +7 -4
- package/styles/variable.scss +5 -1
- /package/es/{iconfont.1729992873866.ttf → iconfont.1730364042434.ttf} +0 -0
- /package/es/{iconfont.1729992873866.woff → iconfont.1730364042434.woff} +0 -0
- /package/es/{iconfont.1729992873866.woff2 → iconfont.1730364042434.woff2} +0 -0
- /package/lib/{iconfont.1729992873866.ttf → iconfont.1730364042434.ttf} +0 -0
- /package/lib/{iconfont.1729992873866.woff → iconfont.1730364042434.woff} +0 -0
- /package/lib/{iconfont.1729992873866.woff2 → iconfont.1730364042434.woff2} +0 -0
|
@@ -3,13 +3,13 @@ import { browse, isPx, isScale, hasClass, addClass, removeClass, getEventTargetN
|
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
5
|
import Cell from './cell'
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation,
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn } from './util'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
9
9
|
|
|
10
|
-
import type { VxeTableDefines } from '../../../types'
|
|
10
|
+
import type { VxeTableDefines, VxeTableEmits, ValueOf } from '../../../types'
|
|
11
11
|
|
|
12
|
-
const { getConfig, getI18n, renderer, formats, interceptor } = VxeUI
|
|
12
|
+
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
|
|
13
13
|
|
|
14
14
|
const isWebkit = browse['-webkit'] && !browse.edge
|
|
15
15
|
const debounceScrollYDuration = browse.msie ? 80 : 20
|
|
@@ -81,7 +81,7 @@ function handleReserveRow (_vm: any, reserveRowMap: any) {
|
|
|
81
81
|
return reserveList
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
function
|
|
84
|
+
function handleVirtualXVisible (_vm: any) {
|
|
85
85
|
const { $refs, visibleColumn } = _vm
|
|
86
86
|
const { tableBody } = $refs
|
|
87
87
|
const tableBodyElem = tableBody ? tableBody.$el : null
|
|
@@ -108,14 +108,16 @@ function computeVirtualX (_vm: any) {
|
|
|
108
108
|
return { toVisibleIndex: 0, visibleSize: 6 }
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
const { $refs, computeSize
|
|
113
|
-
const
|
|
114
|
-
const
|
|
111
|
+
const computeRowHeight = ($xeTable: any) => {
|
|
112
|
+
const { $refs, computeSize } = $xeTable
|
|
113
|
+
const tableHeader = $refs.tableHeader
|
|
114
|
+
const tableBody = $refs.tableBody
|
|
115
|
+
const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
|
|
115
116
|
const vSize = computeSize
|
|
117
|
+
const rowHeightMaps = $xeTable.rowHeightMaps
|
|
118
|
+
let rowHeight = 0
|
|
116
119
|
if (tableBodyElem) {
|
|
117
|
-
const tableHeaderElem = tableHeader ? tableHeader.$el : null
|
|
118
|
-
let rowHeight = 0
|
|
120
|
+
const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
|
|
119
121
|
let firstTrElem
|
|
120
122
|
firstTrElem = tableBodyElem.querySelector('tr')
|
|
121
123
|
if (!firstTrElem && tableHeaderElem) {
|
|
@@ -127,10 +129,42 @@ function computeVirtualY (_vm: any) {
|
|
|
127
129
|
if (!rowHeight) {
|
|
128
130
|
rowHeight = rowHeightMaps[vSize || 'default']
|
|
129
131
|
}
|
|
130
|
-
const visibleSize = Math.max(8, Math.ceil(tableBodyElem.clientHeight / rowHeight) + 2)
|
|
131
|
-
return { rowHeight, visibleSize }
|
|
132
132
|
}
|
|
133
|
-
return
|
|
133
|
+
return rowHeight
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function handleVirtualYVisible ($xeTable: any) {
|
|
137
|
+
const { $refs, scrollYStore, afterFullData, fullAllDataRowIdData } = $xeTable
|
|
138
|
+
const tableBody: any = $refs.tableBody
|
|
139
|
+
const tableBodyElem = tableBody ? tableBody.$el : null
|
|
140
|
+
const { rowHeight } = scrollYStore
|
|
141
|
+
if (tableBodyElem) {
|
|
142
|
+
const { scrollTop, clientHeight } = tableBodyElem
|
|
143
|
+
const endHeight = scrollTop + clientHeight
|
|
144
|
+
let toVisibleIndex = -1
|
|
145
|
+
let offsetTop = 0
|
|
146
|
+
let visibleSize = 0
|
|
147
|
+
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
148
|
+
const row = afterFullData[rIndex]
|
|
149
|
+
const rowid = getRowid($xeTable, row)
|
|
150
|
+
const rest = fullAllDataRowIdData[rowid]
|
|
151
|
+
if (!rest) {
|
|
152
|
+
break
|
|
153
|
+
}
|
|
154
|
+
offsetTop += rest.height || rowHeight
|
|
155
|
+
if (toVisibleIndex === -1 && scrollTop < offsetTop) {
|
|
156
|
+
toVisibleIndex = rIndex
|
|
157
|
+
}
|
|
158
|
+
if (toVisibleIndex >= 0) {
|
|
159
|
+
visibleSize++
|
|
160
|
+
if (offsetTop > endHeight) {
|
|
161
|
+
break
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(8, visibleSize) }
|
|
166
|
+
}
|
|
167
|
+
return { toVisibleIndex: 0, visibleSize: 8 }
|
|
134
168
|
}
|
|
135
169
|
|
|
136
170
|
function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
@@ -234,7 +268,7 @@ function clearAllSort (_vm: any) {
|
|
|
234
268
|
})
|
|
235
269
|
}
|
|
236
270
|
|
|
237
|
-
function
|
|
271
|
+
function calcTableHeight (_vm: any, key: 'height' | 'minHeight' | 'maxHeight') {
|
|
238
272
|
const { parentHeight } = _vm
|
|
239
273
|
const val = _vm[key]
|
|
240
274
|
let num = 0
|
|
@@ -254,6 +288,26 @@ function calcHeight (_vm: any, key: 'height' | 'minHeight' | 'maxHeight') {
|
|
|
254
288
|
return num
|
|
255
289
|
}
|
|
256
290
|
|
|
291
|
+
const calcCellHeight = ($xeTable: any) => {
|
|
292
|
+
const { tableData, scrollYLoad, fullAllDataRowIdData } = $xeTable
|
|
293
|
+
const el = $xeTable.$el
|
|
294
|
+
if (scrollYLoad && el) {
|
|
295
|
+
tableData.forEach((row: any) => {
|
|
296
|
+
const rowid = getRowid($xeTable, row)
|
|
297
|
+
const rest = fullAllDataRowIdData[rowid]
|
|
298
|
+
const trList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]`)
|
|
299
|
+
if (rest && trList.length) {
|
|
300
|
+
let height = 0
|
|
301
|
+
for (let i = 0; i < trList.length; i++) {
|
|
302
|
+
const trEl = trList[i] as HTMLTableRowElement
|
|
303
|
+
height = Math.max(height, trEl.offsetHeight)
|
|
304
|
+
}
|
|
305
|
+
rest.height = height
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
257
311
|
function getOrderField (_vm: any, column: any) {
|
|
258
312
|
const { sortBy, sortType } = column
|
|
259
313
|
return (row: any) => {
|
|
@@ -456,9 +510,9 @@ const Methods = {
|
|
|
456
510
|
if (!(this.height || this.maxHeight)) {
|
|
457
511
|
errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}'])
|
|
458
512
|
}
|
|
459
|
-
if (!this.showOverflow) {
|
|
460
|
-
|
|
461
|
-
}
|
|
513
|
+
// if (!this.showOverflow) {
|
|
514
|
+
// warnLog('vxe.error.reqProp', ['table.show-overflow'])
|
|
515
|
+
// }
|
|
462
516
|
if (this.spanMethod) {
|
|
463
517
|
warnLog('vxe.error.scrollErrProp', ['table.span-method'])
|
|
464
518
|
}
|
|
@@ -672,7 +726,7 @@ const Methods = {
|
|
|
672
726
|
}
|
|
673
727
|
let cacheItem = fullAllDataRowIdData[rowid]
|
|
674
728
|
if (!cacheItem) {
|
|
675
|
-
cacheItem = { row, rowid, seq, index: -1, _index: -1, $index: -1, items, parent, level }
|
|
729
|
+
cacheItem = { row, rowid, seq, index: -1, _index: -1, $index: -1, items, parent, level, height: 0 }
|
|
676
730
|
}
|
|
677
731
|
if (isSource) {
|
|
678
732
|
cacheItem.index = treeConfig && parent ? -1 : index
|
|
@@ -741,7 +795,7 @@ const Methods = {
|
|
|
741
795
|
XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
|
|
742
796
|
const rowid = getRowid($xeTable, childRow)
|
|
743
797
|
const parentRow = parent || parentRest.row
|
|
744
|
-
const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, items, parent: parentRow, level: parentLevel + nodes.length }
|
|
798
|
+
const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0 }
|
|
745
799
|
fullDataRowIdData[rowid] = rest
|
|
746
800
|
fullAllDataRowIdData[rowid] = rest
|
|
747
801
|
}, { children: childrenField })
|
|
@@ -771,7 +825,7 @@ const Methods = {
|
|
|
771
825
|
let hasFixed: any
|
|
772
826
|
const handleFunc = (column: any, index: any, items: any, path: any, parent: any) => {
|
|
773
827
|
const { id: colid, field, fixed, type, treeNode } = column
|
|
774
|
-
const rest = { column, colid, index, items, parent }
|
|
828
|
+
const rest = { column, colid, index, items, parent: parent || null, width: 0 }
|
|
775
829
|
if (field) {
|
|
776
830
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
777
831
|
if (fullColumnFieldData[field]) {
|
|
@@ -885,9 +939,15 @@ const Methods = {
|
|
|
885
939
|
if (tr) {
|
|
886
940
|
const { fullAllDataRowIdData } = this
|
|
887
941
|
const rowid = tr.getAttribute('rowid')
|
|
888
|
-
const
|
|
889
|
-
if (
|
|
890
|
-
return {
|
|
942
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
943
|
+
if (rowRest) {
|
|
944
|
+
return {
|
|
945
|
+
rowid: rowRest.rowid,
|
|
946
|
+
item: rowRest.row,
|
|
947
|
+
index: rowRest.index,
|
|
948
|
+
items: rowRest.items,
|
|
949
|
+
parent: rowRest.parent
|
|
950
|
+
}
|
|
891
951
|
}
|
|
892
952
|
}
|
|
893
953
|
return null
|
|
@@ -900,9 +960,17 @@ const Methods = {
|
|
|
900
960
|
if (cell) {
|
|
901
961
|
const { fullColumnIdData } = this
|
|
902
962
|
const colid = cell.getAttribute('colid')
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
963
|
+
if (colid) {
|
|
964
|
+
const colRest = fullColumnIdData[colid]
|
|
965
|
+
if (colRest) {
|
|
966
|
+
return {
|
|
967
|
+
colid: colRest.colid,
|
|
968
|
+
item: colRest.column,
|
|
969
|
+
index: colRest.index,
|
|
970
|
+
items: colRest.items,
|
|
971
|
+
parent: colRest.parent
|
|
972
|
+
}
|
|
973
|
+
}
|
|
906
974
|
}
|
|
907
975
|
}
|
|
908
976
|
return null
|
|
@@ -1215,13 +1283,13 @@ const Methods = {
|
|
|
1215
1283
|
const { fullAllDataRowIdData } = $xeTable
|
|
1216
1284
|
const rowid = getRowid($xeTable, row)
|
|
1217
1285
|
const colid = column.id
|
|
1218
|
-
const
|
|
1219
|
-
if (
|
|
1220
|
-
formatData =
|
|
1286
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1287
|
+
if (rowRest) {
|
|
1288
|
+
formatData = rowRest.formatData
|
|
1221
1289
|
if (!formatData) {
|
|
1222
1290
|
formatData = fullAllDataRowIdData[rowid].formatData = {}
|
|
1223
1291
|
}
|
|
1224
|
-
if (
|
|
1292
|
+
if (rowRest && formatData[colid]) {
|
|
1225
1293
|
if (formatData[colid].value === cellValue) {
|
|
1226
1294
|
return formatData[colid].label
|
|
1227
1295
|
}
|
|
@@ -1534,13 +1602,13 @@ const Methods = {
|
|
|
1534
1602
|
if (treeConfig) {
|
|
1535
1603
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
1536
1604
|
const rowid = getRowid(this, row)
|
|
1537
|
-
const
|
|
1605
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1538
1606
|
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
1539
|
-
if (
|
|
1540
|
-
|
|
1541
|
-
|
|
1607
|
+
if (rowRest) {
|
|
1608
|
+
rowRest.seq = seq
|
|
1609
|
+
rowRest._index = index
|
|
1542
1610
|
} else {
|
|
1543
|
-
const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1611
|
+
const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0 }
|
|
1544
1612
|
fullAllDataRowIdData[rowid] = rest
|
|
1545
1613
|
fullDataRowIdData[rowid] = rest
|
|
1546
1614
|
}
|
|
@@ -1549,13 +1617,13 @@ const Methods = {
|
|
|
1549
1617
|
} else {
|
|
1550
1618
|
afterFullData.forEach((row: any, index: any) => {
|
|
1551
1619
|
const rowid = getRowid(this, row)
|
|
1552
|
-
const
|
|
1620
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1553
1621
|
const seq = index + 1
|
|
1554
|
-
if (
|
|
1555
|
-
|
|
1556
|
-
|
|
1622
|
+
if (rowRest) {
|
|
1623
|
+
rowRest.seq = seq
|
|
1624
|
+
rowRest._index = index
|
|
1557
1625
|
} else {
|
|
1558
|
-
const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0 }
|
|
1626
|
+
const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, items: [], parent: null, level: 0, height: 0 }
|
|
1559
1627
|
fullAllDataRowIdData[rowid] = rest
|
|
1560
1628
|
fullDataRowIdData[rowid] = rest
|
|
1561
1629
|
}
|
|
@@ -2062,7 +2130,7 @@ const Methods = {
|
|
|
2062
2130
|
warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
|
|
2063
2131
|
}
|
|
2064
2132
|
}
|
|
2065
|
-
const { visibleSize } =
|
|
2133
|
+
const { visibleSize } = handleVirtualXVisible(this)
|
|
2066
2134
|
scrollXStore.startIndex = 0
|
|
2067
2135
|
scrollXStore.endIndex = visibleSize
|
|
2068
2136
|
scrollXStore.visibleSize = visibleSize
|
|
@@ -2076,9 +2144,9 @@ const Methods = {
|
|
|
2076
2144
|
this.scrollXLoad = scrollXLoad
|
|
2077
2145
|
visibleColumn.forEach((column, index) => {
|
|
2078
2146
|
const colid = column.id
|
|
2079
|
-
const
|
|
2080
|
-
if (
|
|
2081
|
-
|
|
2147
|
+
const colRest = fullColumnIdData[colid]
|
|
2148
|
+
if (colRest) {
|
|
2149
|
+
colRest._index = index
|
|
2082
2150
|
}
|
|
2083
2151
|
})
|
|
2084
2152
|
this.visibleColumn = visibleColumn
|
|
@@ -2165,30 +2233,27 @@ const Methods = {
|
|
|
2165
2233
|
* 计算单元格列宽,动态分配可用剩余空间
|
|
2166
2234
|
* 支持 width=? width=?px width=?% min-width=? min-width=?px min-width=?%
|
|
2167
2235
|
*/
|
|
2168
|
-
recalculate (
|
|
2169
|
-
const { $refs } = this
|
|
2170
|
-
const { tableBody, tableHeader, tableFooter } = $refs
|
|
2171
|
-
const bodyElem = tableBody ? tableBody.$el : null
|
|
2172
|
-
const headerElem = tableHeader ? tableHeader.$el : null
|
|
2173
|
-
const footerElem = tableFooter ? tableFooter.$el : null
|
|
2236
|
+
recalculate (reFull?: boolean) {
|
|
2174
2237
|
const el = this.$el
|
|
2175
2238
|
if (!el || !el.clientWidth) {
|
|
2176
2239
|
return this.$nextTick()
|
|
2177
2240
|
}
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
}
|
|
2241
|
+
calcCellHeight(this)
|
|
2242
|
+
this.calcCellWidth()
|
|
2243
|
+
this.autoCellWidth()
|
|
2244
|
+
if (reFull === true) {
|
|
2245
|
+
// 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
|
|
2246
|
+
return this.computeScrollLoad().then(() => {
|
|
2247
|
+
calcCellHeight(this)
|
|
2248
|
+
this.autoCellWidth()
|
|
2249
|
+
return this.computeScrollLoad()
|
|
2250
|
+
})
|
|
2188
2251
|
}
|
|
2189
2252
|
return this.computeScrollLoad()
|
|
2190
2253
|
},
|
|
2191
2254
|
calcCellWidth () {
|
|
2255
|
+
const $xeTable = this
|
|
2256
|
+
|
|
2192
2257
|
const { autoWidthColumnList, tableData } = this
|
|
2193
2258
|
if (!tableData.length || !autoWidthColumnList.length) {
|
|
2194
2259
|
this.isCalcColumn = false
|
|
@@ -2196,9 +2261,14 @@ const Methods = {
|
|
|
2196
2261
|
}
|
|
2197
2262
|
this.isCalcColumn = true
|
|
2198
2263
|
return this.$nextTick().then(() => {
|
|
2264
|
+
const internalData = $xeTable
|
|
2265
|
+
|
|
2266
|
+
const { fullColumnIdData } = internalData
|
|
2199
2267
|
const el = this.$el
|
|
2200
2268
|
if (el) {
|
|
2201
2269
|
autoWidthColumnList.forEach((column: any) => {
|
|
2270
|
+
const colid = column.id
|
|
2271
|
+
const colRest = fullColumnIdData[colid]
|
|
2202
2272
|
const cellElList = el.querySelectorAll(`.vxe-header--column.${column.id}>.vxe-cell,.vxe-body--column.${column.id}>.vxe-cell,.vxe-footer--column.${column.id}>.vxe-cell`)
|
|
2203
2273
|
const firstCellEl = cellElList[0]
|
|
2204
2274
|
let paddingSize = 0
|
|
@@ -2225,6 +2295,9 @@ const Methods = {
|
|
|
2225
2295
|
colWidth = Math.max(colWidth, Math.ceil(titleWidth) + 4)
|
|
2226
2296
|
}
|
|
2227
2297
|
})
|
|
2298
|
+
if (colRest) {
|
|
2299
|
+
colRest.width = Math.max(colWidth, colRest.width)
|
|
2300
|
+
}
|
|
2228
2301
|
column.renderAutoWidth = colWidth + paddingSize
|
|
2229
2302
|
})
|
|
2230
2303
|
this.analyColumnWidth()
|
|
@@ -2237,12 +2310,14 @@ const Methods = {
|
|
|
2237
2310
|
* 支持 px、%、固定 混合分配
|
|
2238
2311
|
* 支持动态列表调整分配
|
|
2239
2312
|
* 支持自动分配偏移量
|
|
2240
|
-
* @param {Element} headerElem
|
|
2241
|
-
* @param {Element} bodyElem
|
|
2242
|
-
* @param {Element} footerElem
|
|
2243
|
-
* @param {Number} bodyWidth
|
|
2244
2313
|
*/
|
|
2245
|
-
autoCellWidth (
|
|
2314
|
+
autoCellWidth () {
|
|
2315
|
+
const { $refs } = this
|
|
2316
|
+
const { tableBody, tableHeader, tableFooter } = $refs
|
|
2317
|
+
const bodyElem = tableBody ? tableBody.$el : null
|
|
2318
|
+
const headerElem = tableHeader ? tableHeader.$el : null
|
|
2319
|
+
const footerElem = tableFooter ? tableFooter.$el : null
|
|
2320
|
+
|
|
2246
2321
|
let tableWidth = 0
|
|
2247
2322
|
const minCellWidth = 40 // 列宽最少限制 40px
|
|
2248
2323
|
const bodyWidth = bodyElem.clientWidth - 1
|
|
@@ -2365,12 +2440,38 @@ const Methods = {
|
|
|
2365
2440
|
this.checkScrolling()
|
|
2366
2441
|
}
|
|
2367
2442
|
},
|
|
2443
|
+
calcCellHeight () {
|
|
2444
|
+
const $xeTable = this
|
|
2445
|
+
const reactData = $xeTable
|
|
2446
|
+
const internalData = $xeTable
|
|
2447
|
+
|
|
2448
|
+
const { tableData, scrollYLoad } = reactData
|
|
2449
|
+
const { fullAllDataRowIdData } = internalData
|
|
2450
|
+
const el = $xeTable.$el
|
|
2451
|
+
if (scrollYLoad && el) {
|
|
2452
|
+
tableData.forEach((row: any) => {
|
|
2453
|
+
const rowid = getRowid($xeTable, row)
|
|
2454
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
2455
|
+
const trList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]`)
|
|
2456
|
+
if (rowRest && trList.length) {
|
|
2457
|
+
let height = 0
|
|
2458
|
+
for (let i = 0; i < trList.length; i++) {
|
|
2459
|
+
const trEl = trList[i] as HTMLTableRowElement
|
|
2460
|
+
height = Math.max(height, trEl.offsetHeight)
|
|
2461
|
+
}
|
|
2462
|
+
rowRest.height = height
|
|
2463
|
+
}
|
|
2464
|
+
})
|
|
2465
|
+
}
|
|
2466
|
+
},
|
|
2368
2467
|
updateHeight () {
|
|
2369
|
-
this.customHeight =
|
|
2370
|
-
this.customMinHeight =
|
|
2371
|
-
this.customMaxHeight =
|
|
2468
|
+
this.customHeight = calcTableHeight(this, 'height')
|
|
2469
|
+
this.customMinHeight = calcTableHeight(this, 'minHeight')
|
|
2470
|
+
this.customMaxHeight = calcTableHeight(this, 'maxHeight')
|
|
2372
2471
|
},
|
|
2373
2472
|
updateStyle () {
|
|
2473
|
+
const $xeTable = this
|
|
2474
|
+
|
|
2374
2475
|
let {
|
|
2375
2476
|
$refs,
|
|
2376
2477
|
isGroup,
|
|
@@ -2392,6 +2493,7 @@ const Methods = {
|
|
|
2392
2493
|
scrollbarWidth,
|
|
2393
2494
|
scrollXLoad,
|
|
2394
2495
|
scrollYLoad,
|
|
2496
|
+
overflowX,
|
|
2395
2497
|
cellOffsetWidth,
|
|
2396
2498
|
columnStore,
|
|
2397
2499
|
elemStore,
|
|
@@ -2406,7 +2508,7 @@ const Methods = {
|
|
|
2406
2508
|
footerSpanMethod,
|
|
2407
2509
|
isAllOverflow,
|
|
2408
2510
|
visibleColumn
|
|
2409
|
-
} =
|
|
2511
|
+
} = $xeTable
|
|
2410
2512
|
const containerList = ['main', 'left', 'right']
|
|
2411
2513
|
const emptyPlaceholderElem = $refs.emptyPlaceholder
|
|
2412
2514
|
const bodyWrapperElem = elemStore['main-body-wrapper']
|
|
@@ -2419,6 +2521,33 @@ const Methods = {
|
|
|
2419
2521
|
customHeight += scrollbarHeight
|
|
2420
2522
|
}
|
|
2421
2523
|
}
|
|
2524
|
+
|
|
2525
|
+
const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem
|
|
2526
|
+
if (scrollXVirtualEl) {
|
|
2527
|
+
scrollXVirtualEl.style.height = `${scrollbarHeight}px`
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem
|
|
2531
|
+
if (scrollYVirtualEl) {
|
|
2532
|
+
let bodyHeight = 0
|
|
2533
|
+
let bodyMaxHeight = 0
|
|
2534
|
+
const bodyMinHeight = customMinHeight - headerHeight - footerHeight
|
|
2535
|
+
if (customMaxHeight) {
|
|
2536
|
+
bodyMaxHeight = customMaxHeight - headerHeight - footerHeight
|
|
2537
|
+
bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight)
|
|
2538
|
+
}
|
|
2539
|
+
if (customHeight) {
|
|
2540
|
+
bodyHeight = customHeight - headerHeight - footerHeight
|
|
2541
|
+
if (bodyMaxHeight) {
|
|
2542
|
+
bodyHeight = Math.min(bodyMaxHeight, bodyHeight)
|
|
2543
|
+
}
|
|
2544
|
+
bodyHeight = Math.max(bodyMinHeight, bodyHeight)
|
|
2545
|
+
}
|
|
2546
|
+
scrollYVirtualEl.style.top = `${headerHeight}px`
|
|
2547
|
+
scrollYVirtualEl.style.width = `${scrollbarWidth}px`
|
|
2548
|
+
scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2422
2551
|
containerList.forEach((name, index) => {
|
|
2423
2552
|
const fixedType = index > 0 ? name : ''
|
|
2424
2553
|
const layoutList = ['header', 'body', 'footer']
|
|
@@ -2592,7 +2721,8 @@ const Methods = {
|
|
|
2592
2721
|
colElem.style.width = `${scrollbarWidth}px`
|
|
2593
2722
|
}
|
|
2594
2723
|
if (fullColumnIdData[colid]) {
|
|
2595
|
-
const
|
|
2724
|
+
const colRest = fullColumnIdData[colid]
|
|
2725
|
+
const column = colRest.column
|
|
2596
2726
|
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column
|
|
2597
2727
|
let cellOverflow
|
|
2598
2728
|
colElem.style.width = `${column.renderWidth}px`
|
|
@@ -2654,18 +2784,22 @@ const Methods = {
|
|
|
2654
2784
|
* 处理固定列的显示状态
|
|
2655
2785
|
*/
|
|
2656
2786
|
checkScrolling () {
|
|
2657
|
-
const
|
|
2787
|
+
const $xeTable = this
|
|
2788
|
+
|
|
2789
|
+
const { tableBody, leftContainer, rightContainer } = $xeTable.$refs
|
|
2658
2790
|
const bodyElem = tableBody ? tableBody.$el : null
|
|
2659
|
-
|
|
2791
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem
|
|
2792
|
+
const bodtTargetEl = xHandleEl || bodyElem
|
|
2793
|
+
if (bodtTargetEl) {
|
|
2660
2794
|
if (leftContainer) {
|
|
2661
|
-
if (
|
|
2795
|
+
if (bodtTargetEl.scrollLeft > 0) {
|
|
2662
2796
|
addClass(leftContainer, 'scrolling--middle')
|
|
2663
2797
|
} else {
|
|
2664
2798
|
removeClass(leftContainer, 'scrolling--middle')
|
|
2665
2799
|
}
|
|
2666
2800
|
}
|
|
2667
2801
|
if (rightContainer) {
|
|
2668
|
-
if (
|
|
2802
|
+
if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
|
|
2669
2803
|
addClass(rightContainer, 'scrolling--middle')
|
|
2670
2804
|
} else {
|
|
2671
2805
|
removeClass(rightContainer, 'scrolling--middle')
|
|
@@ -4602,8 +4736,8 @@ const Methods = {
|
|
|
4602
4736
|
const $xeTable = this
|
|
4603
4737
|
|
|
4604
4738
|
const { fullAllDataRowIdData } = this
|
|
4605
|
-
const
|
|
4606
|
-
return
|
|
4739
|
+
const rowRest = fullAllDataRowIdData[getRowid($xeTable, row)]
|
|
4740
|
+
return rowRest && !!rowRest.expandLoaded
|
|
4607
4741
|
},
|
|
4608
4742
|
clearRowExpandLoaded (row: any) {
|
|
4609
4743
|
const $xeTable = this
|
|
@@ -4611,9 +4745,9 @@ const Methods = {
|
|
|
4611
4745
|
const { expandOpts, rowExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
4612
4746
|
const { lazy } = expandOpts
|
|
4613
4747
|
const rowid = getRowid($xeTable, row)
|
|
4614
|
-
const
|
|
4615
|
-
if (lazy &&
|
|
4616
|
-
|
|
4748
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
4749
|
+
if (lazy && rowRest) {
|
|
4750
|
+
rowRest.expandLoaded = false
|
|
4617
4751
|
const rowTempExpandLazyLoadedMaps = { ...rowExpandLazyLoadedMaps }
|
|
4618
4752
|
if (rowTempExpandLazyLoadedMaps[rowid]) {
|
|
4619
4753
|
delete rowTempExpandLazyLoadedMaps[rowid]
|
|
@@ -4713,14 +4847,14 @@ const Methods = {
|
|
|
4713
4847
|
if (loadMethod) {
|
|
4714
4848
|
const { rowExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
4715
4849
|
const rowid = getRowid($xeTable, row)
|
|
4716
|
-
const
|
|
4850
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
4717
4851
|
rowExpandLazyLoadedMaps[rowid] = row
|
|
4718
4852
|
loadMethod({ $table: $xeTable, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) }).then(() => {
|
|
4719
4853
|
const { rowExpandedMaps } = this
|
|
4720
|
-
|
|
4854
|
+
rowRest.expandLoaded = true
|
|
4721
4855
|
rowExpandedMaps[rowid] = row
|
|
4722
4856
|
}).catch(() => {
|
|
4723
|
-
|
|
4857
|
+
rowRest.expandLoaded = false
|
|
4724
4858
|
}).finally(() => {
|
|
4725
4859
|
const { rowExpandLazyLoadedMaps } = this
|
|
4726
4860
|
if (rowExpandLazyLoadedMaps[rowid]) {
|
|
@@ -4761,8 +4895,8 @@ const Methods = {
|
|
|
4761
4895
|
validRows.forEach((row: any) => {
|
|
4762
4896
|
const rowid = getRowid(this, row)
|
|
4763
4897
|
if (!rExpandedMaps[rowid]) {
|
|
4764
|
-
const
|
|
4765
|
-
const isLoad = lazy && !
|
|
4898
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
4899
|
+
const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
4766
4900
|
if (isLoad) {
|
|
4767
4901
|
lazyRests.push(this.handleAsyncRowExpand(row))
|
|
4768
4902
|
} else {
|
|
@@ -4871,8 +5005,8 @@ const Methods = {
|
|
|
4871
5005
|
const $xeTable = this
|
|
4872
5006
|
|
|
4873
5007
|
const { fullAllDataRowIdData } = this
|
|
4874
|
-
const
|
|
4875
|
-
return
|
|
5008
|
+
const rowRest = fullAllDataRowIdData[getRowid($xeTable, row)]
|
|
5009
|
+
return rowRest && !!rowRest.treeLoaded
|
|
4876
5010
|
},
|
|
4877
5011
|
clearTreeExpandLoaded (row: any) {
|
|
4878
5012
|
const $xeTable = this
|
|
@@ -4880,9 +5014,9 @@ const Methods = {
|
|
|
4880
5014
|
const { treeOpts, treeExpandedMaps, fullAllDataRowIdData } = this
|
|
4881
5015
|
const { transform, lazy } = treeOpts
|
|
4882
5016
|
const rowid = getRowid($xeTable, row)
|
|
4883
|
-
const
|
|
4884
|
-
if (lazy &&
|
|
4885
|
-
|
|
5017
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
5018
|
+
if (lazy && rowRest) {
|
|
5019
|
+
rowRest.treeLoaded = false
|
|
4886
5020
|
if (treeExpandedMaps[rowid]) {
|
|
4887
5021
|
delete treeExpandedMaps[rowid]
|
|
4888
5022
|
}
|
|
@@ -4982,12 +5116,12 @@ const Methods = {
|
|
|
4982
5116
|
if (loadMethod) {
|
|
4983
5117
|
const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
4984
5118
|
const rowid = getRowid($xeTable, row)
|
|
4985
|
-
const
|
|
5119
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
4986
5120
|
treeExpandLazyLoadedMaps[rowid] = row
|
|
4987
5121
|
Promise.resolve(
|
|
4988
5122
|
loadMethod({ $table: $xeTable, row })
|
|
4989
5123
|
).then((childRecords: any) => {
|
|
4990
|
-
|
|
5124
|
+
rowRest.treeLoaded = true
|
|
4991
5125
|
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
4992
5126
|
delete treeExpandLazyLoadedMaps[rowid]
|
|
4993
5127
|
}
|
|
@@ -5013,7 +5147,7 @@ const Methods = {
|
|
|
5013
5147
|
}
|
|
5014
5148
|
}).catch(() => {
|
|
5015
5149
|
const { treeExpandLazyLoadedMaps } = this
|
|
5016
|
-
|
|
5150
|
+
rowRest.treeLoaded = false
|
|
5017
5151
|
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
5018
5152
|
delete treeExpandLazyLoadedMaps[rowid]
|
|
5019
5153
|
}
|
|
@@ -5075,8 +5209,8 @@ const Methods = {
|
|
|
5075
5209
|
validRows.forEach((row: any) => {
|
|
5076
5210
|
const rowid = getRowid(this, row)
|
|
5077
5211
|
if (!treeTempExpandedMaps[rowid]) {
|
|
5078
|
-
const
|
|
5079
|
-
const isLoad = lazy && row[hasChildField] && !
|
|
5212
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
5213
|
+
const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
5080
5214
|
// 是否使用懒加载
|
|
5081
5215
|
if (isLoad) {
|
|
5082
5216
|
result.push(this.handleAsyncTreeExpandChilds(row))
|
|
@@ -5208,7 +5342,7 @@ const Methods = {
|
|
|
5208
5342
|
loadScrollXData () {
|
|
5209
5343
|
const { mergeList, mergeFooterList, scrollXStore } = this
|
|
5210
5344
|
const { startIndex, endIndex, offsetSize } = scrollXStore
|
|
5211
|
-
const { toVisibleIndex, visibleSize } =
|
|
5345
|
+
const { toVisibleIndex, visibleSize } = handleVirtualXVisible(this)
|
|
5212
5346
|
const offsetItem = {
|
|
5213
5347
|
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
|
|
5214
5348
|
endIndex: toVisibleIndex + visibleSize + offsetSize
|
|
@@ -5224,31 +5358,121 @@ const Methods = {
|
|
|
5224
5358
|
}
|
|
5225
5359
|
this.closeTooltip()
|
|
5226
5360
|
},
|
|
5361
|
+
handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, params: any) {
|
|
5362
|
+
const $xeTable = this
|
|
5363
|
+
const props = $xeTable
|
|
5364
|
+
|
|
5365
|
+
const { highlightHoverRow } = props
|
|
5366
|
+
const tableBody = $xeTable.$refs.tableBody
|
|
5367
|
+
const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
|
|
5368
|
+
const rowOpts = $xeTable.computeRowOpts
|
|
5369
|
+
const validTip = $xeTable.$refs.validTip
|
|
5370
|
+
const tooltip = $xeTable.$refs.tooltip
|
|
5371
|
+
if (rowOpts.isHover || highlightHoverRow) {
|
|
5372
|
+
$xeTable.clearHoverRow()
|
|
5373
|
+
}
|
|
5374
|
+
if (validTip && validTip.visible) {
|
|
5375
|
+
validTip.close()
|
|
5376
|
+
}
|
|
5377
|
+
if (tooltip && tooltip.visible) {
|
|
5378
|
+
tooltip.close()
|
|
5379
|
+
}
|
|
5380
|
+
if (isRollX) {
|
|
5381
|
+
$xeTable.checkScrolling()
|
|
5382
|
+
}
|
|
5383
|
+
const bodyHeight = bodyElem ? bodyElem.clientHeight : 0
|
|
5384
|
+
const bodyWidth = bodyElem ? bodyElem.clientWidth : 0
|
|
5385
|
+
const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0
|
|
5386
|
+
const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0
|
|
5387
|
+
$xeTable.dispatchEvent('scroll', {
|
|
5388
|
+
bodyHeight,
|
|
5389
|
+
bodyWidth,
|
|
5390
|
+
scrollHeight,
|
|
5391
|
+
scrollWidth,
|
|
5392
|
+
isX: isRollX,
|
|
5393
|
+
isY: isRollY,
|
|
5394
|
+
...params
|
|
5395
|
+
}, evnt)
|
|
5396
|
+
},
|
|
5227
5397
|
/**
|
|
5228
5398
|
* 纵向 Y 可视渲染事件处理
|
|
5229
5399
|
*/
|
|
5230
|
-
triggerScrollYEvent (
|
|
5400
|
+
triggerScrollYEvent () {
|
|
5231
5401
|
const { scrollYStore } = this
|
|
5232
5402
|
const { adaptive, offsetSize, visibleSize } = scrollYStore
|
|
5233
5403
|
// webkit 浏览器使用最佳的渲染方式,且最高渲染量不能大于 40 条
|
|
5234
5404
|
if (isWebkit && adaptive && (offsetSize * 2 + visibleSize) <= 40) {
|
|
5235
|
-
this.loadScrollYData(
|
|
5405
|
+
this.loadScrollYData()
|
|
5236
5406
|
} else {
|
|
5237
|
-
this.
|
|
5407
|
+
this.debounceScrollYData()
|
|
5238
5408
|
}
|
|
5409
|
+
this.debounceScrollYCalculate()
|
|
5239
5410
|
},
|
|
5240
|
-
|
|
5241
|
-
this.loadScrollYData(
|
|
5411
|
+
debounceScrollYData: XEUtils.debounce(function () {
|
|
5412
|
+
this.loadScrollYData()
|
|
5242
5413
|
}, debounceScrollYDuration, { leading: false, trailing: true }),
|
|
5414
|
+
scrollXEvent (evnt: Event) {
|
|
5415
|
+
const $xeTable = this
|
|
5416
|
+
|
|
5417
|
+
const wrapperEl = evnt.currentTarget as HTMLDivElement
|
|
5418
|
+
const tableHeader = $xeTable.$refs.tableHeader
|
|
5419
|
+
const tableBody = $xeTable.$refs.tableBody
|
|
5420
|
+
const tableFooter = $xeTable.$refs.tableFooter
|
|
5421
|
+
const bodyElem = tableBody.$el as HTMLDivElement
|
|
5422
|
+
const headerElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
|
|
5423
|
+
const footerElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
|
|
5424
|
+
const { scrollTop, scrollLeft } = wrapperEl
|
|
5425
|
+
const isRollX = true
|
|
5426
|
+
const isRollY = false
|
|
5427
|
+
$xeTable.lastScrollLeft = scrollLeft
|
|
5428
|
+
$xeTable.lastScrollTime = Date.now()
|
|
5429
|
+
setScrollLeft(bodyElem, scrollLeft)
|
|
5430
|
+
setScrollLeft(headerElem, scrollLeft)
|
|
5431
|
+
setScrollLeft(footerElem, scrollLeft)
|
|
5432
|
+
$xeTable.triggerScrollXEvent(evnt)
|
|
5433
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
|
|
5434
|
+
type: 'table',
|
|
5435
|
+
fixed: '',
|
|
5436
|
+
scrollTop,
|
|
5437
|
+
scrollLeft
|
|
5438
|
+
})
|
|
5439
|
+
},
|
|
5440
|
+
debounceScrollYCalculate: XEUtils.debounce(function () {
|
|
5441
|
+
this.updateScrollYSpace()
|
|
5442
|
+
}, 1000, { leading: false, trailing: true }),
|
|
5443
|
+
scrollYEvent (evnt: Event) {
|
|
5444
|
+
const $xeTable = this
|
|
5445
|
+
|
|
5446
|
+
const wrapperEl = evnt.currentTarget as HTMLDivElement
|
|
5447
|
+
const tableBody = $xeTable.$refs.tableBody
|
|
5448
|
+
const leftBody = $xeTable.$refs.leftBody
|
|
5449
|
+
const rightBody = $xeTable.$refs.rightBody
|
|
5450
|
+
const bodyElem = tableBody.$el as HTMLDivElement
|
|
5451
|
+
const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
|
|
5452
|
+
const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
|
|
5453
|
+
const { scrollTop, scrollLeft } = wrapperEl
|
|
5454
|
+
const isRollX = false
|
|
5455
|
+
const isRollY = true
|
|
5456
|
+
$xeTable.lastScrollTop = scrollTop
|
|
5457
|
+
$xeTable.lastScrollTime = Date.now()
|
|
5458
|
+
setScrollTop(bodyElem, scrollTop)
|
|
5459
|
+
setScrollTop(leftElem, scrollTop)
|
|
5460
|
+
setScrollTop(rightElem, scrollTop)
|
|
5461
|
+
$xeTable.triggerScrollYEvent(evnt)
|
|
5462
|
+
$xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
|
|
5463
|
+
type: 'table',
|
|
5464
|
+
fixed: '',
|
|
5465
|
+
scrollTop,
|
|
5466
|
+
scrollLeft
|
|
5467
|
+
})
|
|
5468
|
+
},
|
|
5243
5469
|
/**
|
|
5244
5470
|
* 纵向 Y 可视渲染处理
|
|
5245
5471
|
*/
|
|
5246
|
-
loadScrollYData (
|
|
5472
|
+
loadScrollYData () {
|
|
5247
5473
|
const { mergeList, scrollYStore } = this
|
|
5248
|
-
const { startIndex, endIndex,
|
|
5249
|
-
const
|
|
5250
|
-
const scrollTop = scrollBodyElem.scrollTop
|
|
5251
|
-
const toVisibleIndex = Math.floor(scrollTop / rowHeight)
|
|
5474
|
+
const { startIndex, endIndex, offsetSize } = scrollYStore
|
|
5475
|
+
const { toVisibleIndex, visibleSize } = handleVirtualYVisible(this)
|
|
5252
5476
|
const offsetItem = {
|
|
5253
5477
|
startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
|
|
5254
5478
|
endIndex: toVisibleIndex + visibleSize + offsetSize
|
|
@@ -5269,7 +5493,7 @@ const Methods = {
|
|
|
5269
5493
|
const { sYOpts, sXOpts, scrollXLoad, scrollYLoad, scrollXStore, scrollYStore } = this
|
|
5270
5494
|
// 计算 X 逻辑
|
|
5271
5495
|
if (scrollXLoad) {
|
|
5272
|
-
const { visibleSize: visibleXSize } =
|
|
5496
|
+
const { visibleSize: visibleXSize } = handleVirtualXVisible(this)
|
|
5273
5497
|
const offsetXSize = sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : browse.msie ? 10 : (browse.edge ? 5 : 0)
|
|
5274
5498
|
scrollXStore.offsetSize = offsetXSize
|
|
5275
5499
|
scrollXStore.visibleSize = visibleXSize
|
|
@@ -5278,9 +5502,12 @@ const Methods = {
|
|
|
5278
5502
|
} else {
|
|
5279
5503
|
this.updateScrollXSpace()
|
|
5280
5504
|
}
|
|
5505
|
+
calcCellHeight(this)
|
|
5281
5506
|
// 计算 Y 逻辑
|
|
5282
|
-
const
|
|
5507
|
+
const rowHeight = computeRowHeight(this)
|
|
5283
5508
|
scrollYStore.rowHeight = rowHeight
|
|
5509
|
+
this.rowHeight = rowHeight
|
|
5510
|
+
const { visibleSize: visibleYSize } = handleVirtualYVisible(this)
|
|
5284
5511
|
if (scrollYLoad) {
|
|
5285
5512
|
const offsetYSize = sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : browse.msie ? 20 : (browse.edge ? 10 : 0)
|
|
5286
5513
|
scrollYStore.offsetSize = offsetYSize
|
|
@@ -5290,13 +5517,20 @@ const Methods = {
|
|
|
5290
5517
|
} else {
|
|
5291
5518
|
this.updateScrollYSpace()
|
|
5292
5519
|
}
|
|
5293
|
-
this.rowHeight = rowHeight
|
|
5294
5520
|
this.$nextTick(this.updateStyle)
|
|
5295
5521
|
})
|
|
5296
5522
|
},
|
|
5297
5523
|
handleTableColumn () {
|
|
5298
|
-
const { scrollXLoad, visibleColumn, scrollXStore } = this
|
|
5299
|
-
|
|
5524
|
+
const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this
|
|
5525
|
+
const tableColumn: any[] = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0)
|
|
5526
|
+
tableColumn.forEach((column, $index) => {
|
|
5527
|
+
const colid = column.id
|
|
5528
|
+
const colRest = fullColumnIdData[colid]
|
|
5529
|
+
if (colRest) {
|
|
5530
|
+
colRest.$index = $index
|
|
5531
|
+
}
|
|
5532
|
+
})
|
|
5533
|
+
this.tableColumn = tableColumn
|
|
5300
5534
|
},
|
|
5301
5535
|
updateScrollXData () {
|
|
5302
5536
|
// this.tableColumn = []
|
|
@@ -5307,7 +5541,9 @@ const Methods = {
|
|
|
5307
5541
|
},
|
|
5308
5542
|
// 更新横向 X 可视渲染上下剩余空间大小
|
|
5309
5543
|
updateScrollXSpace () {
|
|
5310
|
-
const
|
|
5544
|
+
const $xeTable = this
|
|
5545
|
+
|
|
5546
|
+
const { $refs, isGroup, elemStore, visibleColumn, scrollXStore, scrollXLoad, tableWidth, scrollbarWidth } = $xeTable
|
|
5311
5547
|
const { tableHeader, tableBody, tableFooter } = $refs
|
|
5312
5548
|
const tableBodyElem = tableBody ? tableBody.$el : null
|
|
5313
5549
|
if (tableBodyElem) {
|
|
@@ -5338,26 +5574,56 @@ const Methods = {
|
|
|
5338
5574
|
}
|
|
5339
5575
|
})
|
|
5340
5576
|
})
|
|
5577
|
+
const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem
|
|
5578
|
+
if (scrollXSpaceEl) {
|
|
5579
|
+
scrollXSpaceEl.style.width = `${tableWidth + scrollbarWidth}px`
|
|
5580
|
+
}
|
|
5341
5581
|
this.$nextTick(this.updateStyle)
|
|
5342
5582
|
}
|
|
5343
5583
|
},
|
|
5344
5584
|
updateScrollYData () {
|
|
5585
|
+
const $xeTable = this
|
|
5586
|
+
|
|
5345
5587
|
// this.tableData = []
|
|
5346
5588
|
this.$nextTick(() => {
|
|
5347
5589
|
this.handleTableData()
|
|
5590
|
+
calcCellHeight($xeTable)
|
|
5348
5591
|
this.updateScrollYSpace()
|
|
5349
5592
|
})
|
|
5350
5593
|
},
|
|
5351
5594
|
// 更新纵向 Y 可视渲染上下剩余空间大小
|
|
5352
5595
|
updateScrollYSpace () {
|
|
5353
|
-
const
|
|
5596
|
+
const $xeTable = this
|
|
5597
|
+
|
|
5598
|
+
const { showOverflow, elemStore, scrollYStore, scrollYLoad, afterFullData, fullAllDataRowIdData } = this
|
|
5354
5599
|
const { startIndex, rowHeight } = scrollYStore
|
|
5355
|
-
|
|
5356
|
-
|
|
5600
|
+
let bodyHeight = 0
|
|
5601
|
+
let topSpaceHeight = 0
|
|
5357
5602
|
const containerList = ['main', 'left', 'right']
|
|
5358
5603
|
let marginTop = ''
|
|
5359
5604
|
let ySpaceHeight = ''
|
|
5360
5605
|
if (scrollYLoad) {
|
|
5606
|
+
if (showOverflow) {
|
|
5607
|
+
bodyHeight = afterFullData.length * rowHeight
|
|
5608
|
+
topSpaceHeight = Math.max(0, startIndex * rowHeight)
|
|
5609
|
+
} else {
|
|
5610
|
+
for (let i = 0; i < afterFullData.length; i++) {
|
|
5611
|
+
const row = afterFullData[i]
|
|
5612
|
+
const rowid = getRowid($xeTable, row)
|
|
5613
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
5614
|
+
if (rowRest) {
|
|
5615
|
+
bodyHeight += rowRest.height || rowHeight
|
|
5616
|
+
}
|
|
5617
|
+
}
|
|
5618
|
+
for (let i = 0; i < startIndex; i++) {
|
|
5619
|
+
const row = afterFullData[i]
|
|
5620
|
+
const rowid = getRowid($xeTable, row)
|
|
5621
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
5622
|
+
if (rowRest) {
|
|
5623
|
+
topSpaceHeight += rowRest.height || rowHeight
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5361
5627
|
marginTop = `${topSpaceHeight}px`
|
|
5362
5628
|
ySpaceHeight = `${bodyHeight}px`
|
|
5363
5629
|
}
|
|
@@ -5374,6 +5640,10 @@ const Methods = {
|
|
|
5374
5640
|
}
|
|
5375
5641
|
})
|
|
5376
5642
|
})
|
|
5643
|
+
const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem
|
|
5644
|
+
if (scrollYSpaceEl) {
|
|
5645
|
+
scrollYSpaceEl.style.height = ySpaceHeight
|
|
5646
|
+
}
|
|
5377
5647
|
this.$nextTick(this.updateStyle)
|
|
5378
5648
|
},
|
|
5379
5649
|
/**
|
|
@@ -5454,28 +5724,44 @@ const Methods = {
|
|
|
5454
5724
|
* 手动清除滚动相关信息,还原到初始状态
|
|
5455
5725
|
*/
|
|
5456
5726
|
clearScroll () {
|
|
5457
|
-
const
|
|
5458
|
-
|
|
5727
|
+
const $xeTable = this
|
|
5728
|
+
|
|
5729
|
+
const { $refs, scrollXStore, scrollYStore } = $xeTable
|
|
5730
|
+
const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs
|
|
5459
5731
|
const tableBodyElem = tableBody ? tableBody.$el : null
|
|
5732
|
+
const leftBodyElem = leftBody ? leftBody.$el : null
|
|
5460
5733
|
const rightBodyElem = rightBody ? rightBody.$el : null
|
|
5734
|
+
const tableHeaderElem = tableHeader ? tableHeader.$el : null
|
|
5461
5735
|
const tableFooterElem = tableFooter ? tableFooter.$el : null
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5467
|
-
|
|
5736
|
+
const xHandleEl = $xeTable.$refs.refScrollXHandleElem
|
|
5737
|
+
if (xHandleEl) {
|
|
5738
|
+
setScrollLeft(xHandleEl, 0)
|
|
5739
|
+
} else {
|
|
5740
|
+
setScrollLeft(tableBodyElem, 0)
|
|
5741
|
+
setScrollLeft(tableHeaderElem, 0)
|
|
5742
|
+
setScrollLeft(tableFooterElem, 0)
|
|
5468
5743
|
}
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5744
|
+
const yHandleEl = $xeTable.$refs.refScrollYHandleElem
|
|
5745
|
+
if (yHandleEl) {
|
|
5746
|
+
setScrollTop(yHandleEl, 0)
|
|
5747
|
+
} else {
|
|
5748
|
+
setScrollTop(tableBodyElem, 0)
|
|
5749
|
+
setScrollTop(leftBodyElem, 0)
|
|
5750
|
+
setScrollTop(rightBodyElem, 0)
|
|
5473
5751
|
}
|
|
5474
5752
|
scrollXStore.startIndex = 0
|
|
5475
5753
|
scrollXStore.endIndex = scrollXStore.visibleSize
|
|
5476
5754
|
scrollYStore.startIndex = 0
|
|
5477
5755
|
scrollYStore.endIndex = scrollYStore.visibleSize
|
|
5478
|
-
return
|
|
5756
|
+
return $xeTable.$nextTick().then(() => {
|
|
5757
|
+
setScrollLeft(tableBodyElem, 0)
|
|
5758
|
+
setScrollLeft(tableHeaderElem, 0)
|
|
5759
|
+
setScrollLeft(tableFooterElem, 0)
|
|
5760
|
+
|
|
5761
|
+
setScrollTop(tableBodyElem, 0)
|
|
5762
|
+
setScrollTop(leftBodyElem, 0)
|
|
5763
|
+
setScrollTop(rightBodyElem, 0)
|
|
5764
|
+
})
|
|
5479
5765
|
},
|
|
5480
5766
|
/**
|
|
5481
5767
|
* 更新表尾合计
|
|
@@ -5626,6 +5912,11 @@ const Methods = {
|
|
|
5626
5912
|
}
|
|
5627
5913
|
return this.$nextTick()
|
|
5628
5914
|
},
|
|
5915
|
+
dispatchEvent (type: ValueOf<VxeTableEmits>, params: Record<string, any>, evnt: Event | null) {
|
|
5916
|
+
const $xeTable = this
|
|
5917
|
+
$xeTable.$emit(type, createEvent(evnt, { $table: $xeTable, $grid: $xeTable.$xegrid }, params))
|
|
5918
|
+
},
|
|
5919
|
+
// 已废弃,使用 dispatchEvent
|
|
5629
5920
|
emitEvent (type: any, params: any, evnt: any) {
|
|
5630
5921
|
this.$emit(type, Object.assign({ $table: this, $grid: this.$xegrid, $event: evnt }, params))
|
|
5631
5922
|
},
|