0823
This commit is contained in:
1 parent
e5029688e5
commit
0db0a99c85
288 files changed
+41335
-11400
No files matched your search
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div class="activity-rating-view">
|
||||
<div v-if="ratings.length === 0" class="empty-state">
|
||||
<el-empty description="暂无评分信息" :image-size="80" />
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<div class="rating-summary">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-statistic title="总评分数" :value="ratings.length" />
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-statistic title="平均评分" :value="averageRating" :precision="1" />
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-statistic title="最高评分" :value="maxRating" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<el-divider />
|
||||
|
||||
<el-table :data="ratings" height="400" border>
|
||||
<el-table-column label="评分人" prop="userName" width="120" />
|
||||
<el-table-column label="评分" prop="ratingScore" width="120" align="center">
|
||||
<template #default="scope">
|
||||
<el-rate :model-value="scope.row.ratingScore" disabled size="small" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="评分备注" prop="ratingComment" show-overflow-tooltip />
|
||||
<el-table-column label="评分时间" prop="ratingTime" width="160" align="center" />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { getActivityRatings } from '@/api/stgl/activity';
|
||||
import { ActivityRatingVO } from '@/api/stgl/activity/types';
|
||||
|
||||
interface Props {
|
||||
activityId: string | number;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const ratings = ref<ActivityRatingVO[]>([]);
|
||||
const loading = ref(false);
|
||||
|
||||
// 计算平均评分
|
||||
const averageRating = computed(() => {
|
||||
if (ratings.value.length === 0) return 0;
|
||||
const sum = ratings.value.reduce((total, rating) => total + rating.ratingScore, 0);
|
||||
return sum / ratings.value.length;
|
||||
});
|
||||
|
||||
// 计算最高评分
|
||||
const maxRating = computed(() => {
|
||||
if (ratings.value.length === 0) return 0;
|
||||
return Math.max(...ratings.value.map(rating => rating.ratingScore));
|
||||
});
|
||||
|
||||
// 加载评分数据
|
||||
const loadRatings = async () => {
|
||||
if (!props.activityId) return;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getActivityRatings(props.activityId);
|
||||
ratings.value = res.data || [];
|
||||
} catch (error: any) {
|
||||
// 如果是404错误,说明后端暂未实现该功能,静默处理
|
||||
if (error.response?.status === 404) {
|
||||
console.log('活动评分功能暂未实现');
|
||||
} else {
|
||||
console.error('加载评分数据失败:', error);
|
||||
}
|
||||
ratings.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadRatings();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.activity-rating-view {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.rating-summary {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user