vxe-table 3.4.14-beta.1 → 3.4.15
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/README.md +1 -5
- package/lib/filter/src/mixin.js +24 -13
- package/lib/filter/src/mixin.min.js +1 -1
- package/lib/form/src/form-item.js +5 -0
- package/lib/form/src/form-item.min.js +1 -1
- package/lib/form/src/form.js +31 -27
- package/lib/form/src/form.min.js +1 -1
- package/lib/form/src/util.js +11 -0
- package/lib/form/src/util.min.js +1 -1
- package/lib/index.umd.js +591 -1272
- package/lib/index.umd.min.js +1 -1
- package/lib/input/src/date.js +54 -0
- package/lib/input/src/date.min.js +1 -0
- package/lib/input/src/input.js +12 -59
- package/lib/input/src/input.min.js +1 -1
- package/lib/input/src/number.js +23 -0
- package/lib/input/src/number.min.js +1 -0
- package/lib/pager/src/pager.js +15 -1
- package/lib/pager/src/pager.min.js +1 -1
- package/lib/table/src/body.js +35 -12
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/methods.js +356 -304
- package/lib/table/src/methods.min.js +1 -1
- package/lib/tools/src/dom.js +12 -1
- package/lib/tools/src/dom.min.js +1 -1
- package/lib/tooltip/src/tooltip.js +81 -44
- package/lib/tooltip/src/tooltip.min.js +1 -1
- package/lib/v-x-e-table/src/conf.js +1 -0
- package/lib/v-x-e-table/src/conf.min.js +1 -1
- package/package.json +3 -3
- package/packages/filter/src/mixin.js +17 -10
- package/packages/form/src/form-item.js +5 -0
- package/packages/form/src/form.js +22 -16
- package/packages/form/src/util.js +7 -0
- package/packages/input/src/date.js +38 -0
- package/packages/input/src/input.js +4 -46
- package/packages/input/src/number.js +12 -0
- package/packages/pager/src/pager.js +15 -1
- package/packages/table/src/body.js +31 -13
- package/packages/table/src/methods.js +63 -26
- package/packages/tools/src/dom.js +13 -1
- package/packages/tooltip/src/tooltip.js +47 -23
- package/packages/v-x-e-table/src/conf.js +1 -0
- package/README.en.md +0 -170
- package/README.zh-TW.md +0 -174
|
@@ -45,6 +45,11 @@ export default {
|
|
|
45
45
|
default: null
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
+
data () {
|
|
49
|
+
return {
|
|
50
|
+
inpCurrPage: this.currentPage
|
|
51
|
+
}
|
|
52
|
+
},
|
|
48
53
|
computed: {
|
|
49
54
|
isSizes () {
|
|
50
55
|
return this.layouts.some(name => name === 'Sizes')
|
|
@@ -75,6 +80,11 @@ export default {
|
|
|
75
80
|
})
|
|
76
81
|
}
|
|
77
82
|
},
|
|
83
|
+
watch: {
|
|
84
|
+
currentPage (value) {
|
|
85
|
+
this.inpCurrPage = value
|
|
86
|
+
}
|
|
87
|
+
},
|
|
78
88
|
render (h) {
|
|
79
89
|
const { $scopedSlots, $xegrid, vSize, align, className } = this
|
|
80
90
|
const childNodes = []
|
|
@@ -240,13 +250,14 @@ export default {
|
|
|
240
250
|
h('input', {
|
|
241
251
|
class: 'vxe-pager--goto',
|
|
242
252
|
domProps: {
|
|
243
|
-
value: this.
|
|
253
|
+
value: this.inpCurrPage
|
|
244
254
|
},
|
|
245
255
|
attrs: {
|
|
246
256
|
type: 'text',
|
|
247
257
|
autocomplete: 'off'
|
|
248
258
|
},
|
|
249
259
|
on: {
|
|
260
|
+
input: this.jumpInputEvent,
|
|
250
261
|
keydown: this.jumpKeydownEvent,
|
|
251
262
|
blur: this.triggerJumpEvent
|
|
252
263
|
}
|
|
@@ -373,6 +384,9 @@ export default {
|
|
|
373
384
|
this.$emit('page-change', { type: 'size', pageSize, currentPage: Math.min(this.currentPage, this.getPageCount(this.total, pageSize)) })
|
|
374
385
|
}
|
|
375
386
|
},
|
|
387
|
+
jumpInputEvent (evnt) {
|
|
388
|
+
this.inpCurrPage = evnt.target.value
|
|
389
|
+
},
|
|
376
390
|
jumpKeydownEvent (evnt) {
|
|
377
391
|
if (evnt.keyCode === 13) {
|
|
378
392
|
this.triggerJumpEvent(evnt)
|
|
@@ -3,7 +3,7 @@ import GlobalConfig from '../../v-x-e-table/src/conf'
|
|
|
3
3
|
import VXETable from '../../v-x-e-table'
|
|
4
4
|
import { UtilTools, DomTools, isEnableConf } from '../../tools'
|
|
5
5
|
import { getOffsetSize, calcTreeLine, mergeBodyMethod, removeScrollListener, restoreScrollListener } from './util'
|
|
6
|
-
import {
|
|
6
|
+
import { setScrollTop } from '../../tools/src/dom'
|
|
7
7
|
|
|
8
8
|
const renderType = 'body'
|
|
9
9
|
|
|
@@ -401,7 +401,7 @@ function renderRows (h, _vm, $xetable, fixedType, tableData, tableColumn) {
|
|
|
401
401
|
* 同步滚动条
|
|
402
402
|
*/
|
|
403
403
|
let scrollProcessTimeout
|
|
404
|
-
function syncBodyScroll (scrollTop, elem1, elem2) {
|
|
404
|
+
function syncBodyScroll (_vm, fixedType, scrollTop, elem1, elem2) {
|
|
405
405
|
if (elem1 || elem2) {
|
|
406
406
|
if (elem1) {
|
|
407
407
|
removeScrollListener(elem1)
|
|
@@ -412,9 +412,27 @@ function syncBodyScroll (scrollTop, elem1, elem2) {
|
|
|
412
412
|
elem2.scrollTop = scrollTop
|
|
413
413
|
}
|
|
414
414
|
clearTimeout(scrollProcessTimeout)
|
|
415
|
-
scrollProcessTimeout = setTimeout(
|
|
415
|
+
scrollProcessTimeout = setTimeout(() => {
|
|
416
|
+
const { tableBody, leftBody, rightBody } = _vm.$refs
|
|
417
|
+
const bodyElem = tableBody.$el
|
|
418
|
+
const leftElem = leftBody ? leftBody.$el : null
|
|
419
|
+
const rightElem = rightBody ? rightBody.$el : null
|
|
416
420
|
restoreScrollListener(elem1)
|
|
417
421
|
restoreScrollListener(elem2)
|
|
422
|
+
// 检查滚动条是的同步
|
|
423
|
+
let targetTop = bodyElem.scrollTop
|
|
424
|
+
if (fixedType === 'left') {
|
|
425
|
+
if (leftElem) {
|
|
426
|
+
targetTop = leftElem.scrollTop
|
|
427
|
+
}
|
|
428
|
+
} else if (fixedType === 'right') {
|
|
429
|
+
if (rightElem) {
|
|
430
|
+
targetTop = rightElem.scrollTop
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
setScrollTop(bodyElem, targetTop)
|
|
434
|
+
setScrollTop(leftElem, targetTop)
|
|
435
|
+
setScrollTop(rightElem, targetTop)
|
|
418
436
|
}, 300)
|
|
419
437
|
}
|
|
420
438
|
}
|
|
@@ -621,10 +639,10 @@ export default {
|
|
|
621
639
|
}
|
|
622
640
|
if (leftElem && fixedType === 'left') {
|
|
623
641
|
scrollTop = leftElem.scrollTop
|
|
624
|
-
syncBodyScroll(scrollTop, bodyElem, rightElem)
|
|
642
|
+
syncBodyScroll($xetable, fixedType, scrollTop, bodyElem, rightElem)
|
|
625
643
|
} else if (rightElem && fixedType === 'right') {
|
|
626
644
|
scrollTop = rightElem.scrollTop
|
|
627
|
-
syncBodyScroll(scrollTop, bodyElem, leftElem)
|
|
645
|
+
syncBodyScroll($xetable, fixedType, scrollTop, bodyElem, leftElem)
|
|
628
646
|
} else {
|
|
629
647
|
if (isRollX) {
|
|
630
648
|
if (headerElem) {
|
|
@@ -637,7 +655,7 @@ export default {
|
|
|
637
655
|
if (leftElem || rightElem) {
|
|
638
656
|
$xetable.checkScrolling()
|
|
639
657
|
if (isRollY) {
|
|
640
|
-
syncBodyScroll(scrollTop, leftElem, rightElem)
|
|
658
|
+
syncBodyScroll($xetable, fixedType, scrollTop, leftElem, rightElem)
|
|
641
659
|
}
|
|
642
660
|
}
|
|
643
661
|
}
|
|
@@ -689,15 +707,15 @@ export default {
|
|
|
689
707
|
wheelYInterval = wheelYInterval - (wheelYTotal - wheelYSize)
|
|
690
708
|
}
|
|
691
709
|
const { scrollTop, clientHeight, scrollHeight } = bodyElem
|
|
692
|
-
const
|
|
693
|
-
bodyElem.scrollTop =
|
|
710
|
+
const targetTop = scrollTop + (wheelYInterval * (isTopWheel ? -1 : 1))
|
|
711
|
+
bodyElem.scrollTop = targetTop
|
|
694
712
|
if (leftElem) {
|
|
695
|
-
leftElem.scrollTop =
|
|
713
|
+
leftElem.scrollTop = targetTop
|
|
696
714
|
}
|
|
697
715
|
if (rightElem) {
|
|
698
|
-
rightElem.scrollTop =
|
|
716
|
+
rightElem.scrollTop = targetTop
|
|
699
717
|
}
|
|
700
|
-
if (isTopWheel ?
|
|
718
|
+
if (isTopWheel ? targetTop < scrollHeight - clientHeight : targetTop >= 0) {
|
|
701
719
|
this.wheelTime = setTimeout(handleSmooth, 10)
|
|
702
720
|
}
|
|
703
721
|
this.wheelYTotal = wheelYTotal
|
|
@@ -728,8 +746,8 @@ export default {
|
|
|
728
746
|
const { tableBody } = $refs
|
|
729
747
|
const bodyElem = tableBody.$el
|
|
730
748
|
|
|
731
|
-
const deltaTop =
|
|
732
|
-
const deltaLeft =
|
|
749
|
+
const deltaTop = deltaY
|
|
750
|
+
const deltaLeft = deltaX
|
|
733
751
|
const isTopWheel = deltaTop < 0
|
|
734
752
|
// 如果滚动位置已经是顶部或底部,则不需要触发
|
|
735
753
|
if (isTopWheel ? scrollBodyElem.scrollTop <= 0 : scrollBodyElem.scrollTop >= scrollBodyElem.scrollHeight - scrollBodyElem.clientHeight) {
|
|
@@ -9,7 +9,7 @@ import { browse, getPaddingTopBottomSize, setScrollTop, setScrollLeft } from '..
|
|
|
9
9
|
import { formats } from '../../v-x-e-table/src/formats'
|
|
10
10
|
|
|
11
11
|
const { getRowid, getRowkey, setCellValue, hasChildrenList, getColumnList } = UtilTools
|
|
12
|
-
const { calcHeight, hasClass, addClass, removeClass, getEventTargetNode } = DomTools
|
|
12
|
+
const { calcHeight, hasClass, addClass, removeClass, getEventTargetNode, isNodeElement } = DomTools
|
|
13
13
|
|
|
14
14
|
const isWebkit = browse['-webkit'] && !browse.edge
|
|
15
15
|
const debounceScrollYDuration = browse.msie ? 80 : 20
|
|
@@ -294,11 +294,30 @@ const Methods = {
|
|
|
294
294
|
})
|
|
295
295
|
},
|
|
296
296
|
/**
|
|
297
|
-
*
|
|
297
|
+
* 手动处理数据,用于手动排序与筛选
|
|
298
298
|
* 对于手动更改了排序、筛选...等条件后需要重新处理数据时可能会用到
|
|
299
299
|
*/
|
|
300
300
|
updateData () {
|
|
301
|
-
|
|
301
|
+
const { scrollXLoad, scrollYLoad } = this
|
|
302
|
+
return this.handleTableData(true).then(() => {
|
|
303
|
+
this.updateFooter()
|
|
304
|
+
this.checkSelectionStatus()
|
|
305
|
+
if (scrollXLoad || scrollYLoad) {
|
|
306
|
+
if (scrollXLoad) {
|
|
307
|
+
this.updateScrollXSpace()
|
|
308
|
+
}
|
|
309
|
+
if (scrollYLoad) {
|
|
310
|
+
this.updateScrollYSpace()
|
|
311
|
+
}
|
|
312
|
+
return this.refreshScroll()
|
|
313
|
+
}
|
|
314
|
+
}).then(() => {
|
|
315
|
+
this.updateCellAreas()
|
|
316
|
+
return this.recalculate(true)
|
|
317
|
+
}).then(() => {
|
|
318
|
+
// 存在滚动行为未结束情况
|
|
319
|
+
setTimeout(() => this.recalculate(), 50)
|
|
320
|
+
})
|
|
302
321
|
},
|
|
303
322
|
handleTableData (force) {
|
|
304
323
|
const { scrollYLoad, scrollYStore, fullDataRowIdData, afterFullData } = this
|
|
@@ -1688,15 +1707,22 @@ const Methods = {
|
|
|
1688
1707
|
const leftBodyElem = leftBody ? leftBody.$el : null
|
|
1689
1708
|
const rightBodyElem = rightBody ? rightBody.$el : null
|
|
1690
1709
|
const tableFooterElem = tableFooter ? tableFooter.$el : null
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1710
|
+
return new Promise(resolve => {
|
|
1711
|
+
// 还原滚动条位置
|
|
1712
|
+
if (lastScrollLeft || lastScrollTop) {
|
|
1713
|
+
return restoreScrollLocation(this, lastScrollLeft, lastScrollTop).then(() => {
|
|
1714
|
+
// 存在滚动行为未结束情况
|
|
1715
|
+
setTimeout(resolve, 30)
|
|
1716
|
+
})
|
|
1717
|
+
}
|
|
1718
|
+
// 重置
|
|
1719
|
+
setScrollTop(tableBodyElem, lastScrollTop)
|
|
1720
|
+
setScrollTop(leftBodyElem, lastScrollTop)
|
|
1721
|
+
setScrollTop(rightBodyElem, lastScrollTop)
|
|
1722
|
+
setScrollLeft(tableFooterElem, lastScrollLeft)
|
|
1723
|
+
// 存在滚动行为未结束情况
|
|
1724
|
+
setTimeout(resolve, 30)
|
|
1725
|
+
})
|
|
1700
1726
|
},
|
|
1701
1727
|
/**
|
|
1702
1728
|
* 计算单元格列宽,动态分配可用剩余空间
|
|
@@ -1965,7 +1991,7 @@ const Methods = {
|
|
|
1965
1991
|
}
|
|
1966
1992
|
} else if (layout === 'body') {
|
|
1967
1993
|
const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`]
|
|
1968
|
-
if (wrapperElem) {
|
|
1994
|
+
if (isNodeElement(wrapperElem)) {
|
|
1969
1995
|
if (customMaxHeight) {
|
|
1970
1996
|
wrapperElem.style.maxHeight = `${fixedType ? customMaxHeight - headerHeight - (showFooter ? 0 : scrollbarHeight) : customMaxHeight - headerHeight}px`
|
|
1971
1997
|
} else {
|
|
@@ -1981,7 +2007,7 @@ const Methods = {
|
|
|
1981
2007
|
if (fixedWrapperElem) {
|
|
1982
2008
|
const isRightFixed = fixedType === 'right'
|
|
1983
2009
|
const fixedColumn = columnStore[`${fixedType}List`]
|
|
1984
|
-
if (wrapperElem) {
|
|
2010
|
+
if (isNodeElement(wrapperElem)) {
|
|
1985
2011
|
wrapperElem.style.top = `${headerHeight}px`
|
|
1986
2012
|
}
|
|
1987
2013
|
fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`
|
|
@@ -2045,7 +2071,7 @@ const Methods = {
|
|
|
2045
2071
|
}
|
|
2046
2072
|
tWidth = tableColumn.reduce((previous, column) => previous + column.renderWidth, 0)
|
|
2047
2073
|
|
|
2048
|
-
if (wrapperElem) {
|
|
2074
|
+
if (isNodeElement(wrapperElem)) {
|
|
2049
2075
|
// 如果是固定列
|
|
2050
2076
|
if (fixedWrapperElem) {
|
|
2051
2077
|
wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`
|
|
@@ -2532,18 +2558,29 @@ const Methods = {
|
|
|
2532
2558
|
}, tooltipOpts.leaveDelay)
|
|
2533
2559
|
return false
|
|
2534
2560
|
},
|
|
2535
|
-
handleTargetEnterEvent () {
|
|
2561
|
+
handleTargetEnterEvent (isClear) {
|
|
2562
|
+
const $tooltip = this.$refs.tooltip
|
|
2536
2563
|
clearTimeout(this.tooltipTimeout)
|
|
2537
2564
|
this.tooltipActive = true
|
|
2538
|
-
|
|
2565
|
+
if (isClear) {
|
|
2566
|
+
this.closeTooltip()
|
|
2567
|
+
} else {
|
|
2568
|
+
if ($tooltip) {
|
|
2569
|
+
$tooltip.setActived(true)
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2539
2572
|
},
|
|
2540
2573
|
handleTargetLeaveEvent () {
|
|
2541
2574
|
const tooltipOpts = this.tooltipOpts
|
|
2575
|
+
let $tooltip = this.$refs.tooltip
|
|
2542
2576
|
this.tooltipActive = false
|
|
2577
|
+
if ($tooltip) {
|
|
2578
|
+
$tooltip.setActived(false)
|
|
2579
|
+
}
|
|
2543
2580
|
if (tooltipOpts.enterable) {
|
|
2544
2581
|
this.tooltipTimeout = setTimeout(() => {
|
|
2545
|
-
|
|
2546
|
-
if (tooltip &&
|
|
2582
|
+
$tooltip = this.$refs.tooltip
|
|
2583
|
+
if ($tooltip && !$tooltip.isActived()) {
|
|
2547
2584
|
this.closeTooltip()
|
|
2548
2585
|
}
|
|
2549
2586
|
}, tooltipOpts.leaveDelay)
|
|
@@ -2556,12 +2593,12 @@ const Methods = {
|
|
|
2556
2593
|
const { titleHelp } = column
|
|
2557
2594
|
if (titleHelp.content || titleHelp.message) {
|
|
2558
2595
|
const { $refs, tooltipStore } = this
|
|
2559
|
-
const tooltip = $refs.tooltip
|
|
2596
|
+
const $tooltip = $refs.tooltip
|
|
2560
2597
|
const content = UtilTools.getFuncText(titleHelp.content || titleHelp.message)
|
|
2561
|
-
this.handleTargetEnterEvent()
|
|
2598
|
+
this.handleTargetEnterEvent(true)
|
|
2562
2599
|
tooltipStore.visible = true
|
|
2563
|
-
if (tooltip) {
|
|
2564
|
-
tooltip.open(evnt.currentTarget, content)
|
|
2600
|
+
if ($tooltip) {
|
|
2601
|
+
$tooltip.open(evnt.currentTarget, content)
|
|
2565
2602
|
}
|
|
2566
2603
|
}
|
|
2567
2604
|
},
|
|
@@ -2572,7 +2609,7 @@ const Methods = {
|
|
|
2572
2609
|
const { tooltipStore } = this
|
|
2573
2610
|
const { column } = params
|
|
2574
2611
|
const titleElem = evnt.currentTarget
|
|
2575
|
-
this.handleTargetEnterEvent()
|
|
2612
|
+
this.handleTargetEnterEvent(tooltipStore.column !== column || tooltipStore.row)
|
|
2576
2613
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
2577
2614
|
this.handleTooltip(evnt, titleElem, titleElem, null, params)
|
|
2578
2615
|
}
|
|
@@ -2585,7 +2622,7 @@ const Methods = {
|
|
|
2585
2622
|
const { actived } = editStore
|
|
2586
2623
|
const { row, column } = params
|
|
2587
2624
|
const cell = evnt.currentTarget
|
|
2588
|
-
this.handleTargetEnterEvent()
|
|
2625
|
+
this.handleTargetEnterEvent(tooltipStore.column !== column || tooltipStore.row !== row)
|
|
2589
2626
|
if (isEnableConf(editConfig)) {
|
|
2590
2627
|
if ((editOpts.mode === 'row' && actived.row === row) || (actived.row === row && actived.column === column)) {
|
|
2591
2628
|
return
|
|
@@ -2612,7 +2649,7 @@ const Methods = {
|
|
|
2612
2649
|
const { column } = params
|
|
2613
2650
|
const { tooltipStore } = this
|
|
2614
2651
|
const cell = evnt.currentTarget
|
|
2615
|
-
this.handleTargetEnterEvent()
|
|
2652
|
+
this.handleTargetEnterEvent(true)
|
|
2616
2653
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
2617
2654
|
this.handleTooltip(evnt, cell, cell.querySelector('.vxe-cell--item') || cell.children[0], null, params)
|
|
2618
2655
|
}
|
|
@@ -80,6 +80,17 @@ export function setScrollLeft (elem, scrollLeft) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// export function setScrollLeftAndTop (elem, scrollLeft, scrollTop) {
|
|
84
|
+
// if (elem) {
|
|
85
|
+
// elem.scrollLeft = scrollLeft
|
|
86
|
+
// elem.scrollTop = scrollTop
|
|
87
|
+
// }
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
function isNodeElement (elem) {
|
|
91
|
+
return elem && elem.nodeType === 1
|
|
92
|
+
}
|
|
93
|
+
|
|
83
94
|
export const DomTools = {
|
|
84
95
|
browse,
|
|
85
96
|
isPx (val) {
|
|
@@ -225,7 +236,8 @@ export const DomTools = {
|
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
238
|
return num
|
|
228
|
-
}
|
|
239
|
+
},
|
|
240
|
+
isNodeElement
|
|
229
241
|
}
|
|
230
242
|
|
|
231
243
|
export default DomTools
|
|
@@ -26,6 +26,20 @@ function updateTipStyle (_vm) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
function showTip (_vm) {
|
|
30
|
+
const { $el, tipStore, zIndex } = _vm
|
|
31
|
+
const parentNode = $el.parentNode
|
|
32
|
+
if (!parentNode) {
|
|
33
|
+
document.body.appendChild($el)
|
|
34
|
+
}
|
|
35
|
+
_vm.updateValue(true)
|
|
36
|
+
_vm.updateZindex()
|
|
37
|
+
tipStore.placement = 'top'
|
|
38
|
+
tipStore.style = { width: 'auto', left: 0, top: 0, zIndex: zIndex || _vm.tipZindex }
|
|
39
|
+
tipStore.arrowStyle = { left: '50%' }
|
|
40
|
+
return _vm.updatePlacement()
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
export default {
|
|
30
44
|
name: 'VxeTooltip',
|
|
31
45
|
mixins: [vSize],
|
|
@@ -38,15 +52,16 @@ export default {
|
|
|
38
52
|
zIndex: [String, Number],
|
|
39
53
|
isArrow: { type: Boolean, default: true },
|
|
40
54
|
enterable: Boolean,
|
|
55
|
+
enterDelay: { type: Number, default: () => GlobalConfig.tooltip.enterDelay },
|
|
41
56
|
leaveDelay: { type: Number, default: () => GlobalConfig.tooltip.leaveDelay },
|
|
42
57
|
leaveMethod: Function
|
|
43
58
|
},
|
|
44
59
|
data () {
|
|
45
60
|
return {
|
|
46
61
|
isUpdate: false,
|
|
47
|
-
isHover: false,
|
|
48
62
|
visible: false,
|
|
49
63
|
message: '',
|
|
64
|
+
tipActive: false,
|
|
50
65
|
tipTarget: null,
|
|
51
66
|
tipZindex: 0,
|
|
52
67
|
tipStore: {
|
|
@@ -67,6 +82,13 @@ export default {
|
|
|
67
82
|
this.isUpdate = false
|
|
68
83
|
}
|
|
69
84
|
},
|
|
85
|
+
created () {
|
|
86
|
+
this.showDelayTip = XEUtils.debounce(() => {
|
|
87
|
+
if (this.tipActive) {
|
|
88
|
+
showTip(this)
|
|
89
|
+
}
|
|
90
|
+
}, this.enterDelay, { leading: false, trailing: true })
|
|
91
|
+
},
|
|
70
92
|
mounted () {
|
|
71
93
|
const { $el, trigger, content, value } = this
|
|
72
94
|
const parentNode = $el.parentNode
|
|
@@ -111,7 +133,7 @@ export default {
|
|
|
111
133
|
}
|
|
112
134
|
},
|
|
113
135
|
render (h) {
|
|
114
|
-
const { $scopedSlots, vSize, theme, message,
|
|
136
|
+
const { $scopedSlots, vSize, theme, message, tipActive, isArrow, visible, tipStore, enterable } = this
|
|
115
137
|
let on
|
|
116
138
|
if (enterable) {
|
|
117
139
|
on = {
|
|
@@ -126,7 +148,7 @@ export default {
|
|
|
126
148
|
'is--enterable': enterable,
|
|
127
149
|
'is--visible': visible,
|
|
128
150
|
'is--arrow': isArrow,
|
|
129
|
-
'is--
|
|
151
|
+
'is--actived': tipActive
|
|
130
152
|
}],
|
|
131
153
|
style: tipStore.style,
|
|
132
154
|
ref: 'tipWrapper',
|
|
@@ -147,15 +169,16 @@ export default {
|
|
|
147
169
|
},
|
|
148
170
|
close () {
|
|
149
171
|
this.tipTarget = null
|
|
172
|
+
this.tipActive = false
|
|
150
173
|
Object.assign(this.tipStore, {
|
|
151
174
|
style: {},
|
|
152
175
|
placement: '',
|
|
153
176
|
arrowStyle: null
|
|
154
177
|
})
|
|
155
|
-
this.
|
|
178
|
+
this.updateValue(false)
|
|
156
179
|
return this.$nextTick()
|
|
157
180
|
},
|
|
158
|
-
|
|
181
|
+
updateValue (value) {
|
|
159
182
|
if (value !== this.visible) {
|
|
160
183
|
this.visible = value
|
|
161
184
|
this.isUpdate = true
|
|
@@ -170,23 +193,18 @@ export default {
|
|
|
170
193
|
}
|
|
171
194
|
},
|
|
172
195
|
toVisible (target, message) {
|
|
173
|
-
this.targetActive = true
|
|
174
196
|
if (target) {
|
|
175
|
-
const {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
document.body.appendChild($el)
|
|
179
|
-
}
|
|
197
|
+
const { trigger, enterDelay } = this
|
|
198
|
+
this.tipActive = true
|
|
199
|
+
this.tipTarget = target
|
|
180
200
|
if (message) {
|
|
181
201
|
this.message = message
|
|
182
202
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
tipStore.arrowStyle = { left: '50%' }
|
|
189
|
-
return this.updatePlacement()
|
|
203
|
+
if (enterDelay && trigger === 'hover') {
|
|
204
|
+
this.showDelayTip()
|
|
205
|
+
} else {
|
|
206
|
+
return showTip(this)
|
|
207
|
+
}
|
|
190
208
|
}
|
|
191
209
|
return this.$nextTick()
|
|
192
210
|
},
|
|
@@ -199,6 +217,12 @@ export default {
|
|
|
199
217
|
}
|
|
200
218
|
})
|
|
201
219
|
},
|
|
220
|
+
isActived () {
|
|
221
|
+
return this.tipActive
|
|
222
|
+
},
|
|
223
|
+
setActived (actived) {
|
|
224
|
+
this.tipActive = !!actived
|
|
225
|
+
},
|
|
202
226
|
clickEvent () {
|
|
203
227
|
this[this.visible ? 'close' : 'open']()
|
|
204
228
|
},
|
|
@@ -207,10 +231,10 @@ export default {
|
|
|
207
231
|
},
|
|
208
232
|
targetMouseleaveEvent () {
|
|
209
233
|
const { trigger, enterable, leaveDelay } = this
|
|
210
|
-
this.
|
|
234
|
+
this.tipActive = false
|
|
211
235
|
if (enterable && trigger === 'hover') {
|
|
212
236
|
setTimeout(() => {
|
|
213
|
-
if (!this.
|
|
237
|
+
if (!this.tipActive) {
|
|
214
238
|
this.close()
|
|
215
239
|
}
|
|
216
240
|
}, leaveDelay)
|
|
@@ -219,15 +243,15 @@ export default {
|
|
|
219
243
|
}
|
|
220
244
|
},
|
|
221
245
|
wrapperMouseenterEvent () {
|
|
222
|
-
this.
|
|
246
|
+
this.tipActive = true
|
|
223
247
|
},
|
|
224
248
|
wrapperMouseleaveEvent (evnt) {
|
|
225
249
|
const { leaveMethod, trigger, enterable, leaveDelay } = this
|
|
226
|
-
this.
|
|
250
|
+
this.tipActive = false
|
|
227
251
|
if (!leaveMethod || leaveMethod({ $event: evnt }) !== false) {
|
|
228
252
|
if (enterable && trigger === 'hover') {
|
|
229
253
|
setTimeout(() => {
|
|
230
|
-
if (!this.
|
|
254
|
+
if (!this.tipActive) {
|
|
231
255
|
this.close()
|
|
232
256
|
}
|
|
233
257
|
}, leaveDelay)
|