fix: 修复主页数据展示问题

1. 优化 MineTask 组件的数据展示逻辑
2. 修复 TypeScript 类型错误
3. 移除冗余的 SurveyAnalysis 组件引用
4. 清理未使用的样式和代码
This commit is contained in:
Huangzhe
2025-05-19 10:23:22 +08:00
parent 2af5c350ee
commit d362b4a7a4
5 changed files with 25 additions and 11 deletions

View File

@@ -10,6 +10,9 @@ import {
// series 信息 // series 信息
const tableData = ref([]); const tableData = ref([]);
const analysis = defineModel('analysis'); const analysis = defineModel('analysis');
console.log('analysis', analysis.value);
const series = ref([]); const series = ref([]);
const dimension = defineModel('dimension'); const dimension = defineModel('dimension');

View File

@@ -1,5 +1,6 @@
import { getSurveysDetail } from '@/api/design'; import { getSurveysDetail } from '@/api/design';
import { getSurveysPage } from '@/api/home'; import { getSurveysPage } from '@/api/home';
import { surveyAnalysis } from '@/api/survey';
import { ref, type Ref } from 'vue'; import { ref, type Ref } from 'vue';
// 异步函数获取数据 // 异步函数获取数据
@@ -37,4 +38,16 @@ function fetchSingleSurvey(sn: string) {
return { currentSurvey }; return { currentSurvey };
} }
export { fetchSurveys, fetchSingleSurvey }; function useFetchAnalysis(sn: string) {
const questionAnalysis = ref();
surveyAnalysis(sn).then(({ data }) => {
questionAnalysis.value = data.data;
});
return {
questionAnalysis
};
}
export { fetchSurveys, fetchSingleSurvey, useFetchAnalysis };

View File

@@ -66,7 +66,7 @@ useFetchAnalysis(sn.value);
<!-- 图表分析部分 --> <!-- 图表分析部分 -->
<van-cell class="analysis"> <van-cell class="analysis">
<template #extra> <template #extra>
<analysis-info /> <analysis-info :sn="sn" />
</template> </template>
</van-cell> </van-cell>
</section> </section>

View File

@@ -26,7 +26,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { questionAnalysis } from '../../hooks/useAnalysis'; import { useFetchAnalysis } from '../../hooks/useAnalysis';
import { questionTypeMap } from '@/utils/question/typeMapping'; import { questionTypeMap } from '@/utils/question/typeMapping';
import ChartMsg from '@/components/Analysis/Index.vue'; import ChartMsg from '@/components/Analysis/Index.vue';
import { getTableData } from './hooks/pieSeries'; import { getTableData } from './hooks/pieSeries';
@@ -34,7 +34,8 @@ import YlTable from '@/components/YlTable/Index.vue';
import { ref } from 'vue'; import { ref } from 'vue';
// questionTypeMap 自己去对应 // questionTypeMap 自己去对应
const showChart = ref([1, 2, 5, 106, 9, 10]); const showChart = ref([1, 2, 5, 106, 9, 10]);
const sn = defineModel('sn');
const { questionAnalysis } = useFetchAnalysis(sn.value as string);
// const showTable = ref([1,2,4]) // const showTable = ref([1,2,4])
// 构建表头 // 构建表头

View File

@@ -10,6 +10,7 @@ type AiInsightType = {
message: string; message: string;
info: string; info: string;
}; };
// ai 智能洞察 // ai 智能洞察
export const aiInsightsConfig = ref<AiInsightType>({ export const aiInsightsConfig = ref<AiInsightType>({
visible: false, visible: false,
@@ -18,7 +19,6 @@ export const aiInsightsConfig = ref<AiInsightType>({
info: '' info: ''
}); });
const questionAnalysis = ref();
const params: AnalysisParam = { const params: AnalysisParam = {
page: 1, page: 1,
per_page: 30, per_page: 30,
@@ -71,10 +71,7 @@ export async function checkAnalysis(sn: string) {
return data; return data;
} }
async function useFetchAnalysis(sn: string) {
const res = await surveyAnalysis(sn);
questionAnalysis.value = res.data.data;
// console.log(`question analysis`, questionAnalysis.value);
}
export { useFetchAnalysis, questionAnalysis, aiAnalysisData, currentSn };
export {aiAnalysisData, currentSn };
export { useFetchAnalysis } from '@/hooks/request/useSurvey';