feat: 添加下拉刷新功能

This commit is contained in:
zyn
2023-11-29 13:43:22 +08:00
parent 187a6cd999
commit bbfc9fbaf9
5 changed files with 106 additions and 86 deletions
+26 -21
View File
@@ -27,9 +27,13 @@
ref="scroll" ref="scroll"
height="calc(100vh - 100px)" height="calc(100vh - 100px)"
:data="list" :data="list"
:page="searchQuery.page"
:pageSize="searchQuery.pageSize"
:total="total" :total="total"
:loading="loading" :loading="loading"
:pullingUpHandler="pullingUpHandler"> pullUpLoad
pullDownRefresh
:getDataHandler="getData">
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<div class="card-content" <div class="card-content"
v-for="item in list" v-for="item in list"
@@ -177,12 +181,6 @@ export default {
// this.getData() // this.getData()
}, },
methods: { methods: {
pullingUpHandler () {
if (this.searchQuery.page * this.searchQuery.pageSize <= this.total) {
this.searchQuery.page = this.searchQuery.page + 1
this.getData()
}
},
onSearch () { onSearch () {
this.list = [] this.list = []
this.searchQuery.page = 1 this.searchQuery.page = 1
@@ -190,7 +188,7 @@ export default {
this.$refs.scroll.scrollTo(0, 0) this.$refs.scroll.scrollTo(0, 0)
this.getData() this.getData()
}, },
getData () { getData (page) {
switch (this.$route.query.standType) { switch (this.$route.query.standType) {
case 'INLAND': case 'INLAND':
this.searchQuery.selectIndex = 'stand' this.searchQuery.selectIndex = 'stand'
@@ -209,20 +207,27 @@ export default {
this.searchQuery.standType = 'laws' this.searchQuery.standType = 'laws'
break break
} }
const config = { return new Promise((resolve, reject) => {
_this: this, const config = {
loading: 'loading' _this: this,
} loading: 'loading'
this.$http._postData("search/searchCenter/searchSarBykey", this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.count
if (this.searchQuery.page === 1) {
this.list = res.data.list
} else {
this.list = [...this.list, ...res.data.list]
}
} }
if (page) {
this.searchQuery.page = page
}
this.$http._postData("search/searchCenter/searchSarBykey", this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.count
if (this.searchQuery.page === 1) {
this.list = res.data.list
} else {
this.list = [...this.list, ...res.data.list]
}
}
}).finally(() => {
resolve()
})
}) })
}, },
onChoose () { onChoose () {
@@ -6,9 +6,13 @@
<PhoneScroll <PhoneScroll
height="calc(100vh - 131px)" height="calc(100vh - 131px)"
:data="list" :data="list"
:page="searchQuery.page"
:pageSize="searchQuery.pageSize"
:total="total" :total="total"
:loading="loading" :loading="loading"
:pullingUpHandler="pullingUpHandler"> pullUpLoad
pullDownRefresh
:getDataHandler="getData">
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<div class="card-content" v-for="item in list" :key="item.id" @click="jumpDetails(item)"> <div class="card-content" v-for="item in list" :key="item.id" @click="jumpDetails(item)">
<div class="standTitle"> <div class="standTitle">
@@ -57,12 +61,6 @@ export default {
this.getData() this.getData()
}, },
methods: { methods: {
pullingUpHandler () {
if (this.searchQuery.page * this.searchQuery.pageSize <= this.total) {
this.searchQuery.page = this.searchQuery.page + 1
this.getData()
}
},
onOpen () { onOpen () {
this.$refs.folderPopupRef.open(this.searchQuery.treeId || null) this.$refs.folderPopupRef.open(this.searchQuery.treeId || null)
}, },
@@ -72,20 +70,27 @@ export default {
this.searchQuery.page = 1 this.searchQuery.page = 1
this.getData() this.getData()
}, },
getData () { getData (page) {
const config = { return new Promise((resolve, reject) => {
_this: this, const config = {
loading: 'loading' _this: this,
} loading: 'loading'
this.$http._getData('fileMaterialCenter/file-material', this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.total
if (this.searchQuery.page === 1) {
this.list = res.data.records
} else {
this.list = [...this.list, ...res.data.records]
}
} }
if (page) {
this.searchQuery.page = page
}
this.$http._getData('fileMaterialCenter/file-material', this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.total
if (this.searchQuery.page === 1) {
this.list = res.data.records
} else {
this.list = [...this.list, ...res.data.records]
}
}
}).finally(() => {
resolve()
})
}) })
}, },
jumpDetails(item) { jumpDetails(item) {
@@ -2,9 +2,13 @@
<PhoneScroll <PhoneScroll
height="calc(100vh - 101px)" height="calc(100vh - 101px)"
:data="list" :data="list"
:page="searchQuery.page"
:pageSize="searchQuery.pageSize"
:total="total" :total="total"
:loading="loading" :loading="loading"
:pullingUpHandler="pullingUpHandler"> pullUpLoad
pullDownRefresh
:getDataHandler="getData">
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<div class="card-content" v-for="item in list" :key="item.id" @click="jumpDetails(item)"> <div class="card-content" v-for="item in list" :key="item.id" @click="jumpDetails(item)">
<div class="standTitle"> <div class="standTitle">
@@ -55,27 +59,28 @@ export default {
this.getData() this.getData()
}, },
methods: { methods: {
pullingUpHandler () { getData (page) {
if (this.searchQuery.page * this.searchQuery.pageSize <= this.total) { return new Promise((resolve, reject) => {
this.searchQuery.page = this.searchQuery.page + 1 const config = {
this.getData() _this: this,
} loading: 'loading'
},
getData () {
const config = {
_this: this,
loading: 'loading'
}
this.$http._getData("lawss/NewsFeed/getNewsFeed", this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.total
if (this.searchQuery.page === 1) {
this.list = res.data.records
} else {
this.list = [...this.list, ...res.data.records]
}
} }
if (page) {
this.searchQuery.page = page
}
this.$http._getData("lawss/NewsFeed/getNewsFeed", this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.total
if (this.searchQuery.page === 1) {
this.list = res.data.records
} else {
this.list = [...this.list, ...res.data.records]
}
}
}).finally(() => {
resolve()
})
}) })
}, },
getDicTypeListCode () { getDicTypeListCode () {
@@ -2,9 +2,13 @@
<PhoneScroll <PhoneScroll
height="calc(100vh - 101px)" height="calc(100vh - 101px)"
:data="list" :data="list"
:page="searchQuery.page"
:pageSize="searchQuery.pageSize"
:total="total" :total="total"
:loading="loading" :loading="loading"
:pullingUpHandler="pullingUpHandler"> pullUpLoad
pullDownRefresh
:getDataHandler="getData">
<div style="padding-top: 10px"> <div style="padding-top: 10px">
<div class="card-content" v-for="item in list" :key="item.id" @click="jumpDetails(item)"> <div class="card-content" v-for="item in list" :key="item.id" @click="jumpDetails(item)">
<div class="standTitle"> <div class="standTitle">
@@ -54,27 +58,28 @@ export default {
this.getData() this.getData()
}, },
methods: { methods: {
pullingUpHandler () { getData (page) {
if (this.searchQuery.page * this.searchQuery.pageSize <= this.total) { return new Promise((resolve, reject) => {
this.searchQuery.page = this.searchQuery.page + 1 const config = {
this.getData() _this: this,
} loading: 'loading'
},
getData () {
const config = {
_this: this,
loading: 'loading'
}
this.$http._getData("lawss/NewsFeed/getNewsFeed", this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.total
if (this.searchQuery.page === 1) {
this.list = res.data.records
} else {
this.list = [...this.list, ...res.data.records]
}
} }
if (page) {
this.searchQuery.page = page
}
this.$http._getData("lawss/NewsFeed/getNewsFeed", this.searchQuery, config).then(res => {
if (res.ok) {
this.total = res.data.total
if (this.searchQuery.page === 1) {
this.list = res.data.records
} else {
this.list = [...this.list, ...res.data.records]
}
}
}).finally(() => {
resolve()
})
}) })
}, },
getDicTypeListCode () { getDicTypeListCode () {
+3 -3
View File
@@ -8,13 +8,13 @@
</div> </div>
<van-tabs v-model="active"> <van-tabs v-model="active">
<van-tab name="ZYBZFG" title="在研标准入库"> <van-tab name="ZYBZFG" title="在研标准入库">
<UnderResearchStandards v-if="active==='ZYBZFG'"></UnderResearchStandards> <UnderResearchStandards></UnderResearchStandards>
</van-tab> </van-tab>
<van-tab name="GNWBZFG" title="标准法规入库"> <van-tab name="GNWBZFG" title="标准法规入库">
<StandardRegulations v-if="active==='GNWBZFG'"></StandardRegulations> <StandardRegulations></StandardRegulations>
</van-tab> </van-tab>
<van-tab name="ZLZX" title="资料中心"> <van-tab name="ZLZX" title="资料中心">
<DataCenter v-if="active==='ZLZX'"></DataCenter> <DataCenter></DataCenter>
</van-tab> </van-tab>
</van-tabs> </van-tabs>
</div> </div>