Explorar o código

加esc回退页面

@dongkboy hai 4 meses
pai
achega
e61a8624e1
Modificáronse 1 ficheiros con 16 adicións e 1 borrados
  1. 16 1
      src/views/finance/modules/auditDetail.vue

+ 16 - 1
src/views/finance/modules/auditDetail.vue

@@ -799,6 +799,7 @@
 </template>
 
 <script setup lang="ts">
+import { ref, onMounted, onUnmounted, nextTick } from 'vue'
 import toubao from '@/assets/images/additional/quote1.png'
 import cheliang from '@/assets/images/insurancePolicy/cheliang.png'
 import guanxi from '@/assets/images/insurancePolicy/guanxi.png'
@@ -1130,11 +1131,25 @@ const getCostDetail = () => {
 
 let isShow = ref('0')
 
+// 键盘事件处理
+const handleKeydown = (event) => {
+    if (event.key === 'Escape') {
+        myRouter.back()
+    }
+}
+
 onMounted(() => {
     console.log(123123, typeof myRoute.query.isShow)
     isShow.value = myRoute.query.isShow
     initDetail();
     initOption();
+    // 添加键盘事件监听器
+    window.addEventListener('keydown', handleKeydown)
+})
+
+onUnmounted(() => {
+    // 移除键盘事件监听器
+    window.removeEventListener('keydown', handleKeydown)
 })
 
 </script>
@@ -1568,4 +1583,4 @@ onMounted(() => {
             display: none;
         }
     }
-</style>
+</style>