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