ct-component-plus 0.0.42 → 0.0.44
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 +3 -3
- package/package.json +1 -1
- package/packages/components/search-box/src/search-box.vue +3 -4
- package/packages/components/table/src/index.js +12 -0
- package/packages/components/table/src/table.vue +4 -3
- package/packages/constants/aria.ts +17 -17
- package/packages/constants/index.ts +1 -1
- package/packages/directives/click-outside/index.ts +118 -118
- package/packages/utils/table.js +135 -0
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Vue 3 + Vite
|
|
2
|
-
|
|
3
|
-
青塔组件库的 Vue 3 版本,使用 Vite 构建。
|
|
1
|
+
# Vue 3 + Vite
|
|
2
|
+
|
|
3
|
+
青塔组件库的 Vue 3 版本,使用 Vite 构建。
|
package/package.json
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
:key="item.param || index"
|
|
13
13
|
:style="{ ...getComponentStyle(item) }">
|
|
14
14
|
<slot v-bind="getComponentSlotScope(item)">
|
|
15
|
-
<slot
|
|
16
|
-
|
|
17
|
-
v-bind="getComponentSlotScope(item)"></slot>
|
|
15
|
+
<slot name="item-before" v-bind="getComponentSlotScope(item)">
|
|
16
|
+
</slot>
|
|
18
17
|
<span
|
|
19
18
|
:class="[
|
|
20
19
|
ns.e('item-label'),
|
|
@@ -142,7 +141,7 @@ const getComponentProps = (item) => {
|
|
|
142
141
|
};
|
|
143
142
|
};
|
|
144
143
|
const getComponent = (type) => {
|
|
145
|
-
return isObject(type) ? type : componentAll.value[type] ||
|
|
144
|
+
return isObject(type) ? type : componentAll.value[type] || "div";
|
|
146
145
|
};
|
|
147
146
|
const getComponentSlotScope = (item) => {
|
|
148
147
|
return isObject(item) ? item : {};
|
|
@@ -64,4 +64,16 @@ export const tableProps = {
|
|
|
64
64
|
alignLeftKeys: Array,
|
|
65
65
|
alignRightKeys: Array,
|
|
66
66
|
rowKey: String,
|
|
67
|
+
showOverflowTooltip: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true
|
|
70
|
+
},
|
|
71
|
+
sticky: {
|
|
72
|
+
type: Object,
|
|
73
|
+
default: () => {
|
|
74
|
+
return {
|
|
75
|
+
top: 0
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
67
79
|
}
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
:span-method="spanMethod"
|
|
9
9
|
@selection-change="handleSelectChange"
|
|
10
10
|
:row-key="rowKey || 'rowKey'"
|
|
11
|
-
v-bind="$attrs"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
v-sticky="sticky">
|
|
12
13
|
<el-table-column
|
|
13
14
|
v-if="isMultiSelect"
|
|
14
15
|
type="selection"
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
:sortable="column.sortable ? 'custom' : false"
|
|
29
30
|
:align="getColumnAlign(column)"
|
|
30
31
|
:fixed="column.fixed || false"
|
|
31
|
-
show-overflow-tooltip
|
|
32
|
+
:show-overflow-tooltip="showOverflowTooltip"
|
|
32
33
|
v-bind="column.rawAttr || {}">
|
|
33
34
|
<template #header="scope" v-if="column.slotHeader">
|
|
34
35
|
<slot
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
:sortable="column1.sortable ? 'custom' : false"
|
|
59
60
|
:align="getColumnAlign(column1)"
|
|
60
61
|
:fixed="column1.fixed || false"
|
|
61
|
-
show-overflow-tooltip
|
|
62
|
+
:show-overflow-tooltip="showOverflowTooltip"
|
|
62
63
|
v-bind="column1.rawAttr || {}">
|
|
63
64
|
<template #default="scope">
|
|
64
65
|
<slot
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export const EVENT_CODE = {
|
|
2
|
-
tab: 'Tab',
|
|
3
|
-
enter: 'Enter',
|
|
4
|
-
space: 'Space',
|
|
5
|
-
left: 'ArrowLeft', // 37
|
|
6
|
-
up: 'ArrowUp', // 38
|
|
7
|
-
right: 'ArrowRight', // 39
|
|
8
|
-
down: 'ArrowDown', // 40
|
|
9
|
-
esc: 'Escape',
|
|
10
|
-
delete: 'Delete',
|
|
11
|
-
backspace: 'Backspace',
|
|
12
|
-
numpadEnter: 'NumpadEnter',
|
|
13
|
-
pageUp: 'PageUp',
|
|
14
|
-
pageDown: 'PageDown',
|
|
15
|
-
home: 'Home',
|
|
16
|
-
end: 'End',
|
|
17
|
-
}
|
|
1
|
+
export const EVENT_CODE = {
|
|
2
|
+
tab: 'Tab',
|
|
3
|
+
enter: 'Enter',
|
|
4
|
+
space: 'Space',
|
|
5
|
+
left: 'ArrowLeft', // 37
|
|
6
|
+
up: 'ArrowUp', // 38
|
|
7
|
+
right: 'ArrowRight', // 39
|
|
8
|
+
down: 'ArrowDown', // 40
|
|
9
|
+
esc: 'Escape',
|
|
10
|
+
delete: 'Delete',
|
|
11
|
+
backspace: 'Backspace',
|
|
12
|
+
numpadEnter: 'NumpadEnter',
|
|
13
|
+
pageUp: 'PageUp',
|
|
14
|
+
pageDown: 'PageDown',
|
|
15
|
+
home: 'Home',
|
|
16
|
+
end: 'End',
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './aria'
|
|
1
|
+
export * from './aria'
|
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
import { isClient, isElement } from '../../utils'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
ComponentPublicInstance,
|
|
5
|
-
DirectiveBinding,
|
|
6
|
-
ObjectDirective,
|
|
7
|
-
} from 'vue'
|
|
8
|
-
|
|
9
|
-
type DocumentHandler = <T extends MouseEvent>(mouseup: T, mousedown: T) => void
|
|
10
|
-
type FlushList = Map<
|
|
11
|
-
HTMLElement,
|
|
12
|
-
{
|
|
13
|
-
documentHandler: DocumentHandler
|
|
14
|
-
bindingFn: (...args: unknown[]) => unknown
|
|
15
|
-
}[]
|
|
16
|
-
>
|
|
17
|
-
|
|
18
|
-
const nodeList: FlushList = new Map()
|
|
19
|
-
|
|
20
|
-
let startClick: MouseEvent
|
|
21
|
-
|
|
22
|
-
if (isClient) {
|
|
23
|
-
document.addEventListener('mousedown', (e: MouseEvent) => (startClick = e))
|
|
24
|
-
document.addEventListener('mouseup', (e: MouseEvent) => {
|
|
25
|
-
for (const handlers of nodeList.values()) {
|
|
26
|
-
for (const { documentHandler } of handlers) {
|
|
27
|
-
documentHandler(e as MouseEvent, startClick)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function createDocumentHandler(
|
|
34
|
-
el: HTMLElement,
|
|
35
|
-
binding: DirectiveBinding
|
|
36
|
-
): DocumentHandler {
|
|
37
|
-
let excludes: HTMLElement[] = []
|
|
38
|
-
if (Array.isArray(binding.arg)) {
|
|
39
|
-
excludes = binding.arg
|
|
40
|
-
} else if (isElement(binding.arg)) {
|
|
41
|
-
// due to current implementation on binding type is wrong the type casting is necessary here
|
|
42
|
-
excludes.push(binding.arg as unknown as HTMLElement)
|
|
43
|
-
}
|
|
44
|
-
return function (mouseup, mousedown) {
|
|
45
|
-
const popperRef = (
|
|
46
|
-
binding.instance as ComponentPublicInstance<{
|
|
47
|
-
popperRef: HTMLElement
|
|
48
|
-
}>
|
|
49
|
-
).popperRef
|
|
50
|
-
const mouseUpTarget = mouseup.target as Node
|
|
51
|
-
const mouseDownTarget = mousedown?.target as Node
|
|
52
|
-
const isBound = !binding || !binding.instance
|
|
53
|
-
const isTargetExists = !mouseUpTarget || !mouseDownTarget
|
|
54
|
-
const isContainedByEl =
|
|
55
|
-
el.contains(mouseUpTarget) || el.contains(mouseDownTarget)
|
|
56
|
-
const isSelf = el === mouseUpTarget
|
|
57
|
-
|
|
58
|
-
const isTargetExcluded =
|
|
59
|
-
(excludes.length &&
|
|
60
|
-
excludes.some((item) => item?.contains(mouseUpTarget))) ||
|
|
61
|
-
(excludes.length && excludes.includes(mouseDownTarget as HTMLElement))
|
|
62
|
-
const isContainedByPopper =
|
|
63
|
-
popperRef &&
|
|
64
|
-
(popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget))
|
|
65
|
-
if (
|
|
66
|
-
isBound ||
|
|
67
|
-
isTargetExists ||
|
|
68
|
-
isContainedByEl ||
|
|
69
|
-
isSelf ||
|
|
70
|
-
isTargetExcluded ||
|
|
71
|
-
isContainedByPopper
|
|
72
|
-
) {
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
binding.value(mouseup, mousedown)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const ClickOutside: ObjectDirective = {
|
|
80
|
-
beforeMount(el: HTMLElement, binding: DirectiveBinding) {
|
|
81
|
-
// there could be multiple handlers on the element
|
|
82
|
-
if (!nodeList.has(el)) {
|
|
83
|
-
nodeList.set(el, [])
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
nodeList.get(el)!.push({
|
|
87
|
-
documentHandler: createDocumentHandler(el, binding),
|
|
88
|
-
bindingFn: binding.value,
|
|
89
|
-
})
|
|
90
|
-
},
|
|
91
|
-
updated(el: HTMLElement, binding: DirectiveBinding) {
|
|
92
|
-
if (!nodeList.has(el)) {
|
|
93
|
-
nodeList.set(el, [])
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const handlers = nodeList.get(el)!
|
|
97
|
-
const oldHandlerIndex = handlers.findIndex(
|
|
98
|
-
(item) => item.bindingFn === binding.oldValue
|
|
99
|
-
)
|
|
100
|
-
const newHandler = {
|
|
101
|
-
documentHandler: createDocumentHandler(el, binding),
|
|
102
|
-
bindingFn: binding.value,
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (oldHandlerIndex >= 0) {
|
|
106
|
-
// replace the old handler to the new handler
|
|
107
|
-
handlers.splice(oldHandlerIndex, 1, newHandler)
|
|
108
|
-
} else {
|
|
109
|
-
handlers.push(newHandler)
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
unmounted(el: HTMLElement) {
|
|
113
|
-
// remove all listeners when a component unmounted
|
|
114
|
-
nodeList.delete(el)
|
|
115
|
-
},
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export default ClickOutside
|
|
1
|
+
import { isClient, isElement } from '../../utils'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ComponentPublicInstance,
|
|
5
|
+
DirectiveBinding,
|
|
6
|
+
ObjectDirective,
|
|
7
|
+
} from 'vue'
|
|
8
|
+
|
|
9
|
+
type DocumentHandler = <T extends MouseEvent>(mouseup: T, mousedown: T) => void
|
|
10
|
+
type FlushList = Map<
|
|
11
|
+
HTMLElement,
|
|
12
|
+
{
|
|
13
|
+
documentHandler: DocumentHandler
|
|
14
|
+
bindingFn: (...args: unknown[]) => unknown
|
|
15
|
+
}[]
|
|
16
|
+
>
|
|
17
|
+
|
|
18
|
+
const nodeList: FlushList = new Map()
|
|
19
|
+
|
|
20
|
+
let startClick: MouseEvent
|
|
21
|
+
|
|
22
|
+
if (isClient) {
|
|
23
|
+
document.addEventListener('mousedown', (e: MouseEvent) => (startClick = e))
|
|
24
|
+
document.addEventListener('mouseup', (e: MouseEvent) => {
|
|
25
|
+
for (const handlers of nodeList.values()) {
|
|
26
|
+
for (const { documentHandler } of handlers) {
|
|
27
|
+
documentHandler(e as MouseEvent, startClick)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function createDocumentHandler(
|
|
34
|
+
el: HTMLElement,
|
|
35
|
+
binding: DirectiveBinding
|
|
36
|
+
): DocumentHandler {
|
|
37
|
+
let excludes: HTMLElement[] = []
|
|
38
|
+
if (Array.isArray(binding.arg)) {
|
|
39
|
+
excludes = binding.arg
|
|
40
|
+
} else if (isElement(binding.arg)) {
|
|
41
|
+
// due to current implementation on binding type is wrong the type casting is necessary here
|
|
42
|
+
excludes.push(binding.arg as unknown as HTMLElement)
|
|
43
|
+
}
|
|
44
|
+
return function (mouseup, mousedown) {
|
|
45
|
+
const popperRef = (
|
|
46
|
+
binding.instance as ComponentPublicInstance<{
|
|
47
|
+
popperRef: HTMLElement
|
|
48
|
+
}>
|
|
49
|
+
).popperRef
|
|
50
|
+
const mouseUpTarget = mouseup.target as Node
|
|
51
|
+
const mouseDownTarget = mousedown?.target as Node
|
|
52
|
+
const isBound = !binding || !binding.instance
|
|
53
|
+
const isTargetExists = !mouseUpTarget || !mouseDownTarget
|
|
54
|
+
const isContainedByEl =
|
|
55
|
+
el.contains(mouseUpTarget) || el.contains(mouseDownTarget)
|
|
56
|
+
const isSelf = el === mouseUpTarget
|
|
57
|
+
|
|
58
|
+
const isTargetExcluded =
|
|
59
|
+
(excludes.length &&
|
|
60
|
+
excludes.some((item) => item?.contains(mouseUpTarget))) ||
|
|
61
|
+
(excludes.length && excludes.includes(mouseDownTarget as HTMLElement))
|
|
62
|
+
const isContainedByPopper =
|
|
63
|
+
popperRef &&
|
|
64
|
+
(popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget))
|
|
65
|
+
if (
|
|
66
|
+
isBound ||
|
|
67
|
+
isTargetExists ||
|
|
68
|
+
isContainedByEl ||
|
|
69
|
+
isSelf ||
|
|
70
|
+
isTargetExcluded ||
|
|
71
|
+
isContainedByPopper
|
|
72
|
+
) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
binding.value(mouseup, mousedown)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const ClickOutside: ObjectDirective = {
|
|
80
|
+
beforeMount(el: HTMLElement, binding: DirectiveBinding) {
|
|
81
|
+
// there could be multiple handlers on the element
|
|
82
|
+
if (!nodeList.has(el)) {
|
|
83
|
+
nodeList.set(el, [])
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
nodeList.get(el)!.push({
|
|
87
|
+
documentHandler: createDocumentHandler(el, binding),
|
|
88
|
+
bindingFn: binding.value,
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
updated(el: HTMLElement, binding: DirectiveBinding) {
|
|
92
|
+
if (!nodeList.has(el)) {
|
|
93
|
+
nodeList.set(el, [])
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const handlers = nodeList.get(el)!
|
|
97
|
+
const oldHandlerIndex = handlers.findIndex(
|
|
98
|
+
(item) => item.bindingFn === binding.oldValue
|
|
99
|
+
)
|
|
100
|
+
const newHandler = {
|
|
101
|
+
documentHandler: createDocumentHandler(el, binding),
|
|
102
|
+
bindingFn: binding.value,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (oldHandlerIndex >= 0) {
|
|
106
|
+
// replace the old handler to the new handler
|
|
107
|
+
handlers.splice(oldHandlerIndex, 1, newHandler)
|
|
108
|
+
} else {
|
|
109
|
+
handlers.push(newHandler)
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
unmounted(el: HTMLElement) {
|
|
113
|
+
// remove all listeners when a component unmounted
|
|
114
|
+
nodeList.delete(el)
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default ClickOutside
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 思路:通过简单的 el-table的 thead和tbody父级别区域,进行设置对于的fixed
|
|
3
|
+
* 1.复制一份 thead 设置为fixed,先隐藏掉。
|
|
4
|
+
* 2.创建滚动条监听事件,根据滚动条计算表格所在可视窗口位置。设置thead副本是否显示
|
|
5
|
+
* 3.创建横向滚动条的属性变化监听。当监听变化时,说明在拖动横向滚动条,需要将设置对应副本的表头位置,防止错位
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function getElParentBySelector(el, queryClassSelector) {
|
|
9
|
+
if (!el) {
|
|
10
|
+
return el
|
|
11
|
+
}
|
|
12
|
+
if ([...el.classList].includes(queryClassSelector)) {
|
|
13
|
+
return el
|
|
14
|
+
}
|
|
15
|
+
return getElParentBySelector(el.parentNode, queryClassSelector)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getTableShowWidth(thead) {
|
|
19
|
+
const tableBox = getElParentBySelector(thead, 'el-table')
|
|
20
|
+
return tableBox.getBoundingClientRect().width
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//使用setTime来确保不会重复设置
|
|
24
|
+
|
|
25
|
+
function createTableSticky(el, binding, vNode) {
|
|
26
|
+
let stickyTop = binding.value.top || 0
|
|
27
|
+
const zIndex = binding.value.zIndex || 0
|
|
28
|
+
stickyTop = parseFloat(stickyTop)
|
|
29
|
+
// 获取表格(element)
|
|
30
|
+
let thead = el.querySelector('.el-table__header')
|
|
31
|
+
thead = getElParentBySelector(thead, 'el-table__header-wrapper')
|
|
32
|
+
const tbody = el.querySelector('.el-scrollbar') || el.querySelector('.el-table__body')
|
|
33
|
+
// const tableBox = el.querySelector('.el-table__inner-wrapper')
|
|
34
|
+
|
|
35
|
+
const elBodyBox = el.querySelector('.el-table__body-wrapper')
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 插入副本元素,确保文档流不塌陷
|
|
39
|
+
*/
|
|
40
|
+
const copyThead = thead.cloneNode(true)
|
|
41
|
+
copyThead.classList.add('el-table_header-copy')
|
|
42
|
+
copyThead.style.display = 'none'
|
|
43
|
+
copyThead.style.position = 'fixed'
|
|
44
|
+
copyThead.style.zIndex = zIndex || 1994
|
|
45
|
+
copyThead.style.top = stickyTop + 'px'
|
|
46
|
+
copyThead.style.backgroundColor = '#fff'
|
|
47
|
+
copyThead.style.borderTop = '1px solid #999999'
|
|
48
|
+
|
|
49
|
+
thead.parentNode.insertBefore(copyThead, elBodyBox)
|
|
50
|
+
|
|
51
|
+
//获取thead 的显示宽度
|
|
52
|
+
const headerShowWidth = getTableShowWidth(thead)
|
|
53
|
+
|
|
54
|
+
// 获取滚动元素
|
|
55
|
+
const scrollParent = document.querySelector(binding.value.parent || 'body')
|
|
56
|
+
if (!scrollParent || binding.value.disabled === true) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
scrollParent.addEventListener('scroll', function () {
|
|
61
|
+
const theadHeight = thead.clientHeight
|
|
62
|
+
// 获取thead距离顶部的距离
|
|
63
|
+
const theadTop = thead.getBoundingClientRect().top
|
|
64
|
+
// 判断是否需要回归原来位置
|
|
65
|
+
const originally = tbody.getBoundingClientRect().top
|
|
66
|
+
// 判断底部距离是否超过表头
|
|
67
|
+
const goBeyond = tbody.getBoundingClientRect().bottom
|
|
68
|
+
|
|
69
|
+
if (theadTop <= stickyTop) {
|
|
70
|
+
copyThead.style.display = 'block'
|
|
71
|
+
copyThead.style.width =
|
|
72
|
+
(tbody.offsetWidth < headerShowWidth ? tbody.offsetWidth : headerShowWidth) + 'px'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (originally - theadHeight > stickyTop || goBeyond - theadHeight / 2 <= stickyTop) {
|
|
76
|
+
//影藏副本
|
|
77
|
+
copyThead.style.display = 'none'
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
//启动底部滚动条监控,防止横向滚动条滚动,表头没有动的问题
|
|
83
|
+
const elThumbBut = el.querySelector(
|
|
84
|
+
'.el-table__body-wrapper .el-scrollbar .el-scrollbar__bar.is-horizontal .el-scrollbar__thumb'
|
|
85
|
+
)
|
|
86
|
+
if (elThumbBut) {
|
|
87
|
+
const observer = new MutationObserver(mutationsList => {
|
|
88
|
+
for (const mutation of mutationsList) {
|
|
89
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
|
|
90
|
+
// CSS样式发生了变化
|
|
91
|
+
// 将 thumb 滚动条的
|
|
92
|
+
const transformX = elThumbBut.style.transform
|
|
93
|
+
if (transformX) {
|
|
94
|
+
copyThead.querySelector(
|
|
95
|
+
'.el-table__header'
|
|
96
|
+
).style.marginLeft = `-${transformX.replace(/[a-zA-Z()]/g, '')}`
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
//开始监听横向滚动条
|
|
102
|
+
observer.observe(elThumbBut, { attributes: true })
|
|
103
|
+
}
|
|
104
|
+
} catch (error) { }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function createSticky(vue) {
|
|
108
|
+
let clearTimeId = 0
|
|
109
|
+
// el-table表头吸顶效果
|
|
110
|
+
vue.directive('sticky', {
|
|
111
|
+
// 当被绑定的元素插入到 DOM 中时……
|
|
112
|
+
mounted(el, binding) {
|
|
113
|
+
const random = parseInt(Math.random() * 10 + '')
|
|
114
|
+
//TIP 延时设置,确保表格进行渲染成功!
|
|
115
|
+
clearTimeId = setTimeout(() => {
|
|
116
|
+
createTableSticky(el, binding)
|
|
117
|
+
// clearTimeout(clearTimeId)
|
|
118
|
+
}, 1000 + random)
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
update(el, binding) {
|
|
122
|
+
const random = parseInt(Math.random() * 10 + '')
|
|
123
|
+
//TIP 延时设置,确保表格进行渲染成功!
|
|
124
|
+
clearTimeId = setTimeout(() => {
|
|
125
|
+
createTableSticky(el, binding)
|
|
126
|
+
// clearTimeout(clearTimeId)
|
|
127
|
+
}, 1000 + random)
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
unmounted(el, binding) {
|
|
131
|
+
clearTimeId && clearTimeout(clearTimeId)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|