MyGradeHistory.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="myGradeHistory">
  3. <div class="chart_title">
  4. <h3 class="title">我的历次成绩</h3>
  5. <!-- <el-button type="primary" size="small" class="compare_btn" @click="showExamCompareDialog">
  6. <img src="../../../assets/studentAnalysis/echarts.svg" alt="图表" class="btn_icon">
  7. 历次考试对比
  8. </el-button> -->
  9. </div>
  10. <div class="content" v-if="gradeHistoryData.length > 0">
  11. <el-table ref="gradeTable" :data="tableData" style="width: 100%" border :header-cell-style="headerCellStyle"
  12. :cell-style="cellStyle" stripe @selection-change="handleSelectionChange" width="55" align="center">
  13. <el-table-column type="selection" width="55" align="center"></el-table-column>
  14. <el-table-column type="index" label="序号" width="70" align="center">
  15. <template slot-scope="scope">
  16. {{scope.$index <10 ? '0' + (scope.$index + 1) : scope.$index + 1 }}
  17. </template>
  18. </el-table-column>
  19. <el-table-column prop="examName" label="考试名称" align="center"></el-table-column>
  20. <el-table-column prop="fullScore" label="满分" width="90" align="center"></el-table-column>
  21. <el-table-column prop="rawScore" label="原始分" width="90" align="center"></el-table-column>
  22. <el-table-column prop="classRank" label="班级排名" width="90" align="center"></el-table-column>
  23. <el-table-column prop="gradeRank" label="年级排名" width="90" align="center"></el-table-column>
  24. <el-table-column prop="standardScore" label="标准分" width="90" align="center"></el-table-column>
  25. <el-table-column prop="scoreRate" label="得分率" width="90" align="center">
  26. <template slot-scope="scope">
  27. {{ scope.row.scoreRate }}%
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="操作" width="120" align="center">
  31. <template slot-scope="scope">
  32. <el-button type="text" @click="viewDetails(scope.row)">查看答题卡</el-button>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. <!-- 暂无数据 -->
  38. <div class="noData" v-else>
  39. <div class="module_chart no_content_data no_data" element-loading-background="#ffffff">
  40. <span>暂无数据</span>
  41. </div>
  42. </div>
  43. <!-- 学生答题卡预览组件 -->
  44. <StudentPaper v-model="showStudentPaperDialog" :paperInfo="paperInfo" :currentPageIndex="currentPageIndex"
  45. :pageTitle="paperTitle"></StudentPaper>
  46. <!-- 历次考试对比弹窗 - 使用公共组件 -->
  47. <!-- <BenchTaskSelect v-if="showBenchTaskSelect" :showDialog.sync="showBenchTaskSelect" :isMultiple="isMultiple"
  48. :title="benchTaskTitle" :before="1" @GetSelectId="GetSelectId"></BenchTaskSelect> -->
  49. </div>
  50. </template>
  51. <script>
  52. import StudentPaper from '@/components/StudentPaper.vue' //学生答题卡预览组件
  53. import { mapGetters } from 'vuex'
  54. // 导入公共组件
  55. //import BenchTaskSelect from '@/views/analysisReport/components/benchTaskSelectSchool';
  56. export default {
  57. components: {
  58. StudentPaper,
  59. // BenchTaskSelect
  60. },
  61. name: "MyGradeHistory",
  62. props: {
  63. mode: {
  64. type: String,
  65. default: 'grade'
  66. },
  67. // 接收历次成绩数据
  68. gradeHistoryData: {
  69. type: Array,
  70. default: () => []
  71. },
  72. // 接收个人画像数据
  73. portraitData: {
  74. type: Object,
  75. default: () => {}
  76. }
  77. },
  78. data() {
  79. return {
  80. showStudentPaperDialog: false, //显示答题卡弹框
  81. paperInfo: {},
  82. paperTitle: '', //答题卡弹框标题
  83. currentPageIndex: 0 ,//当前选中的答题卡第几页
  84. // 控制弹窗显示/隐藏
  85. showBenchTaskSelect: false,
  86. // 是否允许多选
  87. isMultiple: true,
  88. // 弹窗标题
  89. benchTaskTitle: '历次考试对比',
  90. // 是否正在初始化全选
  91. isInitializing: false,
  92. };
  93. },
  94. watch: {
  95. // 监听gradeHistoryData变化,数据加载完成后默认全选
  96. gradeHistoryData: {
  97. handler(newVal) {
  98. if (newVal && newVal.length > 0) {
  99. this.$nextTick(() => {
  100. if (this.$refs.gradeTable) {
  101. // 设置初始化标志,避免触发selection-change事件
  102. this.isInitializing = true;
  103. // 先清空所有选择,再重新全选
  104. this.$refs.gradeTable.clearSelection();
  105. // 遍历表格数据,手动选中每一行
  106. this.tableData.forEach(row => {
  107. this.$refs.gradeTable.toggleRowSelection(row, true);
  108. });
  109. // 完成后重置标志
  110. this.isInitializing = false;
  111. }
  112. });
  113. }
  114. },
  115. immediate: true
  116. }
  117. },
  118. computed: {
  119. ...mapGetters(['userInfo']),
  120. pageName() {
  121. return this.$store.state.report.examSelectItem.examName
  122. }, //考试名称
  123. reportParam() {
  124. return {
  125. examLevel: this.$store.state.report.filterObject.examLevel, //1-联考 2-单校
  126. contrastExamIds: this.$store.state.report.filterObject.contrastExamIds, //多次考试任务对比ID,不包含当前任务ID
  127. examId: this.$store.state.report.filterObject.examId, //考试id
  128. subjectCode: this.$store.state.report.filterObject.subjectCode, //科目code
  129. subjectGroupType: this.$store.state.report.filterObject.subjectGroupType, //是否为组合科目 1为组合科目 0为非组合科目
  130. isTotal: this.$store.state.report.filterObject.isTotal //是否为总分科目 1为总分 0为非总分
  131. }
  132. }, //分析报告公共参数变量
  133. // 处理数据,映射接口字段到表格字段
  134. tableData() {
  135. return this.gradeHistoryData.map(item => ({
  136. id: item.id || Math.random(),
  137. examName: item.examName || '',
  138. fullScore: item.fullScore,
  139. rawScore: item.originalScore, // 接口字段originalScore映射到rawScore
  140. classRank: item.classRank,
  141. gradeRank: item.gradeRank,
  142. standardScore: item.standardScore,
  143. scoreRate: item.scoreRate,
  144. examId: item.examId, //考试id
  145. subjectId: item.subjectId, //科目id
  146. }));
  147. },
  148. // 表头样式
  149. headerCellStyle() {
  150. return {
  151. backgroundColor: '#F5F7FA',
  152. color: '#303133',
  153. height: '50px',
  154. padding: '0',
  155. margin: '0',
  156. lineHeight: '50px'
  157. };
  158. },
  159. // 表格内容样式
  160. cellStyle() {
  161. return {
  162. color: '#606266',
  163. height: '50px',
  164. padding: '0',
  165. margin: '0',
  166. lineHeight: '50px'
  167. };
  168. },
  169. },
  170. methods: {
  171. // 处理选择变化
  172. handleSelectionChange(selection) {
  173. // 初始化过程中不触发事件,避免重复调用接口
  174. if (this.isInitializing) {
  175. return;
  176. }
  177. let selectedExamIds = selection.map(item => item.examId);
  178. // 传递选中的考试ID给父组件
  179. this.$emit('selection-change', selectedExamIds);
  180. },
  181. // 历史考试对比弹窗
  182. showExamCompareDialog() {
  183. this.showBenchTaskSelect = true;
  184. },
  185. // 获取选中的ID
  186. GetSelectId() {
  187. // 获取选中的考试ID
  188. const selectedExamIds = this.$store.state.report.lastExamSelectIds || [];
  189. // 通过事件将选中的考试ID传递给父组件
  190. this.$emit('select-exam-ids', selectedExamIds);
  191. // 关闭弹窗
  192. this.showBenchTaskSelect = false;
  193. },
  194. viewDetails(row) {
  195. this.paperTitle = `${row.examName}_${this.userInfo.userName}`
  196. this.paperInfo = { examId: this.reportParam.examId, subjectCode: this.reportParam.subjectCode }
  197. this.showStudentPaperDialog = true
  198. // 实际项目中可以跳转到详情页面或展开详情
  199. },
  200. }
  201. }
  202. </script>
  203. <style scoped lang="scss">
  204. .myGradeHistory {
  205. background-color: #ffffff;
  206. border-radius: 10px;
  207. padding: 20px;
  208. box-sizing: border-box;
  209. .chart_title {
  210. .title {
  211. font-size: 16px;
  212. font-weight: 600;
  213. color: #333333;
  214. margin: 0 0 20px 0;
  215. }
  216. // 历史考试对比
  217. .compare_btn {
  218. font-size: 14px;
  219. padding: 8px 10px;
  220. background: #FFFFFF;
  221. border-radius: 4px;
  222. border: 1px solid #DCDFE6;
  223. color: #333333;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. .btn_icon {
  228. width: 16px;
  229. height: 16px;
  230. margin-right: 4px;
  231. vertical-align: middle;
  232. }
  233. span {
  234. vertical-align: middle;
  235. }
  236. }
  237. }
  238. /* 表格区域 */
  239. .content {
  240. /* 调整表格斑马条纹颜色 */
  241. :deep(.el-table--striped .el-table__body tr.el-table__row--striped) {
  242. background-color: #FAFAFA !important;
  243. }
  244. /* 确保表头行高 */
  245. :deep(.el-table__header tr) {
  246. height: 50px !important;
  247. }
  248. /* 确保表格内容行高 */
  249. :deep(.el-table__body tr) {
  250. height: 50px !important;
  251. }
  252. /* 移除表头单元格内外边距 */
  253. :deep(.el-table__header th.el-table__cell) {
  254. padding: 0 !important;
  255. margin: 0 !important;
  256. height: 50px !important;
  257. line-height: 50px !important;
  258. }
  259. /* 移除表格内容单元格内外边距 */
  260. :deep(.el-table__body td.el-table__cell) {
  261. padding: 0 !important;
  262. margin: 0 !important;
  263. height: 50px !important;
  264. line-height: 50px !important;
  265. }
  266. /* 表格圆角样式 */
  267. :deep(.el-table) {
  268. border-radius: 6px !important;
  269. overflow: hidden;
  270. }
  271. /* 表头圆角 */
  272. :deep(.el-table__header-wrapper) {
  273. border-radius: 6px 6px 0 0;
  274. overflow: hidden;
  275. }
  276. /* 表尾圆角 */
  277. :deep(.el-table__body-wrapper) {
  278. border-radius: 0 0 6px 6px;
  279. overflow: hidden;
  280. }
  281. /* 表头首列圆角 */
  282. :deep(.el-table__header th.el-table__cell:first-child) {
  283. border-radius: 6px 0 0 0 !important;
  284. }
  285. /* 表头末列圆角 */
  286. :deep(.el-table__header th.el-table__cell:last-child) {
  287. border-radius: 0 6px 0 0 !important;
  288. }
  289. /* 表尾首列圆角 */
  290. :deep(.el-table__body tr:last-child td.el-table__cell:first-child) {
  291. border-radius: 0 0 0 6px !important;
  292. }
  293. /* 表尾末列圆角 */
  294. :deep(.el-table__body tr:last-child td.el-table__cell:last-child) {
  295. border-radius: 0 0 6px 0 !important;
  296. }
  297. .pagination {
  298. margin-top: 16px;
  299. display: flex;
  300. justify-content: flex-end;
  301. align-items: center;
  302. }
  303. }
  304. // 暂无数据样式
  305. .noData {
  306. position: relative;
  307. height: 220px;
  308. /* 暂无数据样式 */
  309. .no_data {
  310. position: absolute;
  311. top: 50%;
  312. left: 50%;
  313. transform: translate(-50%, -50%);
  314. font-size: 14px;
  315. color: #909399;
  316. text-align: center;
  317. width: 100%;
  318. height: 100%;
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. border-radius: 8px;
  323. span {
  324. margin-top: 11%;
  325. }
  326. }
  327. }
  328. }
  329. </style>