Selaa lähdekoodia

三个列表的计时器刷新优化

ronaldo9Zhang 2 vuotta sitten
vanhempi
commit
8b10b8686e

+ 10 - 7
src/views/systemManagement/sceneUploadList.vue

@@ -9,7 +9,7 @@
                     clearable
                     placeholder="请输入"
                     maxlength="60"
-                    @keyup.enter.native="doSearch"
+                    @keyup.enter.native="doSearch(false)"
                 >
                 </el-input>
             </template>
@@ -47,7 +47,7 @@
             </template>
 
             <template slot="searchBtn1">
-                <el-button type="primary" @click="doSearch">查询</el-button>
+                <el-button type="primary" @click="doSearch(false)">查询</el-button>
             </template>
             <template slot="searchBtn2">
                 <el-button type="primary" @click="doReset">重置</el-button>
@@ -309,7 +309,7 @@ export default {
     },
 
     methods: {
-        doSearch() {
+        doSearch(isTimer = false) {
             // if (this.uploadDate) {
             //     this.searchParams.timeBegin = `${this.uploadDate[0]}`;
             //     this.searchParams.timeEnd = `${this.uploadDate[1]}`;
@@ -337,14 +337,17 @@ export default {
                 name: this.searchParams.name,
                 timeBegin,
                 timeEnd,
-                resetPageNum: this.pagination.currentPage || 1,
+                resetPageNum: !isTimer ? false : (this.pagination.currentPage || 1),
             };
+
+            if(!isTimer) this.pagination.currentPage = 1;
+
             this.refreshList(pageMap);
 
             if (this.timer) clearInterval(this.timer);
 
             this.timer = setInterval(() => {
-                if (this.$refs["table"]) this.doSearch();
+                if (this.$refs["table"]) this.doSearch(true);
             }, 1000 * 60);
         },
         //刷新table
@@ -360,7 +363,7 @@ export default {
                 timeEnd: "",
             };
             // this.uploadDate = "";
-            this.doSearch();
+            this.doSearch(false);
         },
         addOne() {
             this.form = {
@@ -477,7 +480,7 @@ export default {
         if (this.timer) clearInterval(this.timer);
 
         this.timer = setInterval(() => {
-            if (this.$refs["table"]) this.doSearch();
+            if (this.$refs["table"]) this.doSearch(true);
         }, 1000 * 60);
 
         await this.$dicsListsInit({

+ 11 - 8
src/views/workManagement/autoRunProjectList.vue

@@ -10,7 +10,7 @@
                         clearable
                         placeholder="请输入"
                         maxlength="60"
-                        @keyup.enter.native="doSearch"
+                        @keyup.enter.native="doSearch(false)"
                     >
                     </el-input>
                 </template>
@@ -22,7 +22,7 @@
                         clearable
                         placeholder="请输入"
                         maxlength="60"
-                        @keyup.enter.native="doSearch"
+                        @keyup.enter.native="doSearch(false)"
                     >
                     </el-input>
                 </template>
@@ -60,7 +60,7 @@
                 </template>
 
                 <template slot="searchBtn1">
-                    <el-button type="primary" @click="doSearch">查询</el-button>
+                    <el-button type="primary" @click="doSearch(false)">查询</el-button>
                 </template>
                 <template slot="searchBtn2">
                     <el-button type="primary" @click="doReset">重置</el-button>
@@ -221,7 +221,7 @@ export default {
     },
     
     methods: {
-        doSearch() {
+        doSearch(isTimer = false) {
             let createStartDate = "";
             if (this.searchParams.createStartDate) {
                 createStartDate = `${this.searchParams.createStartDate} 00:00:00`;
@@ -246,14 +246,17 @@ export default {
                 projectName: this.searchParams.projectName,
                 createStartDate,
                 createEndDate,
-                resetPageNum: this.pagination.currentPage || 1,
+                resetPageNum: !isTimer ? false : (this.pagination.currentPage || 1),
             };
+
+            if(!isTimer) this.pagination.currentPage = 1;
+
             this.refreshList(pageMap);
 
             if (this.timer) clearInterval(this.timer);
 
             this.timer = setInterval(() => {
-                if (this.$refs["table"]) this.doSearch();
+                if (this.$refs["table"]) this.doSearch(true);
             }, 1000 * 60);
         },
         //刷新table
@@ -270,7 +273,7 @@ export default {
                 createEndDate: "",
             };
             // this.createDate = "";
-            this.doSearch();
+            this.doSearch(false);
         },
         addOne() {
             this.$router.push({ path: "/autoRunProjectDetail" });
@@ -414,7 +417,7 @@ export default {
         if (this.timer) clearInterval(this.timer);
 
         this.timer = setInterval(() => {
-            if (this.$refs["table"]) this.doSearch();
+            if (this.$refs["table"]) this.doSearch(true);
         }, 1000 * 60);
     },
 

+ 12 - 8
src/views/workManagement/manualRunProjectList.vue

@@ -10,7 +10,7 @@
                         clearable
                         placeholder="请输入"
                         maxlength="60"
-                        @keyup.enter.native="doSearch"
+                        @keyup.enter.native="doSearch(false)"
                     >
                     </el-input>
                 </template>
@@ -22,7 +22,7 @@
                         clearable
                         placeholder="请输入"
                         maxlength="60"
-                        @keyup.enter.native="doSearch"
+                        @keyup.enter.native="doSearch(false)"
                     >
                     </el-input>
                 </template>
@@ -114,7 +114,7 @@
                 </template>
 
                 <template slot="searchBtn1">
-                    <el-button type="primary" @click="doSearch">查询</el-button>
+                    <el-button type="primary" @click="doSearch(false)">查询</el-button>
                 </template>
                 <template slot="searchBtn2">
                     <el-button type="primary" @click="doReset">重置</el-button>
@@ -349,7 +349,8 @@ export default {
         };
     },
     methods: {
-        doSearch() {
+        // 若是有鼠标、键盘等操作事件,需要给定isTimer,否则该参数为交互事件
+        doSearch(isTimer = false) {
             // if (this.createDate) {
             //     this.searchParams.createStartDate = `${this.createDate[0]}`;
             //     this.searchParams.createEndDate = `${this.createDate[1]}`;
@@ -413,14 +414,17 @@ export default {
                 createEndDate,
                 finishDateStart,
                 finishDateEnd,
-                resetPageNum: this.pagination.currentPage || 1,
+                resetPageNum: !isTimer ? false : (this.pagination.currentPage || 1),
             };
+
+            if(!isTimer) this.pagination.currentPage = 1;
+
             this.refreshList(pageMap);
 
             if (this.timer) clearInterval(this.timer);
 
             this.timer = setInterval(() => {
-                if (this.$refs["table"]) this.doSearch();
+                if (this.$refs["table"]) this.doSearch(true);
             }, 1000 * 60);
         },
         //刷新table
@@ -442,7 +446,7 @@ export default {
             };
             // this.createDate = "";
             // this.finishDate = "";
-            this.doSearch();
+            this.doSearch(false);
         },
         addOne() {
             this.$router.push({ path: "/manualRunProjectDetail" });
@@ -632,7 +636,7 @@ export default {
         if (this.timer) clearInterval(this.timer);
 
         this.timer = setInterval(() => {
-            if (this.$refs["table"]) this.doSearch();
+            if (this.$refs["table"]) this.doSearch(true);
         }, 1000 * 60);
 
         // console.log(666);