Commit 8f0df435 authored by 13841799530's avatar 13841799530

解润东

20220517
执行巡查分页
parent 6494078b
Pipeline #8346 passed with stage
in 5 minutes and 2 seconds
...@@ -6,15 +6,22 @@ ...@@ -6,15 +6,22 @@
<!-- tab标签 --> <!-- tab标签 -->
<van-tabs <van-tabs
v-model="active" v-model="active"
@click="onClick"
color="#2980f7" color="#2980f7"
animated animated
@change="tabChange"
:sticky="true" :sticky="true"
offset-top="1.5rem" offset-top="1.5rem"
> >
<van-tab v-for="(item, key) in tabs" :key="key" :title="item.title"> <van-tab v-for="(i, key) in tabs" :key="key" :title="i.title">
<!-- 内容列表 --> <!-- 内容列表 -->
<div class="con-list"> <div class="con-list">
<van-pull-refresh v-model="i.refreshing" @refresh="onRefresh">
<van-list
v-model="i.loading"
:finished="i.finished"
finished-text="没有更多了"
@load="onLoad()"
>
<van-cell-group inset v-for="(item, index) in messageList" :key="index"> <van-cell-group inset v-for="(item, index) in messageList" :key="index">
<van-row gutter> <van-row gutter>
<!-- <van-col span="18"> <!-- <van-col span="18">
...@@ -61,6 +68,8 @@ ...@@ -61,6 +68,8 @@
</van-col> </van-col>
</van-row> </van-row>
</van-cell-group> </van-cell-group>
</van-list>
</van-pull-refresh>
</div> </div>
<!-- 暂无数据 --> <!-- 暂无数据 -->
<div <div
...@@ -73,6 +82,7 @@ ...@@ -73,6 +82,7 @@
" "
v-if="messageList.length == 0" v-if="messageList.length == 0"
>暂无数据</div> >暂无数据</div>
</van-tab> </van-tab>
</van-tabs> </van-tabs>
...@@ -85,6 +95,7 @@ ...@@ -85,6 +95,7 @@
@click="finish" @click="finish"
>结束巡查</van-button> >结束巡查</van-button>
</div> </div>
</div> </div>
</template> </template>
...@@ -105,6 +116,10 @@ export default { ...@@ -105,6 +116,10 @@ export default {
messageList: [], messageList: [],
active: 0, active: 0,
hdType:'', hdType:'',
total:0,//总条数
page:1,//页码
psize:5,//页数量
refreshing:false,
cycle:'', cycle:'',
tabs: [ tabs: [
// { // {
...@@ -138,9 +153,17 @@ export default { ...@@ -138,9 +153,17 @@ export default {
this.loadingTabs() this.loadingTabs()
}, },
methods: { methods: {
onClick(name,title){ tabChange(name,title){
this.page=1
this.hdType=title this.hdType=title
this.postList() this.messageList=[]
this.tabs.forEach((i)=>{
if(i.title==this.hdType){
i.loading=true
i.finished=false
}
})
this.onLoad();
}, },
loadingTabs(){ loadingTabs(){
postWork("patrol/running/hdType?cycle="+this.id).then(res => { postWork("patrol/running/hdType?cycle="+this.id).then(res => {
...@@ -148,10 +171,12 @@ export default { ...@@ -148,10 +171,12 @@ export default {
res.data.forEach((i)=>{ res.data.forEach((i)=>{
this.tabs.push({ this.tabs.push({
title:i.hdType, title:i.hdType,
api:i.id api:i.id,
loading: false,
finished: false,
refreshing:false,
}) })
}) })
this.postList();
this.$toast.clear(); this.$toast.clear();
}) })
.catch(err => { .catch(err => {
...@@ -159,11 +184,7 @@ export default { ...@@ -159,11 +184,7 @@ export default {
this.$toast.fail("加载失败,请稍后再试"); this.$toast.fail("加载失败,请稍后再试");
}); });
}, },
onChange() {
console.log(this.active);
},
postList(val) { postList(val) {
this.messageList=[]
this.$toast.loading({ this.$toast.loading({
message: "加载中...", message: "加载中...",
forbidClick: true, forbidClick: true,
...@@ -172,12 +193,30 @@ export default { ...@@ -172,12 +193,30 @@ export default {
}); });
let obj = { let obj = {
cycle: this.id, cycle: this.id,
hdType:this.hdType hdType:this.hdType,
page:this.page,
psize:this.psize,
}; };
postFun("patrol/running/list?cycle="+this.id+'&hdType='+this.hdType) postFun("patrol/running/list?cycle="+this.id+'&hdType='+this.hdType+'&page='+this.page+'&psize='+this.psize)
.then(res => { .then(res => {
this.messageList = res.data; res.rows.forEach((item)=>{
this.messageList.push(item)
})
this.$toast.clear(); this.$toast.clear();
this.total=res.total
this.page++;
this.tabs.forEach((i)=>{
if(i.title==this.hdType){
if (this.messageList.length>=this.total) {
i.finished = true;
}
i.loading = false;
}
})
//防止分页超出操作
// if(!(this.page*5-this.total>=0)){
// this.page++;
// }
}) })
.catch(err => { .catch(err => {
this.$toast.clear(); this.$toast.clear();
...@@ -246,7 +285,31 @@ export default { ...@@ -246,7 +285,31 @@ export default {
.catch(() => { .catch(() => {
}); });
} },
//下拉页面刷新
onRefresh() {
// 清空列表数据
this.page=1
this.tabs.forEach((i)=>{
if(i.title==this.hdType){
i.loading=true
i.finished=false
}
})
this.onLoad();
},
//上拉页面加载数据
onLoad(value) {
this.tabs.forEach((i)=>{
if(i.title==this.hdType){
if (i.refreshing) {
this.messageList=[]
i.refreshing = false;
}
}
})
this.postList()
},
} }
}; };
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment