|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
|
|
|
|
import { throttle } from 'lodash-es'
|
|
|
|
|
import { reactive, ref, watch } from 'vue'
|
|
|
|
|
import { useInfiniteScroll } from '@vueuse/core'
|
|
|
|
|
import { useMessage } from 'naive-ui'
|
|
|
|
|
import ApprovalModal from '../modal/ApprovalModal.vue'
|
|
|
|
@ -162,43 +161,7 @@ defineExpose({
|
|
|
|
|
search,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const onKeydown = throttle((event) => {
|
|
|
|
|
const eles = ['INPUT', 'TEXTAREA']
|
|
|
|
|
if (eles.includes(event.target.tagName))
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if (event.defaultPrevented)
|
|
|
|
|
return // 如果已取消默认操作,则不应执行任何操作
|
|
|
|
|
|
|
|
|
|
const handled = false
|
|
|
|
|
if (event.key !== undefined) {
|
|
|
|
|
// 使用 KeyboardEvent.key 处理事件,并将 handled 设置为 true。
|
|
|
|
|
}
|
|
|
|
|
else if (event.keyCode !== undefined) {
|
|
|
|
|
// 使用 KeyboardEvent.keyCode 处理事件并将 handled 设置为 true。
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (handled) {
|
|
|
|
|
// 如果事件已处理,则禁止“双重操作”
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
if (event.key === 'ArrowLeft') {
|
|
|
|
|
const prev = data.value[workStore.currentIndex - 1]?.id
|
|
|
|
|
if (prev)
|
|
|
|
|
selectHandler(prev, workStore.currentIndex - 1)
|
|
|
|
|
}
|
|
|
|
|
if (event.key === 'ArrowRight') {
|
|
|
|
|
const next = data.value[workStore.currentIndex + 1]?.id
|
|
|
|
|
if (next)
|
|
|
|
|
selectHandler(next, workStore.currentIndex + 1)
|
|
|
|
|
}
|
|
|
|
|
}, 500)
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
document.addEventListener('keydown', onKeydown, true)
|
|
|
|
|
})
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
document.removeEventListener('keydown', onKeydown)
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|