n20-common-lib 2.22.46 → 2.22.47
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,13 @@ function mapColumnOverflowForVxe(item) {
|
|
|
186
180
|
}
|
|
187
181
|
return applyTooltipToShowOverflow(item)
|
|
188
182
|
}
|
|
183
|
+
const DEFAULT_SCROLL_Y = { enabled: true, oSize: 20, gt: 30 }
|
|
184
|
+
const VXE_ROW_HEIGHT_MAP = {
|
|
185
|
+
default: 48,
|
|
186
|
+
medium: 44,
|
|
187
|
+
small: 40,
|
|
188
|
+
mini: 36
|
|
189
|
+
}
|
|
189
190
|
const renderer = {
|
|
190
191
|
name: 'renderer',
|
|
191
192
|
props: {
|
|
@@ -211,9 +212,13 @@ export default {
|
|
|
211
212
|
scrollY: {
|
|
212
213
|
type: Object,
|
|
213
214
|
default: () => {
|
|
214
|
-
return {
|
|
215
|
+
return { ...DEFAULT_SCROLL_Y }
|
|
215
216
|
}
|
|
216
217
|
},
|
|
218
|
+
dynamicRowHeight: {
|
|
219
|
+
type: Boolean,
|
|
220
|
+
default: false
|
|
221
|
+
},
|
|
217
222
|
data: {
|
|
218
223
|
type: Array,
|
|
219
224
|
default: undefined
|
|
@@ -284,6 +289,45 @@ export default {
|
|
|
284
289
|
}
|
|
285
290
|
},
|
|
286
291
|
computed: {
|
|
292
|
+
tableBindSource() {
|
|
293
|
+
const attrs = { ...this.$attrs }
|
|
294
|
+
const small = attrs.small
|
|
295
|
+
delete attrs.rowConfig
|
|
296
|
+
delete attrs['row-config']
|
|
297
|
+
delete attrs.scrollY
|
|
298
|
+
delete attrs['scroll-y']
|
|
299
|
+
delete attrs.small
|
|
300
|
+
return Object.assign({ size: this.sizeC || this.size }, attrs, this.sizeBind, small)
|
|
301
|
+
},
|
|
302
|
+
computedTableAttrs() {
|
|
303
|
+
return this.tableBindSource
|
|
304
|
+
},
|
|
305
|
+
computedRowConfig() {
|
|
306
|
+
const rowConfig = {
|
|
307
|
+
isHover: true,
|
|
308
|
+
useKey: true,
|
|
309
|
+
...this.$attrs.rowConfig,
|
|
310
|
+
...this.$attrs['row-config']
|
|
311
|
+
}
|
|
312
|
+
if (!this.dynamicRowHeight && rowConfig.height === undefined) {
|
|
313
|
+
rowConfig.height = this.getVirtualRowHeight()
|
|
314
|
+
}
|
|
315
|
+
return rowConfig
|
|
316
|
+
},
|
|
317
|
+
computedScrollY() {
|
|
318
|
+
const scrollY = {
|
|
319
|
+
...DEFAULT_SCROLL_Y,
|
|
320
|
+
...(this.scrollY || {})
|
|
321
|
+
}
|
|
322
|
+
if (this.dynamicRowHeight) {
|
|
323
|
+
scrollY.enabled = false
|
|
324
|
+
return scrollY
|
|
325
|
+
}
|
|
326
|
+
if (scrollY.rHeight === undefined) {
|
|
327
|
+
scrollY.rHeight = this.getVirtualRowHeight()
|
|
328
|
+
}
|
|
329
|
+
return scrollY
|
|
330
|
+
},
|
|
287
331
|
_columns() {
|
|
288
332
|
const raw = this.isAutoWidth ? this.calcColumnWidth(this.columns) : this.columns
|
|
289
333
|
return raw.map(mapColumnOverflowForVxe)
|
|
@@ -292,9 +336,11 @@ export default {
|
|
|
292
336
|
watch: {
|
|
293
337
|
columns() {
|
|
294
338
|
this.colsKey = this.colsKey + 1
|
|
339
|
+
this.refreshTableLayout()
|
|
295
340
|
},
|
|
296
341
|
size(val) {
|
|
297
342
|
this.sizeC = val
|
|
343
|
+
this.refreshTableLayout()
|
|
298
344
|
},
|
|
299
345
|
data() {
|
|
300
346
|
// 翻页清除选中
|
|
@@ -307,6 +353,7 @@ export default {
|
|
|
307
353
|
if (this.mergeCells && this.mergeCells.length > 0 && this.$refs.vxeTable) {
|
|
308
354
|
this.$refs.vxeTable.setMergeCells(this.mergeCells)
|
|
309
355
|
}
|
|
356
|
+
this.refreshTableLayout()
|
|
310
357
|
})
|
|
311
358
|
}
|
|
312
359
|
},
|
|
@@ -317,9 +364,36 @@ export default {
|
|
|
317
364
|
if (this.mergeCells && this.mergeCells.length > 0 && this.$refs.vxeTable) {
|
|
318
365
|
this.$refs.vxeTable.setMergeCells(this.mergeCells)
|
|
319
366
|
}
|
|
367
|
+
this.refreshTableLayout()
|
|
320
368
|
})
|
|
321
369
|
},
|
|
322
370
|
methods: {
|
|
371
|
+
getVirtualRowHeight() {
|
|
372
|
+
const rowConfig = {
|
|
373
|
+
...this.$attrs.rowConfig,
|
|
374
|
+
...this.$attrs['row-config']
|
|
375
|
+
}
|
|
376
|
+
if (rowConfig.height !== undefined) {
|
|
377
|
+
return rowConfig.height
|
|
378
|
+
}
|
|
379
|
+
if (this.scrollY && this.scrollY.rHeight !== undefined) {
|
|
380
|
+
return this.scrollY.rHeight
|
|
381
|
+
}
|
|
382
|
+
const tableSize = this.tableBindSource.size || this.sizeC || 'default'
|
|
383
|
+
return VXE_ROW_HEIGHT_MAP[tableSize] || VXE_ROW_HEIGHT_MAP.default
|
|
384
|
+
},
|
|
385
|
+
refreshTableLayout() {
|
|
386
|
+
this.$nextTick(() => {
|
|
387
|
+
const xTable = this.$refs.vxeTable
|
|
388
|
+
if (!xTable) return
|
|
389
|
+
const recalculate = typeof xTable.recalculate === 'function' ? xTable.recalculate(true) : Promise.resolve()
|
|
390
|
+
Promise.resolve(recalculate).then(() => {
|
|
391
|
+
if (xTable && typeof xTable.refreshScroll === 'function') {
|
|
392
|
+
xTable.refreshScroll()
|
|
393
|
+
}
|
|
394
|
+
})
|
|
395
|
+
})
|
|
396
|
+
},
|
|
323
397
|
// 全选/反选
|
|
324
398
|
toggleAllSelection() {
|
|
325
399
|
if (!this.$refs.vxeTable) return
|
|
@@ -524,9 +598,11 @@ export default {
|
|
|
524
598
|
sizeUp(size) {
|
|
525
599
|
this.sizeC = size
|
|
526
600
|
this.$emit('update:size', size)
|
|
601
|
+
this.refreshTableLayout()
|
|
527
602
|
},
|
|
528
603
|
sizeSet(el) {
|
|
529
604
|
this.sizeBind = el
|
|
605
|
+
this.refreshTableLayout()
|
|
530
606
|
},
|
|
531
607
|
// 计算列宽
|
|
532
608
|
calcColumnWidth(columns) {
|