4377830a by lttnew

分页

1 parent 61adfba3
......@@ -2,10 +2,6 @@
<view>
<uni-segmented-control class="whitebg" :current="current" :values="navs" @clickItem="onClickItem"
styleType="text" activeColor="#AD181F"></uni-segmented-control>
<!-- <view v-show="infoList.length>0" class="stat-row">
<view class="stat-item">费用合计:<text class="red">{{ totalCost.toFixed(2) }}</text></view>
<view class="stat-item">考试人数:<text class="red">{{ totalNum }}</text></view>
</view> -->
<view class="appList">
<view class="appItem" v-for="item in infoList" :key="item.examId" @click="goDetail(item)">
......@@ -29,11 +25,6 @@
支付方式
<view>
民生付
<!-- <text :class="{
'text-success': item.examPayStatusStr=='已上传',
'text-danger': item.examPayStatusStr=='未上传',
'text-warning': item.examPayStatusStr=='已结算'
}">{{ item.examPayStatusStr || '--' }}</text> -->
</view>
</view>
<view>
......@@ -44,12 +35,19 @@
<view class="pp esp">上报单位:{{ item.memberName }}</view>
<view class="func" v-if="item.status=='1'">
<button @click="goApproval(item)">审批</button>
<button @click.stop="goApproval(item)">审批</button>
</view>
</view>
</view>
<view class="nodata" v-if="infoList.length==0">
<!-- 上滑加载提示 -->
<view class="load-tip" v-if="infoList.length > 0">
<text v-if="loading">加载中...</text>
<text v-else-if="noMore">没有更多数据了</text>
</view>
<!-- 空数据 -->
<view class="nodata" v-if="infoList.length == 0 && !loading">
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>暂无数据</text>
</view>
......@@ -59,12 +57,8 @@
<script setup>
import * as api from '@/common/api.js'
import config from '@/config.js'
import {
ref
} from 'vue'
import {
onShow
} from '@dcloudio/uni-app'
import { ref } from 'vue'
import { onShow, onReachBottom } from '@dcloudio/uni-app'
const app = getApp()
......@@ -85,30 +79,71 @@
const total = ref(0)
const totalCost = ref(0)
const totalNum = ref(0)
const loading = ref(false)
const noMore = ref(false)
onShow(() => {
if (app.globalData.isLogin) {
getList()
refreshList()
} else {
app.firstLoadCallback = () => {
getList()
refreshList()
}
}
})
// 刷新列表(重置第一页)
function refreshList() {
queryParams.value.pageNum = 1
noMore.value = false
infoList.value = []
getList()
}
// 上滑加载下一页
onReachBottom(() => {
if (loading.value || noMore.value) return
queryParams.value.pageNum++
getList()
})
function getList() {
uni.showLoading({ title: '加载中', mask: true })
if (loading.value || noMore.value) return
loading.value = true
if (queryParams.value.pageNum === 1) {
uni.showLoading({ title: '加载中', mask: true })
}
totalCost.value = 0
totalNum.value = 0
api.examauditList(queryParams.value).then(response => {
loading.value = false
uni.hideLoading()
infoList.value = response.rows || []
const list = response.rows || []
total.value = response.total || 0
// 分页追加
if (queryParams.value.pageNum === 1) {
infoList.value = list
} else {
infoList.value = [...infoList.value, ...list]
}
// 判断是否还有更多
if (list.length < queryParams.value.pageSize) {
noMore.value = true
}
// 统计
infoList.value.forEach(item => {
totalCost.value += Number(item.price) || 0
totalNum.value += Number(item.totalNum) || 0
})
}).catch(() => {
loading.value = false
uni.hideLoading()
})
}
......@@ -116,7 +151,7 @@
function onClickItem(e) {
current.value = e.currentIndex
queryParams.value.status = statusValues[e.currentIndex]
getList()
refreshList()
}
function goDetail(item) {
......@@ -144,7 +179,6 @@
background: #f3e5e5;
font-size: 26rpx;
color: #666;
// margin-top: 20rpx;
.red {
color: #C4121B;
......@@ -156,4 +190,12 @@
width: 100%;
word-break: break-all;
}
</style>
/* 加载提示样式 */
.load-tip {
text-align: center;
padding: 20rpx 0;
font-size: 26rpx;
color: #999;
}
</style>
\ No newline at end of file
......
......@@ -41,7 +41,14 @@
</view>
</view>
</view>
<view class="nodata" v-if="infoList.length==0">
<!-- 加载提示 & 无更多数据 -->
<view class="load-tip" v-if="infoList.length > 0">
<text v-if="loading">加载中...</text>
<text v-else-if="noMore">没有更多数据了</text>
</view>
<view class="nodata" v-if="infoList.length==0 && !loading">
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>暂无数据</text>
</view>
......@@ -52,7 +59,7 @@
import * as api from '@/common/api.js'
import config from '@/config.js'
import { ref } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
const app = getApp()
......@@ -60,10 +67,11 @@
const navs = ref(['全部', '审批中', '审批通过', '审批拒绝'])
const current = ref(0)
// 分页参数
const queryParams = ref({
auditSelectType: '2',
rankStatus: '0',
// status: '',
status: '',
pageNum: 1,
pageSize: 10
})
......@@ -72,7 +80,10 @@
const total = ref(0)
const totalCost = ref(0)
const totalNum = ref(0)
const loading = ref(false) // 加载状态
const noMore = ref(false) // 是否无更多数据
// 页面加载
onLoad((options) => {
queryParams.value.type = options.type
queryParams.value.auditSelectType = options.type
......@@ -83,43 +94,86 @@
}
})
// 页面显示
onShow(() => {
if (app.globalData.isLogin) {
getList()
refreshList()
} else {
app.firstLoadCallback = () => { getList() }
app.firstLoadCallback = () => { refreshList() }
}
})
// 顶部切换
function onClickItem(e) {
current.value = e.currentIndex
queryParams.value.status = statusValues[e.currentIndex]
refreshList()
}
// 下拉刷新(重置)
function refreshList() {
queryParams.value.pageNum = 1
noMore.value = false
infoList.value = []
getList()
}
// 上滑加载下一页
onReachBottom(() => {
if (loading.value || noMore.value) return
queryParams.value.pageNum++
getList()
})
// 获取列表
function getList() {
uni.showLoading({ title: '加载中', mask: true })
// 已无更多数据 或 正在加载,直接返回
if (noMore.value || loading.value) return
loading.value = true
uni.showLoading({ title: '加载中', mask: queryParams.value.pageNum === 1 })
totalCost.value = 0
totalNum.value = 0
api.examauditList(queryParams.value).then(res => {
loading.value = false
uni.hideLoading()
infoList.value = res.rows || []
const list = res.rows || []
total.value = res.total || 0
// 第一页:直接覆盖
if (queryParams.value.pageNum === 1) {
infoList.value = list
} else {
// 分页:追加
infoList.value = [...infoList.value, ...list]
}
// 判断是否还有下一页
if (list.length < queryParams.value.pageSize) {
noMore.value = true
}
// 统计
infoList.value.forEach(item => {
totalCost.value += Number(item.price) || 0
totalNum.value += Number(item.totalNum) || 0
})
}).catch(() => {
loading.value = false
uni.hideLoading()
})
}
// 详情
function goDetail(item) {
uni.navigateTo({
url: `/pages/rank/applyDetail?examId=${item.examId}&type=1`
})
}
// 审核
function goApproval(item) {
uni.navigateTo({
url: `/pages/rank/scoreAudit?ids=${item.examId}&pageType=2`
......@@ -141,4 +195,12 @@
font-weight: 600;
}
}
</style>
/* 加载提示 */
.load-tip {
text-align: center;
padding: 20rpx 0;
font-size: 26rpx;
color: #999;
}
</style>
\ No newline at end of file
......
......@@ -3,11 +3,6 @@
<uni-segmented-control class="whitebg" :current="current" :values="navs" @clickItem="onClickItem"
styleType="text" activeColor="#AD181F"></uni-segmented-control>
<!-- <view v-show="infoList.length>0" class="stat-row">
<view class="stat-item">费用合计:<text class="red">{{ totalCost.toFixed(2) }}</text></view>
<view class="stat-item">考试人数:<text class="red">{{ totalNum }}</text></view>
</view> -->
<view class="appList">
<view class="appItem" v-for="item in infoList" :key="item.examId">
<view @click="goDetail(item)">
......@@ -47,7 +42,14 @@
</view>
</view>
<view class="nodata" v-if="infoList.length==0">
<!-- 加载提示 -->
<view class="load-tip" v-if="infoList.length > 0">
<text v-if="loading">加载中...</text>
<text v-else-if="noMore">没有更多数据了</text>
</view>
<!-- 空数据 -->
<view class="nodata" v-if="infoList.length == 0 && !loading">
<image mode="aspectFit" :src="config.baseUrl_api + '/fs/static/nodata.png'"></image>
<text>暂无数据</text>
</view>
......@@ -58,7 +60,7 @@
import * as api from '@/common/api.js'
import config from '@/config.js'
import { ref } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
const app = getApp()
......@@ -67,20 +69,23 @@
const current = ref(0)
const statusArr = ['审批中', '审批通过', '审批拒绝', '审批撤回']
// 分页参数
const queryParams = ref({
status: '',
scoreStatus: '',
pageNum: 1,
pageSize: 50
pageSize: 10
})
const infoList = ref([])
const total = ref(0)
const totalCost = ref(0)
const totalNum = ref(0)
const loading = ref(false)
const noMore = ref(false)
onLoad((options) => {
queryParams.value.type = options.type
queryParams.value.auditSelectType = options.type
queryParams.value.auditSelectType = options.type
if (options.type == '3') {
uni.setNavigationBarTitle({ title: '段位成绩审核' })
} else if (options.type == '5') {
......@@ -90,42 +95,85 @@
onShow(() => {
if (app.globalData.isLogin) {
getList()
refreshList()
} else {
app.firstLoadCallback = () => { getList() }
app.firstLoadCallback = () => { refreshList() }
}
})
// 切换标签
function onClickItem(e) {
current.value = e.currentIndex
queryParams.value.scoreStatus = statusValues[e.currentIndex]
refreshList()
}
// 刷新列表(重置第一页)
function refreshList() {
queryParams.value.pageNum = 1
noMore.value = false
infoList.value = []
getList()
}
// 上滑加载下一页
onReachBottom(() => {
if (loading.value || noMore.value) return
queryParams.value.pageNum++
getList()
})
// 获取数据
function getList() {
uni.showLoading({ title: '加载中', mask: true })
totalCost.value = 0
totalNum.value = 0
if (loading.value || noMore.value) return
loading.value = true
// 第一页显示loading
if (queryParams.value.pageNum === 1) {
uni.showLoading({ title: '加载中', mask: true })
}
api.examauditList(queryParams.value).then(res => {
loading.value = false
uni.hideLoading()
infoList.value = res.rows || []
const list = res.rows || []
total.value = res.total || 0
// 分页追加数据
if (queryParams.value.pageNum === 1) {
infoList.value = list
} else {
infoList.value = [...infoList.value, ...list]
}
// 判断是否还有更多
if (list.length < queryParams.value.pageSize) {
noMore.value = true
}
// 统计合计
totalCost.value = 0
totalNum.value = 0
infoList.value.forEach(item => {
item.statusStr = statusArr[item.auditStatus] || '审批中'
totalCost.value += Number(item.totalAmount) || 0
totalNum.value += Number(item.totalNum) || 0
})
}).catch(() => {
loading.value = false
uni.hideLoading()
})
}
// 审核
function goApproval(item) {
uni.navigateTo({
url: `/pages/rank/scoreAudit?ids=${item.examId}&pageType=2`
})
}
// 详情
function goDetail(item) {
uni.navigateTo({
url: `/pages/rank/scoreDetail?examId=${item.examId}&type=${queryParams.value.type}`
......@@ -143,8 +191,16 @@
color: #666;
.red {
color: #C4121B;
color: #C4121F;
font-weight: 600;
}
}
</style>
/* 加载提示 */
.load-tip {
text-align: center;
padding: 20rpx 0;
font-size: 26rpx;
color: #999;
}
</style>
\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!