likang 2 years ago
parent
commit
84dbbfc978
1 changed files with 45 additions and 69 deletions
  1. 45 69
      src/views/tag_history/index.vue

+ 45 - 69
src/views/tag_history/index.vue

@@ -39,21 +39,19 @@
             class="filter-item form-search-input fl"
           />
        
-         <el-button v-show="start"
+         <el-button v-show="!start"
           class="filter-item search fl"
           icon="el-icon-video-play"
-          type="warning"
           @click="beforehandleSearch"
-          >开始计时</el-button
+          >清除</el-button
         >
 
-        <el-button v-show="!start"
+        <el-button v-show="start"
           class="filter-item fl"
-          type="danger"
-          icon="el-icon-video-pause
-"
+          icon="el-icon-video-pause"
+          type="warning"
           @click="beforhandleRefresh"
-          > 结束</el-button
+          > 暂停</el-button
         >
       
 
@@ -128,7 +126,7 @@
         :show-overflow-tooltip="true"
       />
   
-      <el-table-column
+      <!-- <el-table-column
         label="操作"
         min-width="120"
         align="center"
@@ -140,11 +138,11 @@
             <el-button type="primary" size="mini" icon="el-icon-data-line" @click="handleDetail(record.row)" ></el-button>
             
         </template>
-      </el-table-column>
+      </el-table-column> -->
     </el-table>
 
     
-    <el-pagination
+    <!-- <el-pagination
       background
       class="pagination-container"
       @size-change="handleSizeChange"
@@ -155,7 +153,7 @@
       :layout="paginate.layout"
       :total="paginate.total"
     />
-    
+     -->
     <detail
       :detailVisible="detailVisible"
        @sendVal="closeDrawer"
@@ -199,14 +197,20 @@ export default {
       //搜索
       searchDisplay: true,
       departments: [],
-
+      //是否结束
+      is_end :false,
+      is_suspended: false,
       //详情
       detailVisible:false,
       detail:{},
       //定时器
       refreshTageAndStation: '',
       //计时
-      timer: '00:00:00',
+
+      //当前浏览器时间
+      back_time: '',
+      //前端时间
+      front_time:'',
       //定时请求数据
       refreshData:'',
 
@@ -225,11 +229,12 @@ export default {
     };
   },
   created() {
-    this.getTime();
+    this.get_back_time();
     this.refreshTagAndSta();
   
   },
   mounted() { 
+    this.getTime();
     this.refreshTageAndStation = setInterval(() => {
       this.refreshTagAndSta()
     }, 1000 * 4);
@@ -239,7 +244,6 @@ export default {
         this.getData()
       }, 1000 * 2);
     
-  
   },
   beforeDestroy() {
     clearInterval(this.refreshTageAndStation);
@@ -260,8 +264,6 @@ export default {
       });
 
     },
-  
-
 
     hydraulicSelectMulti(data) {
       this.selectedIds = [];
@@ -285,82 +287,50 @@ export default {
       this.detailVisible = false
     },
     beforehandleSearch() {
-     
-      this.start = false;
+      this.is_suspended = false;
+      this.data = [];
+      this.start = true;
       this.getTime();
-      this.timetool();
-      this.handleSearch(); 
-
       clearInterval(this.refreshData);
       this.refreshData = null;
+      this.getData();
       this.refreshData =
         setInterval(() => {
           this.getData()
         }, 1000 * 2);
      
     },
+    //暂停
     beforhandleRefresh()
     {
+      this.is_suspended = true;
       clearInterval(this.refreshData);
       clearInterval(this.refreshTime);
       this.refreshData = null;
       this.refreshTime = null
-      this.start = true
-
+      this.start = false
       //this.handleRefresh()
     },
+
     getTime()
     {
-      let times = null;
+     
+      this.queryParam.time = this.back_time + (parseInt(new Date().getTime() / 1000) - this.front_time);
+    },
+    get_back_time()
+    {
       this.$http.get("getTime").then((response) => {
-        this.queryParam.time = response.data;
+        this.back_time = response.data;
+        this.front_time = parseInt(new Date().getTime() / 1000);
       });
-     
+        
     },
     handleChange(val) {
       //  console.log(val)
       this.queryParam.department_id = val;
       this.handleSearch();
     },
-    timetool()
-    {
-      var i, j, k,i1,j1,k1;
 
-      i = 0;
-
-      j = 0;
-
-      k = 0;
-
-     this.refreshTime = setInterval(function () {
-
-          k++;
-          if (k > 59) {
-
-            k = 0;
-
-            j++;
-
-           
-            if (j > 59) {
-
-              j = 0;
-
-              i++;
-
-             
-
-            };
-    
-          };
-      
-       this.timer = i + ':' + j + ':' + k;
-       //this.$set(this.timer, 'timer', i1 + ':' + j1 + ':' + k1)
-
-  }, 1000);
-
-  
-    },
     refresh() {
       this.queryParam = {
         mac: "",
@@ -375,10 +345,16 @@ export default {
     getData()
     {
       
-        const query = this.queryParam
+      const query = this.queryParam;
         this.$http.get(this.url, { params: query }).then(response => {
-
-          this.data = response.data
+          if (this.is_suspended)
+          {
+            console.log('已经暂停');
+          }
+          else
+          {
+            this.data = response.data;
+          }
           this.handlePaginateResponse(response)
           if (this.afterGetList !== undefined) {
             this.afterGetList()