n20-common-lib 2.22.46 → 2.22.48
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/package.json
CHANGED
|
@@ -15,19 +15,14 @@
|
|
|
15
15
|
}"
|
|
16
16
|
show-header-overflow
|
|
17
17
|
show-overflow
|
|
18
|
-
:row-config="
|
|
19
|
-
isHover: true,
|
|
20
|
-
useKey: true,
|
|
21
|
-
...$attrs.rowConfig,
|
|
22
|
-
...$attrs['row-config']
|
|
23
|
-
}"
|
|
18
|
+
:row-config="computedRowConfig"
|
|
24
19
|
:column-config="{
|
|
25
20
|
resizable: true,
|
|
26
21
|
useKey: true,
|
|
27
22
|
...$attrs.columnConfig,
|
|
28
23
|
...$attrs['column-config']
|
|
29
24
|
}"
|
|
30
|
-
:scroll-y="
|
|
25
|
+
:scroll-y="computedScrollY"
|
|
31
26
|
:sort-config="{
|
|
32
27
|
multiple: false,
|
|
33
28
|
remote: true,
|
|
@@ -43,7 +38,7 @@
|
|
|
43
38
|
iconMatch: 'n20-icon-xiala-moren'
|
|
44
39
|
}"
|
|
45
40
|
:merge-cells="mergeCells"
|
|
46
|
-
v-bind="
|
|
41
|
+
v-bind="computedTableAttrs"
|
|
47
42
|
v-on="$listeners"
|
|
48
43
|
@sort-change="(val) => customSortMethod(val)"
|
|
49
44
|
@filter-change="filterChange"
|
|
@@ -144,7 +139,6 @@
|
|
|
144
139
|
import empty from '../Empty'
|
|
145
140
|
import tableSetSize from '../TableSetSize/index.vue'
|
|
146
141
|
import { $lc } from '../../utils/i18n/index.js'
|
|
147
|
-
import XEUtils from 'xe-utils'
|
|
148
142
|
|
|
149
143
|
/** 将 Element 表格风格的 show-overflow-tooltip 转为 vxe-column 的 show-overflow */
|
|
150
144
|
function hasOverflowTooltipKey(item) {
|
|
@@ -186,6 +180,15 @@ function mapColumnOverflowForVxe(item) {
|
|
|
186
180
|
}
|
|
187
181
|
return applyTooltipToShowOverflow(item)
|
|
188
182
|
}
|
|
183
|
+
// vxe-table 3.6 在渲染行数超过 40 时会防抖更新虚拟滚动数据,快速滚动容易露出空白。
|
|
184
|
+
// 保持较小的默认缓冲,让常见高度下走同步更新路径;业务仍可通过 scroll-y.oSize 覆盖。
|
|
185
|
+
const DEFAULT_SCROLL_Y = { enabled: true, oSize: 6, gt: 30 }
|
|
186
|
+
const VXE_ROW_HEIGHT_MAP = {
|
|
187
|
+
default: 48,
|
|
188
|
+
medium: 44,
|
|
189
|
+
small: 40,
|
|
190
|
+
mini: 36
|
|
191
|
+
}
|
|
189
192
|
const renderer = {
|
|
190
193
|
name: 'renderer',
|
|
191
194
|
props: {
|
|
@@ -211,9 +214,13 @@ export default {
|
|
|
211
214
|
scrollY: {
|
|
212
215
|
type: Object,
|
|
213
216
|
default: () => {
|
|
214
|
-
return {
|
|
217
|
+
return { ...DEFAULT_SCROLL_Y }
|
|
215
218
|
}
|
|
216
219
|
},
|
|
220
|
+
dynamicRowHeight: {
|
|
221
|
+
type: Boolean,
|
|
222
|
+
default: false
|
|
223
|
+
},
|
|
217
224
|
data: {
|
|
218
225
|
type: Array,
|
|
219
226
|
default: undefined
|
|
@@ -284,6 +291,45 @@ export default {
|
|
|
284
291
|
}
|
|
285
292
|
},
|
|
286
293
|
computed: {
|
|
294
|
+
tableBindSource() {
|
|
295
|
+
const attrs = { ...this.$attrs }
|
|
296
|
+
const small = attrs.small
|
|
297
|
+
delete attrs.rowConfig
|
|
298
|
+
delete attrs['row-config']
|
|
299
|
+
delete attrs.scrollY
|
|
300
|
+
delete attrs['scroll-y']
|
|
301
|
+
delete attrs.small
|
|
302
|
+
return Object.assign({ size: this.sizeC || this.size }, attrs, this.sizeBind, small)
|
|
303
|
+
},
|
|
304
|
+
computedTableAttrs() {
|
|
305
|
+
return this.tableBindSource
|
|
306
|
+
},
|
|
307
|
+
computedRowConfig() {
|
|
308
|
+
const rowConfig = {
|
|
309
|
+
isHover: true,
|
|
310
|
+
useKey: true,
|
|
311
|
+
...this.$attrs.rowConfig,
|
|
312
|
+
...this.$attrs['row-config']
|
|
313
|
+
}
|
|
314
|
+
if (!this.dynamicRowHeight && rowConfig.height === undefined) {
|
|
315
|
+
rowConfig.height = this.getVirtualRowHeight()
|
|
316
|
+
}
|
|
317
|
+
return rowConfig
|
|
318
|
+
},
|
|
319
|
+
computedScrollY() {
|
|
320
|
+
const scrollY = {
|
|
321
|
+
...DEFAULT_SCROLL_Y,
|
|
322
|
+
...(this.scrollY || {})
|
|
323
|
+
}
|
|
324
|
+
if (this.dynamicRowHeight) {
|
|
325
|
+
scrollY.enabled = false
|
|
326
|
+
return scrollY
|
|
327
|
+
}
|
|
328
|
+
if (scrollY.rHeight === undefined) {
|
|
329
|
+
scrollY.rHeight = this.getVirtualRowHeight()
|
|
330
|
+
}
|
|
331
|
+
return scrollY
|
|
332
|
+
},
|
|
287
333
|
_columns() {
|
|
288
334
|
const raw = this.isAutoWidth ? this.calcColumnWidth(this.columns) : this.columns
|
|
289
335
|
return raw.map(mapColumnOverflowForVxe)
|
|
@@ -292,9 +338,11 @@ export default {
|
|
|
292
338
|
watch: {
|
|
293
339
|
columns() {
|
|
294
340
|
this.colsKey = this.colsKey + 1
|
|
341
|
+
this.refreshTableLayout()
|
|
295
342
|
},
|
|
296
343
|
size(val) {
|
|
297
344
|
this.sizeC = val
|
|
345
|
+
this.refreshTableLayout()
|
|
298
346
|
},
|
|
299
347
|
data() {
|
|
300
348
|
// 翻页清除选中
|
|
@@ -307,6 +355,7 @@ export default {
|
|
|
307
355
|
if (this.mergeCells && this.mergeCells.length > 0 && this.$refs.vxeTable) {
|
|
308
356
|
this.$refs.vxeTable.setMergeCells(this.mergeCells)
|
|
309
357
|
}
|
|
358
|
+
this.refreshTableLayout()
|
|
310
359
|
})
|
|
311
360
|
}
|
|
312
361
|
},
|
|
@@ -317,9 +366,36 @@ export default {
|
|
|
317
366
|
if (this.mergeCells && this.mergeCells.length > 0 && this.$refs.vxeTable) {
|
|
318
367
|
this.$refs.vxeTable.setMergeCells(this.mergeCells)
|
|
319
368
|
}
|
|
369
|
+
this.refreshTableLayout()
|
|
320
370
|
})
|
|
321
371
|
},
|
|
322
372
|
methods: {
|
|
373
|
+
getVirtualRowHeight() {
|
|
374
|
+
const rowConfig = {
|
|
375
|
+
...this.$attrs.rowConfig,
|
|
376
|
+
...this.$attrs['row-config']
|
|
377
|
+
}
|
|
378
|
+
if (rowConfig.height !== undefined) {
|
|
379
|
+
return rowConfig.height
|
|
380
|
+
}
|
|
381
|
+
if (this.scrollY && this.scrollY.rHeight !== undefined) {
|
|
382
|
+
return this.scrollY.rHeight
|
|
383
|
+
}
|
|
384
|
+
const tableSize = this.tableBindSource.size || this.sizeC || 'default'
|
|
385
|
+
return VXE_ROW_HEIGHT_MAP[tableSize] || VXE_ROW_HEIGHT_MAP.default
|
|
386
|
+
},
|
|
387
|
+
refreshTableLayout() {
|
|
388
|
+
this.$nextTick(() => {
|
|
389
|
+
const xTable = this.$refs.vxeTable
|
|
390
|
+
if (!xTable) return
|
|
391
|
+
const recalculate = typeof xTable.recalculate === 'function' ? xTable.recalculate(true) : Promise.resolve()
|
|
392
|
+
Promise.resolve(recalculate).then(() => {
|
|
393
|
+
if (xTable && typeof xTable.refreshScroll === 'function') {
|
|
394
|
+
xTable.refreshScroll()
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
})
|
|
398
|
+
},
|
|
323
399
|
// 全选/反选
|
|
324
400
|
toggleAllSelection() {
|
|
325
401
|
if (!this.$refs.vxeTable) return
|
|
@@ -524,9 +600,11 @@ export default {
|
|
|
524
600
|
sizeUp(size) {
|
|
525
601
|
this.sizeC = size
|
|
526
602
|
this.$emit('update:size', size)
|
|
603
|
+
this.refreshTableLayout()
|
|
527
604
|
},
|
|
528
605
|
sizeSet(el) {
|
|
529
606
|
this.sizeBind = el
|
|
607
|
+
this.refreshTableLayout()
|
|
530
608
|
},
|
|
531
609
|
// 计算列宽
|
|
532
610
|
calcColumnWidth(columns) {
|