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 信息
const tableData = ref([]);
const analysis = defineModel('analysis');
console.log('analysis', analysis.value);
const series = ref([]);
const dimension = defineModel('dimension');

View File

@@ -1,5 +1,6 @@
import { getSurveysDetail } from '@/api/design';
import { getSurveysPage } from '@/api/home';
import { surveyAnalysis } from '@/api/survey';
import { ref, type Ref } from 'vue';
// 异步函数获取数据
@@ -37,4 +38,16 @@ function fetchSingleSurvey(sn: string) {
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">
<template #extra>
<analysis-info />
<analysis-info :sn="sn" />
</template>
</van-cell>
</section>

View File

@@ -26,7 +26,7 @@
</template>
<script setup lang="ts">
import { questionAnalysis } from '../../hooks/useAnalysis';
import { useFetchAnalysis } from '../../hooks/useAnalysis';
import { questionTypeMap } from '@/utils/question/typeMapping';
import ChartMsg from '@/components/Analysis/Index.vue';
import { getTableData } from './hooks/pieSeries';
@@ -34,7 +34,8 @@ import YlTable from '@/components/YlTable/Index.vue';
import { ref } from 'vue';
// questionTypeMap 自己去对应
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])
// 构建表头

View File

@@ -10,6 +10,7 @@ type AiInsightType = {
message: string;
info: string;
};
// ai 智能洞察
export const aiInsightsConfig = ref<AiInsightType>({
visible: false,
@@ -18,7 +19,6 @@ export const aiInsightsConfig = ref<AiInsightType>({
info: ''
});
const questionAnalysis = ref();
const params: AnalysisParam = {
page: 1,
per_page: 30,
@@ -71,10 +71,7 @@ export async function checkAnalysis(sn: string) {
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';