|
@@ -260,7 +260,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {ref, watch, nextTick, onUnmounted} from "vue";
|
|
|
+import {ref, watch, nextTick, onActivated, onDeactivated, onMounted, onUnmounted} from "vue";
|
|
|
import {useAppStore} from "~src/store";
|
|
|
import wbsApi from "~api/data-fill/wbs"
|
|
|
import HcUpload from "../components/HcUpload.vue"
|
|
@@ -404,11 +404,12 @@ watch(() => [
|
|
|
})
|
|
|
|
|
|
//渲染完成
|
|
|
-nextTick(() => {
|
|
|
+onMounted(() => {
|
|
|
setFormDataNum(props.datas)
|
|
|
setTableFormMenu(useAppState.projectInfo)
|
|
|
const {offsetHeight} = document.body
|
|
|
DragModalHeight.value = offsetHeight - 200
|
|
|
+ setMountKey_down_up()
|
|
|
})
|
|
|
|
|
|
//处理变动的数据
|
|
@@ -1149,41 +1150,64 @@ const excelTableFormClick = (key) => {
|
|
|
presentId.value = key
|
|
|
}
|
|
|
|
|
|
-//全局按键按下监听
|
|
|
-document.onkeydown = async (event) => {
|
|
|
- const pkeyId = presentId.value
|
|
|
- if (!isValueNull(pkeyId)) {
|
|
|
- const {key, ctrlKey} = event
|
|
|
- //按下ctrl键
|
|
|
- if (ctrlKey && key === 'Control') {
|
|
|
- const refs = await getFormRef(pkeyId)
|
|
|
- refs?.setIsCtrlKey(true)
|
|
|
- }
|
|
|
- //按下复制快捷键
|
|
|
- if (ctrlKey && key === 'c') {
|
|
|
- const refs = await getFormRef(pkeyId)
|
|
|
- refs?.setCopyKeyList(event)
|
|
|
+//缓存被激活时
|
|
|
+onActivated(() => {
|
|
|
+ setMountKey_down_up()
|
|
|
+})
|
|
|
+
|
|
|
+//缓存时被移除
|
|
|
+onDeactivated(() => {
|
|
|
+ setUnloadKey_down_up()
|
|
|
+})
|
|
|
+
|
|
|
+//页面被卸载
|
|
|
+onUnmounted(() => {
|
|
|
+ setUnloadKey_down_up()
|
|
|
+})
|
|
|
+
|
|
|
+const setMountKey_down_up = () => {
|
|
|
+ //全局按键按下监听
|
|
|
+ document.onkeydown = async (event) => {
|
|
|
+ const pkeyId = presentId.value
|
|
|
+ console.log('按下' + event.key + '键')
|
|
|
+ if (!isValueNull(pkeyId)) {
|
|
|
+ const {key, ctrlKey} = event
|
|
|
+ //按下ctrl键
|
|
|
+ if (ctrlKey && key === 'Control') {
|
|
|
+ const refs = await getFormRef(pkeyId)
|
|
|
+ refs?.setIsCtrlKey(true)
|
|
|
+ }
|
|
|
+ //按下复制快捷键
|
|
|
+ if (ctrlKey && key === 'c') {
|
|
|
+ const refs = await getFormRef(pkeyId)
|
|
|
+ refs?.setCopyKeyList(event)
|
|
|
+ }
|
|
|
+ //按下粘贴快捷键
|
|
|
+ if (ctrlKey && key === 'v') {
|
|
|
+ const refs = await getFormRef(pkeyId)
|
|
|
+ await refs?.setPasteKeyList(event)
|
|
|
+ }
|
|
|
}
|
|
|
- //按下粘贴快捷键
|
|
|
- if (ctrlKey && key === 'v') {
|
|
|
- const refs = await getFormRef(pkeyId)
|
|
|
- await refs?.setPasteKeyList(event)
|
|
|
+ }
|
|
|
+ //全局键盘放开监听
|
|
|
+ document.onkeyup = async (event) => {
|
|
|
+ const pkeyId = presentId.value
|
|
|
+ if (!isValueNull(pkeyId)) {
|
|
|
+ const {key, ctrlKey} = event
|
|
|
+ if (!ctrlKey && key === 'Control') {
|
|
|
+ const refs = await getFormRef(pkeyId)
|
|
|
+ refs?.setIsCtrlKey(false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//全局键盘放开监听
|
|
|
-document.onkeyup = async (event) => {
|
|
|
- const pkeyId = presentId.value
|
|
|
- if (!isValueNull(pkeyId)) {
|
|
|
- const {key, ctrlKey} = event
|
|
|
- if (!ctrlKey && key === 'Control') {
|
|
|
- const refs = await getFormRef(pkeyId)
|
|
|
- refs?.setIsCtrlKey(false)
|
|
|
- }
|
|
|
- }
|
|
|
+const setUnloadKey_down_up = () => {
|
|
|
+ document.onkeydown = null
|
|
|
+ document.onkeyup = null
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//获取已渲染的表单
|
|
|
const getFilterFormData = async () => {
|
|
|
const formArr = formDataList.value;
|
|
@@ -1241,13 +1265,6 @@ const setActiveKey = (key) => {
|
|
|
return ActiveKey.value = key;
|
|
|
}
|
|
|
|
|
|
-//卸载页面
|
|
|
-onUnmounted(() => {
|
|
|
- console.log('卸载页面')
|
|
|
- document.onkeydown = null
|
|
|
- document.onkeyup = null
|
|
|
-})
|
|
|
-
|
|
|
// 暴露出去
|
|
|
defineExpose({
|
|
|
getFormData,
|