Selaa lähdekoodia

Merge branch 'master' of http://132.232.92.186:3000/XinXiBu/oa-system

liuhj 11 kuukautta sitten
vanhempi
commit
64ed0db6eb
1 muutettua tiedostoa jossa 50 lisäystä ja 31 poistoa
  1. 50 31
      src/components/Finance/Cost.vue

+ 50 - 31
src/components/Finance/Cost.vue

@@ -41,8 +41,9 @@
                         <el-button size="small" type="primary" @click="GetClientWord">导出客户报表</el-button>
                         <el-button size="small" type="primary" @click="GetGroupCostExcel">导出成本</el-button>
                         <!-- <el-button type="primary">一键复制</el-button> -->
-                        <el-button v-if="isShare==1" size="small" type="info" @click="GroupIsShare">取消成本通知</el-button>
-                        <el-button v-if="isShare==0" size="small" type="primary" @click="GroupIsShare">成本通知</el-button>
+                        <el-button v-if="isShare == 1" size="small" type="info" @click="GroupIsShare">取消成本通知</el-button>
+                        <el-button v-if="isShare == 0" size="small" type="primary"
+                            @click="GroupIsShare">成本通知</el-button>
                         <el-button size="small" type="primary" @click="save">保存设置</el-button>
                     </div>
                 </div>
@@ -2661,16 +2662,16 @@ export default {
                 }
             ],
             autoSave: null,
-            acconarr:[],
-            acconarrs:[],
-            isShare:0,
+            acconarr: [],
+            acconarrs: [],
+            isShare: 0,
             blackCodeIsTrue: false,
             dialogTableVisible:false,
             gridData:[],
             //监听变量
-            count:0,
-            x:0,
-            y:0,
+            //count: 0,
+            x: 0,
+            y: 0,
         };
     },
     watch: {
@@ -3183,7 +3184,7 @@ export default {
                         var acostvalue = resp.data.data.groupCostParameter.filter(x => x.costType == 'A')[0];
                         if (acostvalue != undefined) {
                             that.AGroupCostParameter = acostvalue;
-                            that.isShare=that.AGroupCostParameter.isShare;//是否通知
+                            that.isShare = that.AGroupCostParameter.isShare;//是否通知
                             console.log(that.AGroupCostParameter)
                             var result = Number(that.AGroupCostParameter.currency);
                             if (isNaN(result)) {
@@ -4567,7 +4568,7 @@ export default {
             }).then(resp => {
                 ////console.log(resp.data.data, '------------------------------------');
                 if (resp.data.code == 200) {
-                    this.isShare=resp.data.data.isShare;
+                    this.isShare = resp.data.data.isShare;
                     this.$message({
                         message: '操作成功!' + resp.data.msg,
                         type: 'success'
@@ -5548,41 +5549,59 @@ export default {
             this.dialogTableVisible=false;
         },
         //监听鼠标
-        MonitorMouse(){
+        MonitorMouse() {
             document.onmousemove = (event) => {
                 let x1 = event.clientX
                 let y1 = event.clientY
                 if (this.x !== x1 || this.y !== y1) {
-                    this.count = 0
+                    this.setTimer();
                 }
                 this.x = x1
                 this.y = y1
             }
         },
         //监听键盘
-        MonitorKeyboard(){
+        MonitorKeyboard() {
             document.onkeydown = () => {
-                this.count = 0;
+                this.setTimer();
             }
         },
         //取消定时器
-        clearTimer () {
-            clearInterval(window.myTimer)
+        clearTimer() {
+            clearTimeout(window.myTimer)
             window.myTimer = null
+            //取消监听
+            document.onmousemove = null;
+            document.onkeydown = null;
         },
         //定时调用函数
-        setTimer () {
+        setTimer() {
             this.count = 0
-            if (!window.myTimer) {
-                window.myTimer = window.setInterval(this.cookieTimeout, 1000)
+            const mm = 1000 * 60;
+            if (window.myTimer) {
+                try {
+                    clearTimeout(window.myTimer);
+                } catch (e) {
+                    console.log("setTimerMessage", e.message);
+                }
             }
+            window.myTimer = setInterval(this.SaveAndLogOut, mm * 30);
         },
-        //执行函数
-        cookieTimeout(){
-            this.count++;
-            // console.log(this.count);
+        SaveAndLogOut() {
+            this.save().then(() => {
+                this.$router.push({ name: 'Login' })
+                localStorage.removeItem("userinif");
+                this.$message({
+                    type: 'success',
+                    message: '已退出!'
+                });
+                console.log("保存成功,已退出!");
+            }).catch(e => {
+                console.log(e);
+                console.log("保存失败,仅停止自动保存!");
+                clearInterval(this.autoSave);
+            })
         }
-
     },
     updated() {
         this.$emit('transfer', true)
@@ -5602,10 +5621,14 @@ export default {
                 setTimeout(() => {
                     this.save();
                 }, 100);
-            }, mm * 3);
+            }, mm * 10);
+
+            this.MonitorMouse();
+            this.MonitorKeyboard();
+            this.setTimer();
         }
 
-        document.querySelectorAll('.el-table__footer')[0].style.display = "none"
+        document.querySelectorAll('.el-table__footer')[0].style.display = "none";
         if (costLoadData) {
             var JSONP = JSON.parse(costLoadData);
             var diidP = Number(JSONP.diid);
@@ -5615,12 +5638,8 @@ export default {
         }
 
         window.Vue = this;
-        
-        this.MonitorMouse();
-        this.MonitorKeyboard();
-        this.setTimer();
     },
-    beforeDestroy(){
+    beforeDestroy() {
         this.clearTimer()
     },
     computed: {