Merge pull request 'feat: 按键事件处理' (#190) from fix/keyhandler into test

Reviewed-on: #190
pull/191/head
李忠 1 year ago
commit 848ecd9838

@ -16,7 +16,7 @@ import { useInfiniteScroll } from '@vueuse/core'
import { format } from 'date-fns'
import imagesloaded from 'imagesloaded'
import { clone, cloneDeep, debounce, pickBy } from 'lodash-es'
import { useDialog, useMessage } from 'naive-ui'
import { useDialog, useMessage, useModal } from 'naive-ui'
import {
computed,
onMounted,
@ -279,18 +279,27 @@ function overTaskHandelr(item: any) {
function leaveTaskHandler() {
overTask.value = null
}
function onEsc(event) {
function onEsc(event: KeyboardEvent) {
const eles = ['INPUT', 'TEXTAREA']
const keys = ['KeyC', 'KeyP', 'KeyX']
const code = event.code
if (eles.includes(event.target.targName))
if (!(event.target instanceof Element))
return
if (eles.includes(event.target.tagName))
return
if (!keys.includes(event.code))
return
if (event.code === 'KeyC') {
if (isFullScreen.value && !document.querySelector('.n-modal-container')) {
//
const modalClasss = [
document.querySelector('.n-modal'),
document.querySelector('.n-dialog'),
]
const hasModal = modalClasss.some(i => i)
if (isFullScreen.value && !hasModal) {
isFullScreen.value = false
return
}
else {
const notPassModal = unref(notPassModalRef)! as any
@ -299,6 +308,7 @@ function onEsc(event) {
mainImageModal.closeModal(false)
confrimModal.closeModal(false)
notPassModal.closeModal(false)
dialog.destroyAll()
}
}
//
@ -326,19 +336,12 @@ function onEsc(event) {
}
}
function resizeImage() {
const container = document.querySelector('.image-container')!
const containerWidth = container.offsetWidth
const containerHeight = container.offsetHeight
}
onUnmounted(() => {
workStore.reset()
document.removeEventListener('keydown', onEsc)
})
onMounted(() => {
document.addEventListener('keydown', onEsc)
window.addEventListener('resize', resizeImage)
})
function immersionHandler() {
// class="wrapper"
@ -539,6 +542,14 @@ function handleRejectdubiousfileyd(pictureid) {
onPositiveClick: () => {
dubiousfileyd(pictureid).then(() => {
refreshHandler()
const packageid = workStore.getActiveId
if (isEmpty(packageid)) {
listData.value.length = 0
totalCount.value = 0
taskDetailInfo.value = {}
return
}
queryDetail(packageid)
})
},
onNegativeClick: () => {},

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { difference } from 'lodash-es'
import { computed, defineEmits, defineProps, onMounted, ref, watch } from 'vue'
import { computed, defineEmits, defineProps, onMounted, onUnmounted, ref, watch } from 'vue'
import { VueDraggable } from 'vue-draggable-plus'
import { getAllfieldList, getfieldList, savefield } from '@/api/home/filter'
import { workPackageMap } from '@/config/workorder'
@ -36,6 +36,9 @@ const showOffList = computed(() => {
const showFixList = computed(() => {
return fixList.value.filter(i => i.name.includes(searchFixVal.value))
})
const showOnList = computed(() => {
return onList.value.filter(i => i.name.includes(searchFixVal.value))
})
const selectCount = computed(() => {
return `显示字段(共${onList.value.length}个)`
})
@ -315,11 +318,24 @@ async function getData() {
}
})
}
function handleKeydown(event: KeyboardEvent) {
//
const eles = ['INPUT', 'TEXTAREA']
if (!(event.target instanceof Element))
return
if (eles.includes(event.target.tagName))
return
if (event.code === 'KeyC')
closeModal()
}
onMounted(async () => {
getData()
document.addEventListener('keydown', handleKeydown)
})
onUnmounted(() => {
document.removeEventListener('keydown', handleKeydown)
})
const indeterminate = computed(() => {
let baseNum = 0
offList.value.map((v) => {
@ -418,13 +434,13 @@ const indeterminate = computed(() => {
</div>
</div>
<VueDraggable
v-model="onList"
v-model="showOnList"
class="draggable-ul"
:animation="150"
group="shared"
>
<div
v-for="item in onList"
v-for="item in showOnList"
:key="item.id"
:class="{ fix: item.fix }"
class="cursor-move draggable-item"

Loading…
Cancel
Save