feat: 恢复重建 分页
This commit is contained in:
parent
ea1dc1afc4
commit
461992a5e7
@ -5,7 +5,7 @@
|
||||
<CurrentSite />
|
||||
|
||||
<div class="list-panel">
|
||||
<van-list :loading="loading" :finished="finished" finished-text="没有更多了">
|
||||
<van-list :loading="loading" :finished="finished" finished-text="没有更多了" @load="handleLoadMore">
|
||||
<CardItem v-for="(item, index) in list" :key="index" :title="`${item.projectName}`" @click="handleClickItem(item)">
|
||||
<template #headerExtra>
|
||||
<van-tag v-if="item.approvalStatus === 3 || item.approvalStatus === 1" type="success" plain size="medium">审批通过</van-tag>
|
||||
@ -57,29 +57,55 @@ import { request } from '../../../../shared/utils/request'
|
||||
const router = useRouter()
|
||||
const loading = ref(false)
|
||||
const finished = ref(false)
|
||||
const loaded = ref(false)
|
||||
|
||||
const pageNum = ref(1)
|
||||
const pageSize = 10
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
getData({ reset: true })
|
||||
})
|
||||
|
||||
const getData = async () => {
|
||||
const getData = async ({ reset = false } = {}) => {
|
||||
if (loading.value) return
|
||||
|
||||
if (reset) {
|
||||
pageNum.value = 1
|
||||
finished.value = false
|
||||
loaded.value = false
|
||||
list.value = []
|
||||
}
|
||||
|
||||
if (finished.value) return
|
||||
|
||||
loading.value = true
|
||||
|
||||
try {
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 999,
|
||||
pageNum: pageNum.value,
|
||||
pageSize,
|
||||
}
|
||||
if (searchValue.value) {
|
||||
params.districtName = searchValue.value
|
||||
params.districtName = searchValue.value.trim()
|
||||
}
|
||||
loading.value = true
|
||||
const res = await request({
|
||||
url: '/snow-ops-platform/recovery/list',
|
||||
method: 'GET',
|
||||
params,
|
||||
})
|
||||
if (res.code === '00000') {
|
||||
list.value = res.data.records
|
||||
if (res.code === '00000' && res.data?.records) {
|
||||
list.value = reset ? res.data.records : [...list.value, ...res.data.records]
|
||||
const total = Number(res.data.total || 0)
|
||||
finished.value = list.value.length >= total || res.data.records.length < pageSize
|
||||
pageNum.value += 1
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取列表失败:', error)
|
||||
finished.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
loaded.value = true
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索关键词
|
||||
@ -111,10 +137,15 @@ const handleAddDevice = () => {
|
||||
// });
|
||||
}
|
||||
|
||||
const handleLoadMore = () => {
|
||||
if (!loaded.value) return
|
||||
getData()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => searchValue.value,
|
||||
() => {
|
||||
getData()
|
||||
getData({ reset: true })
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user