diff --git a/src/utils/useProjectList.ts b/src/utils/useProjectList.ts new file mode 100644 index 00000000..17c57ae3 --- /dev/null +++ b/src/utils/useProjectList.ts @@ -0,0 +1,40 @@ +// 在总页面统一请求项目列表,provide给子组件使用,避免重复请求,用于echarts图表 +import { ref, provide } from 'vue'; +import { queryNodeListApi } from '@/api/project/node'; + +export function useProjectList() { + const projectListRes = ref(null); + const loading = ref(false); + + const getProjectList = async () => { + loading.value = true; + try { + const params = { + nodeType: 'project', + current: 1, + size: 9999, + }; + const res = await queryNodeListApi(params); + if (res.code === 200) { + projectListRes.value = res; + } + } catch (error) { + console.error('获取项目列表失败:', error); + } finally { + loading.value = false; + } + }; + + // 自动调用获取项目列表 + getProjectList(); + + // 自动提供数据给子组件 + provide('projectProvide', true); + provide('projectListRes', projectListRes); + + return { + projectListRes, + loading, + getProjectList, + }; +} diff --git a/src/views/task/dashboard/components/dataStatistics.vue b/src/views/task/dashboard/components/dataStatistics.vue index 0c127346..89074ff9 100644 --- a/src/views/task/dashboard/components/dataStatistics.vue +++ b/src/views/task/dashboard/components/dataStatistics.vue @@ -25,7 +25,7 @@ diff --git a/src/views/task/dashboard/components/summaryNewBoard.vue b/src/views/task/dashboard/components/summaryNewBoard.vue index da1b29ef..f7181730 100644 --- a/src/views/task/dashboard/components/summaryNewBoard.vue +++ b/src/views/task/dashboard/components/summaryNewBoard.vue @@ -34,7 +34,7 @@ :nodata="achieveBarOption?.xAxis.data.length === 0" :option="achieveBarOption" :showChangeModel="true" - :filterItems="['projectName', 'projectCode', 'discipline']" + :filterItems="['projectName', 'projectCode', 'discipline', 'workspace']" @update="achieveBarChartUpdate" > @@ -46,7 +46,7 @@ :bar-type="'pieChart'" :nodata="achievePieChartNodata" :option="achievePieOption" - :filterItems="['projectName', 'projectCode', 'discipline']" + :filterItems="['projectName', 'projectCode', 'discipline', 'workspace']" @update="achievePieChartUpdate" > @@ -57,13 +57,17 @@