academicYearStats.vue 4.0 KB

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