academicYearStats.vue 4.0 KB

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