Browse Source

增加多井巡查功能

chenwen 2 years ago
parent
commit
64c3b7fab0
2 changed files with 43 additions and 18 deletions
  1. 40 8
      src/components/crudtable/PatrolTable.vue
  2. 3 10
      src/pages/multi/multiPatrol.vue

+ 40 - 8
src/components/crudtable/PatrolTable.vue

@@ -32,7 +32,7 @@
 </template>
 
 <script setup>
-	import {reactive,ref,onMounted,toRaw,watch} from 'vue'
+	import {reactive,ref,onMounted,onUnmounted,toRaw,watch} from 'vue'
 	import request from '../../utils/request'
 	import { ElMessage } from "element-plus"
 	
@@ -53,7 +53,10 @@
 			default:true
 		},
 		beforeBindData:Function,
-		autoTurnPageInterval:Number
+		autoTurnPageInterval:{
+			type:Number,
+			default:10
+		}
 	})
 	
 	const pagination=reactive({
@@ -66,7 +69,7 @@
 	
 	const isLoading=ref(false)
 	const tableDatas=ref([])
-	
+	let turnTimer=null
 	
 	onMounted(()=>{
 		
@@ -76,6 +79,13 @@
 		else{
 			tableDatas.value=props.datas
 		}
+		
+	})
+	
+	onUnmounted(()=>{
+		if(turnTimer){
+			clearInterval(turnTimer)
+		}
 	})
 	
 	let _queryParam={}
@@ -109,16 +119,18 @@
 	const query=(queryParams)=>{
 		pagination.watchReload=false
 		pagination.currentPage=1  //新的查询页码重置为1,禁止通过监听自动查询,手动查询,便于外部接收查询状态
-		return load(queryParams)
+		//return load(queryParams)
+		load(queryParams).then(resp=>{autoTurnPage()})
 	} 
 	
 	const load=async (queryParams)=>{
 		//console.log('query...')
 		isLoading.value=true
+		_queryParam=queryParams||{}
 		try{
 			let resp=await request({url: props.url,method: 'post',data: getReqParam(queryParams)})
 			isLoading.value=false
-			console.log(resp)
+			//console.log(resp)
 			pagination.watchReload=true				
 			//pagination.currentPage=resp.currentPage
 			
@@ -126,7 +138,7 @@
 				tableDatas.value=props.beforeBindData?props.beforeBindData(resp.data.data):resp.data.data
 				pagination.totalRows=resp.data.totalRow
 				pagination.pageCount = resp.data.pageCount
-				_queryParam=queryParams||{}
+				
 				
 				return 0
 			}
@@ -139,7 +151,7 @@
 		catch (e) {
 			pagination.watchReload=true
 			isLoading.value=false
-			ElMessage.error("加载数据失败");
+			//ElMessage.error("加载数据失败");
 		    console.log(e)
 			return -1
 		}
@@ -149,8 +161,28 @@
 	const indexGenerate=(index)=>{
 		return (pagination.currentPage-1) * pagination.pageSize + index + 1
 	}
-		
 	
+	//自动翻页巡查
+	const autoTurnPage=()=>{
+		if(turnTimer){
+			clearInterval(turnTimer)
+		}
+		let inter=props.autoTurnPageInterval<10?10:props.autoTurnPageInterval
+		turnTimer=setInterval(()=>{
+			if(pagination.currentPage==pagination.pageCount){
+				if(pagination.pageCount==1){  //本身只有1页,通过手动重加载
+					load(_queryParam)
+				}
+				else{ //否则更改页码,通过监听自动重加载
+					pagination.currentPage=1
+				}
+				
+			}
+			else{
+				pagination.currentPage++
+			}
+		},inter*1000)
+	}
 	
 	defineExpose({
 		query,

+ 3 - 10
src/pages/multi/multiPatrol.vue

@@ -106,6 +106,7 @@
 				return
 			}
 			tableHead.value=JSON.parse(resp.data.tempContent)
+			setTimeout(()=>{patrolTable.value.query({orgId})},100)
 		}).catch(err=>{
 			ElMessage.error(err||'获取井站信息失败')
 		})
@@ -116,7 +117,7 @@
 				crtOrg.value=newNode.name
 				tableHead.value=[]
 				getOrgInfo(newNode.id)
-				setTimeout(()=>{patrolTable.value.query({orgId:newNode.id})},100)
+				
 			}
 	},{ immediate: true })
 	
@@ -184,20 +185,12 @@
 	
 	.alarm-cell{
 		 background-color: #ff0000 !important;
+		 color:#fff;
 	}
 	
 	.val-cell{
 		/* background-color: #ff0000; */
 		line-height:24px;
 	}
-	.qpage-body:deep(.el-popper.is-customized) {
-	  /* Set padding to ensure the height is 32px */
-	  padding: 6px 12px;
-	  background: linear-gradient(90deg, rgb(159, 229, 151), rgb(204, 229, 129));
-	}
 	
-	.qpage-body:deep(.el-popper.is-customized .el-popper__arrow::before) {
-	  background: linear-gradient(45deg, #b2e68d, #bce689);
-	  right: 0;
-	}
 </style>