|
|
@@ -1,6 +1,7 @@
|
|
|
import React, { useState, useEffect, memo } from 'react'
|
|
|
+import Taro, { usePullDownRefresh } from '@tarojs/taro'
|
|
|
import { View, Text, ScrollView } from '@tarojs/components'
|
|
|
-import { useQuery } from '@tanstack/react-query'
|
|
|
+import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|
|
import { YongrenTabBarLayout } from '@d8d/yongren-shared-ui/components/YongrenTabBarLayout'
|
|
|
import { Navbar } from '@d8d/mini-shared-ui-components/components/navbar'
|
|
|
import { ColumnChart } from '@d8d/mini-charts/components/ColumnChart'
|
|
|
@@ -83,6 +84,9 @@ export interface StatisticsProps {
|
|
|
}
|
|
|
|
|
|
const Statistics: React.FC<StatisticsProps> = () => {
|
|
|
+ // Query Client 用于刷新数据
|
|
|
+ const queryClient = useQueryClient()
|
|
|
+
|
|
|
// 状态:图表懒加载控制 - 哪些图表已经加载
|
|
|
const [loadedCharts, setLoadedCharts] = useState<Set<string>>(new Set(['disability', 'gender'])) // 默认加载前两个关键图表
|
|
|
|
|
|
@@ -112,6 +116,16 @@ const Statistics: React.FC<StatisticsProps> = () => {
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
+ // 下拉刷新:刷新所有统计数据
|
|
|
+ usePullDownRefresh(async () => {
|
|
|
+ try {
|
|
|
+ // 使所有统计查询失效,触发重新获取
|
|
|
+ await queryClient.invalidateQueries({ queryKey: ['statistics'] })
|
|
|
+ } finally {
|
|
|
+ Taro.stopPullDownRefresh()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
// 获取在职人数统计(简化版:无查询参数)
|
|
|
const { data: employmentCountData, isLoading: isLoadingEmploymentCount } = useQuery({
|
|
|
queryKey: ['statistics', 'employment-count'],
|