ReportQuestion.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="report-question">
  3. <report-box v-for="(page, pindex) in pages" :key="pindex" :title="title">
  4. <div v-if="page.charts" class="question-chart" :style="page.charts.style">
  5. <v-chart
  6. :option="page.charts.chart"
  7. :init-options="initOption"
  8. ></v-chart>
  9. </div>
  10. <table v-if="page.tables" class="report-table report-table-border">
  11. <tr>
  12. <th>题目名称</th>
  13. <th>大题号</th>
  14. <th>小题号</th>
  15. <th>单题分数</th>
  16. <th>单题平均分</th>
  17. <th>得分率(%)</th>
  18. <th>满分率(%)</th>
  19. </tr>
  20. <tr v-for="(item, ind) in page.tables" :key="ind">
  21. <td class="td-question">
  22. <div>{{ item.title }}</div>
  23. </td>
  24. <td>{{ item.mainNumber }}</td>
  25. <td>{{ item.subNumber }}</td>
  26. <td>{{ item.score }}</td>
  27. <td>{{ item.avgScore }}</td>
  28. <td>{{ item.scoreRate | progressFilter }}</td>
  29. <td>{{ item.fullScoreRate | progressFilter }}</td>
  30. </tr>
  31. </table>
  32. </report-box>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapState } from "vuex";
  37. import ReportBox from "./ReportBox.vue";
  38. import { sectionArr } from "./utils";
  39. import { getBarPointTopicOptions, initOption } from "./chart";
  40. export default {
  41. name: "report-question",
  42. components: { ReportBox },
  43. props: {
  44. type: String,
  45. },
  46. data() {
  47. return {
  48. questionCharts: [],
  49. questionTables: [],
  50. pages: [],
  51. chartSplitRange: 30,
  52. initOption,
  53. };
  54. },
  55. computed: {
  56. ...mapState("report", ["objective", "subjective"]),
  57. typeName() {
  58. return this.type === "subjective" ? "主观题" : "客观题";
  59. },
  60. title() {
  61. return `${this.typeName}成绩分析`;
  62. },
  63. },
  64. mounted() {
  65. this.initData();
  66. },
  67. methods: {
  68. initData() {
  69. const question =
  70. this.type === "subjective" ? this.subjective : this.objective;
  71. const questionCharts = sectionArr(question, this.chartSplitRange).map(
  72. (data) => {
  73. return {
  74. chart: getBarPointTopicOptions(data),
  75. count: data.length,
  76. style: this.getChartStyle(data.length),
  77. };
  78. }
  79. );
  80. const questionTables = sectionArr(question, this.chartSplitRange);
  81. let pages = [];
  82. if (question.length <= 14) {
  83. pages = [
  84. {
  85. charts: questionCharts[0],
  86. tables: questionTables[0],
  87. },
  88. ];
  89. } else {
  90. questionCharts.forEach((chart) => {
  91. pages.push({
  92. charts: chart,
  93. tables: null,
  94. });
  95. });
  96. questionTables.forEach((table) => {
  97. pages.push({
  98. charts: null,
  99. tables: table,
  100. });
  101. });
  102. }
  103. this.pages = pages;
  104. },
  105. getChartStyle(count) {
  106. const labelHeight = 28;
  107. return {
  108. height: `${100 + count * labelHeight}px`,
  109. };
  110. },
  111. },
  112. };
  113. </script>