Ver código fonte

05221012lhj成本监听

liuhj 1 ano atrás
pai
commit
2bf56f5746
1 arquivos alterados com 48 adições e 3 exclusões
  1. 48 3
      src/components/Finance/Cost.vue

+ 48 - 3
src/components/Finance/Cost.vue

@@ -2652,8 +2652,11 @@ export default {
             acconarr:[],
             acconarrs:[],
             isShare:0,
-            blackCodeIsTrue: false
-
+            blackCodeIsTrue: false,
+            //监听变量
+            count:0,
+            x:0,
+            y:0,
         };
     },
     watch: {
@@ -5511,7 +5514,43 @@ export default {
                 }
             })
 
+        },
+        //监听鼠标
+        MonitorMouse(){
+            document.onmousemove = (event) => {
+                let x1 = event.clientX
+                let y1 = event.clientY
+                if (this.x !== x1 || this.y !== y1) {
+                    this.count = 0
+                }
+                this.x = x1
+                this.y = y1
+            }
+        },
+        //监听键盘
+        MonitorKeyboard(){
+            document.onkeydown = () => {
+                this.count = 0;
+            }
+        },
+        //取消定时器
+        clearTimer () {
+            clearInterval(window.myTimer)
+            window.myTimer = null
+        },
+        //定时调用函数
+        setTimer () {
+            this.count = 0
+            if (!window.myTimer) {
+                window.myTimer = window.setInterval(this.cookieTimeout, 1000)
+            }
+        },
+        //执行函数
+        cookieTimeout(){
+            this.count++;
+            // console.log(this.count);
         }
+
     },
     updated() {
         this.$emit('transfer', true)
@@ -5544,7 +5583,13 @@ export default {
         }
 
         window.Vue = this;
-
+        
+        this.MonitorMouse();
+        this.MonitorKeyboard();
+        this.setTimer();
+    },
+    beforeDestroy(){
+        this.clearTimer()
     },
     computed: {
         defaultCostTypeHotelNumber() {