academicYearStats.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!-- 学年数据统计 -->
  2. <template>
  3. <view class="academicYearStats-component">
  4. <view class="card">
  5. <view class="card-header">
  6. <text class="card-title">📊 学年数据统计</text>
  7. <view class="btn-outline" @click="examElLabEduRelationGraduationReport">成绩报告</view>
  8. </view>
  9. <view class="card-body">
  10. <view class="year-row" v-for="(item, index) in yearStatsList" :key="index">
  11. <text class="year-label">{{ item.year }}</text>
  12. <text :class="['year-status', item.statusClass]">{{ item.statusText }}</text>
  13. </view>
  14. <view v-if="!yearStatsList.length" class="empty-tip">暂无统计数据</view>
  15. </view>
  16. </view>
  17. <dataStatisticsReport v-if="dialogType" :dataStatisticsReportPropsData="dataStatisticsReportPropsData"></dataStatisticsReport>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. examElLabEduRelationAcademicYearProgress,
  23. examElLabEduRelationGraduationReport,
  24. } from '@/pages_safetyEducationExamination/api/index.js'
  25. import { dataStatisticsReport } from './dataStatisticsReport'
  26. export default {
  27. components: {
  28. dataStatisticsReport,
  29. },
  30. data() {
  31. return {
  32. yearStatsList: [],
  33. dataStatisticsReportPropsData:{},
  34. dialogType:false,
  35. }
  36. },
  37. created() {
  38. },
  39. mounted() {
  40. this.examElLabEduRelationAcademicYearProgress();
  41. },
  42. methods: {
  43. //年度数据
  44. async examElLabEduRelationAcademicYearProgress() {
  45. try {
  46. const { data } = await examElLabEduRelationAcademicYearProgress();
  47. if (data.code === 200) {
  48. this.yearStatsList = (data.data || []).map(item => ({
  49. year: item.academicYear,
  50. statusText: item.statusCode == '0' ? `未开始` : (item.statusCode == '2' ? `通过 · `+item.score+` 分` : (item.statusCode == '1' ? `进行中` : '未通过')),
  51. statusClass: item.statusCode == '2' ? 'year-status-pass' : (item.statusCode == '1' ? 'year-status-going' : 'year-status-text')
  52. }));
  53. }
  54. } catch (e) { console.error('获取学年统计失败', e); }
  55. },
  56. async examElLabEduRelationGraduationReport() {
  57. try {
  58. const { data } = await examElLabEduRelationGraduationReport({});
  59. if(data.data.studyHoursList[0]&&data.data.examPassRecords[0]){
  60. this.$set(this, 'dataStatisticsReportPropsData', data.data);
  61. this.$set(this,'dialogType',true);
  62. }else{
  63. uni.showToast({
  64. title: '请完成至少一次课程学习与考试',
  65. icon:"none",
  66. mask:true,
  67. duration: 2000
  68. });
  69. }
  70. } catch (e) { console.error('获取成绩报表失败', e); }
  71. },
  72. },
  73. }
  74. </script>
  75. <style lang="stylus" scoped>
  76. .academicYearStats-component {
  77. margin:0 32rpx 32rpx;
  78. .card {
  79. background: #fff;
  80. border-radius: 24rpx;
  81. overflow: hidden;
  82. margin-bottom: 24rpx;
  83. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  84. border: 1px solid #dde3ed;
  85. }
  86. .card-header {
  87. background: #f4f6fa;
  88. padding: 20rpx 28rpx;
  89. display: flex;
  90. justify-content: space-between;
  91. align-items: center;
  92. .card-title {
  93. font-size: 28rpx;
  94. font-weight: 700;
  95. color: #333;
  96. }
  97. .btn-outline{
  98. height: 56rpx;
  99. line-height:56rpx;
  100. font-size: 24rpx;
  101. padding: 0 20rpx;
  102. border-radius: 12rpx;
  103. color: #1857d4;
  104. border: 1px solid rgba(24, 87, 212, .3);
  105. }
  106. .header-link {
  107. font-size: 24rpx;
  108. color: #1857d4;
  109. }
  110. }
  111. .card-body {
  112. padding: 16rpx 28rpx 24rpx;
  113. // 学年统计样式
  114. .year-row {
  115. display: flex;
  116. justify-content: space-between;
  117. align-items: center;
  118. padding: 12rpx 0;
  119. border-bottom: 1px solid #f4f6fa;
  120. &:last-child { border-bottom: none; }
  121. }
  122. .year-label { font-size: 26rpx; color: #333; font-weight: 500; }
  123. .year-status { font-size: 24rpx; font-weight: 500; }
  124. .year-status-pass { color: #0d8f6f;font-weight:600; }
  125. .year-status-going { color: #1857d4; }
  126. .year-status-text { color: #333; }
  127. .empty-tip { text-align: center; padding: 30rpx 0; color: #ccc; font-size: 24rpx; }
  128. }
  129. }
  130. </style>