refactor(table): clean code

This commit is contained in:
07akioni 2021-09-03 01:10:54 +08:00
parent a715dfd545
commit 29577a22d2
2 changed files with 9 additions and 7 deletions

View File

@ -290,10 +290,12 @@ export default defineComponent({
onKeydown={handleKeyDown}
onClick={handleClick}
onMousedown={() => {
const userCallBack = window.onselectstart
window.onselectstart = () => false
const preventDefault = (e: Event): void => {
e.preventDefault()
}
window.addEventListener('selectstart', preventDefault)
setTimeout(() => {
window.onselectstart = userCallBack
window.removeEventListener('selectstart', preventDefault)
}, 0)
}}
>

View File

@ -143,12 +143,9 @@ export default defineComponent({
checked: boolean,
shiftKey: boolean
): void {
const lastKey = lastSelectedKey
lastSelectedKey = tmNode.key
if (shiftKey) {
const lastIndex = paginatedDataRef.value.findIndex(
(item) => item.key === lastKey
(item) => item.key === lastSelectedKey
)
if (lastIndex !== -1) {
const currentIndex = paginatedDataRef.value.findIndex(
@ -167,6 +164,8 @@ export default defineComponent({
} else {
doUncheck(rowKeysToCheck)
}
lastSelectedKey = tmNode.key
return
}
}
@ -175,6 +174,7 @@ export default defineComponent({
} else {
doUncheck(tmNode.key)
}
lastSelectedKey = tmNode.key
}
function getScrollContainer (): HTMLElement | null {
if (virtualScrollRef.value) {