Merge pull request 'fix: 图检审批左右键异常处理' (#248) from 20240420keydown into test

Reviewed-on: #248
pull/250/head
yaoshuli 1 year ago
commit 94b4e1dc3b

@ -2,7 +2,9 @@ import { getApprovalList } from '@/api/task/task'
import { store } from '@/store' import { store } from '@/store'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import type { TaskState } from '/#/task' import type { TaskState } from '/#/task'
import { createDiscreteApi } from 'naive-ui'
const {message} = createDiscreteApi(['message'])
export const useTaskStore = defineStore({ export const useTaskStore = defineStore({
id: 'task-store', id: 'task-store',
state: (): TaskState => ({ state: (): TaskState => ({
@ -42,13 +44,13 @@ export const useTaskStore = defineStore({
const len = this.approvalList.length const len = this.approvalList.length
if (this.currentIndex === len - 1) if (this.currentIndex === len - 1)
return return message.error('已经到达最后一个')
this.setActive(++this.currentIndex) this.setActive(++this.currentIndex)
}, },
back() { back() {
if (this.currentIndex === 0) if (this.currentIndex === 0)
return return message.error('已经到达第一个')
this.setActive(--this.currentIndex) this.setActive(--this.currentIndex)
}, },

@ -1,7 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { import {
computed, computed,
nextTick,
onMounted, onMounted,
onUnmounted, onUnmounted,
reactive, reactive,
@ -112,8 +111,6 @@ const fullscreenStylestwo = computed<any>(() => ({
zIndex: isFullScreen.value ? '160' : '', zIndex: isFullScreen.value ? '160' : '',
})) }))
onMounted(() => { onMounted(() => {
window.addEventListener('keydown', handleKeydown)
if (route.query.id) { if (route.query.id) {
taskId.value = route.query.id taskId.value = route.query.id
packageId.value = route.query.packageid packageId.value = route.query.packageid
@ -123,40 +120,14 @@ onMounted(() => {
} }
}) })
let lastKeyPressTime = 0
let keyPressTimer = null
function changeimgbigshow() { function changeimgbigshow() {
imgbigshow.value = !imgbigshow.value imgbigshow.value = !imgbigshow.value
} }
const doubleClickInterval = 300 //
// //
function handleKeydown(event) { useKeydown('right', forwardHandler)
if (event.key === 'ArrowLeft') { useKeydown('left', backHandler)
backHandler() useKeydown('p p', () => {
} const item = taskDetailInfo.value
//
else if (event.key === 'ArrowRight') {
forwardHandler()
}
//
else if (event.keyCode === 67) {
isFullScreen.value = false
// batchModalRef.value.closeModal()
}
else if (event.keyCode === 27) {
overTask.value = null
overTasktwo.value = null
}
else if (event.key === 'p' || event.key === 'P') {
//
const now = Date.now()
//
if (now - lastKeyPressTime < doubleClickInterval) {
//
clearTimeout(keyPressTimer)
const item = taskDetailInfo.value
if (item?.userapprove?.statshis === 2 || item?.userapprove?.statshis == 3) { if (item?.userapprove?.statshis === 2 || item?.userapprove?.statshis == 3) {
overTask.value = null overTask.value = null
return return
@ -166,32 +137,10 @@ function handleKeydown(event) {
overTask.value = item overTask.value = item
// //
approvalHandler() approvalHandler()
})
// useKeydown('x x', () => {
lastKeyPressTime = 0 const item = taskDetailInfo.value
} if (item?.userapprove?.statshis === 2 || item?.userapprove?.statshis == 3) {
else {
//
lastKeyPressTime = now
//
//
clearTimeout(keyPressTimer)
keyPressTimer = setTimeout(() => {
lastKeyPressTime = 0
}, doubleClickInterval)
}
}
else if (event.key === 'x' || event.key === 'X') {
//
const now = Date.now()
//
if (now - lastKeyPressTime < doubleClickInterval) {
//
clearTimeout(keyPressTimer)
const item = taskDetailInfo.value
if (item?.userapprove?.statshis === 2 || item?.userapprove?.statshis == 3) {
overTask.value = null overTask.value = null
return return
} }
@ -201,23 +150,8 @@ function handleKeydown(event) {
// //
const modal = unref(notPassModalRef)! as any const modal = unref(notPassModalRef)! as any
modal.showModal([taskDetailInfo.value]) modal.showModal([taskDetailInfo.value])
})
//
lastKeyPressTime = 0
}
else {
//
lastKeyPressTime = now
//
//
clearTimeout(keyPressTimer)
keyPressTimer = setTimeout(() => {
lastKeyPressTime = 0
}, doubleClickInterval)
}
}
}
function setBatch(value: boolean) { function setBatch(value: boolean) {
// if (totalCount.value === 0) // if (totalCount.value === 0)
@ -484,7 +418,6 @@ function showActionsModal() {
onUnmounted(() => { onUnmounted(() => {
taskStore.reset() taskStore.reset()
window.removeEventListener('keydown', handleKeydown)
window.removeEventListener('scroll', checkBottom) window.removeEventListener('scroll', checkBottom)
}) })

Loading…
Cancel
Save