fix
This commit is contained in:
@@ -50,6 +50,7 @@ const error = ref(false)
|
||||
const finished = ref(false)
|
||||
const hasData = ref(false)
|
||||
const unclassifiedCount = ref(0)
|
||||
const _loadedUnclassifiedInitially = ref(false)
|
||||
|
||||
// 获取未分类账单统计
|
||||
const loadUnclassifiedCount = async () => {
|
||||
@@ -72,6 +73,10 @@ const handleDataLoaded = ({ groups, total, finished: isFinished }) => {
|
||||
// 处理数据变更
|
||||
const handleDataChanged = async () => {
|
||||
await loadUnclassifiedCount()
|
||||
// 重新加载数据
|
||||
listLoading.value = true
|
||||
await onLoad()
|
||||
listLoading.value = false
|
||||
}
|
||||
|
||||
// 加载更多
|
||||
@@ -83,14 +88,16 @@ const onLoad = async () => {
|
||||
|
||||
try {
|
||||
await groupListRef.value.loadData()
|
||||
|
||||
// 首次加载时获取统计信息
|
||||
if (!hasData.value) {
|
||||
|
||||
// 首次加载时获取统计信息(确保统计不会丢失)
|
||||
if (!_loadedUnclassifiedInitially.value) {
|
||||
await loadUnclassifiedCount()
|
||||
_loadedUnclassifiedInitially.value = true
|
||||
}
|
||||
|
||||
error.value = false
|
||||
} catch (err) {
|
||||
console.error('加载分组数据失败:', err)
|
||||
error.value = true
|
||||
} finally {
|
||||
listLoading.value = false
|
||||
@@ -106,6 +113,13 @@ const handleBack = () => {
|
||||
onMounted(async () => {
|
||||
// 初始加载数据
|
||||
listLoading.value = true
|
||||
try {
|
||||
// 先确保统计加载,避免统计消失
|
||||
await loadUnclassifiedCount()
|
||||
_loadedUnclassifiedInitially.value = true
|
||||
} catch (e) {
|
||||
console.error('初始化加载未分类统计失败:', e)
|
||||
}
|
||||
await onLoad()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user