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