GradeAnalysis.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="grade-analysis">
  3. <div class="part-box">
  4. <div class="part-box-top">
  5. <Button type="success" icon="md-download" @click="toExport"
  6. >导出</Button
  7. >
  8. </div>
  9. <Table
  10. ref="TableList"
  11. :columns="columns"
  12. :data="levelData"
  13. :span-method="handleSpan"
  14. disabled-hover
  15. border
  16. v-if="levelData.length"
  17. ></Table>
  18. </div>
  19. <div class="part-box">
  20. <echart-render
  21. :chart-data="lineChartData"
  22. chart-type="line"
  23. chart-title="档位分布图"
  24. v-if="lineChartData"
  25. ></echart-render>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { gradingStatData } from "@/api";
  31. import EchartRender from "@/components/EchartRender";
  32. export default {
  33. name: "grade-analysis",
  34. components: { EchartRender },
  35. props: {
  36. questionId: {
  37. type: Number,
  38. required: true
  39. },
  40. subjectId: {
  41. type: String,
  42. required: true
  43. }
  44. },
  45. data() {
  46. return {
  47. levelData: [],
  48. lineChartData: null,
  49. columns: [
  50. {
  51. title: "科目",
  52. key: "subjectName"
  53. },
  54. {
  55. title: "档位",
  56. key: "code"
  57. },
  58. {
  59. title: "范围",
  60. render: (h, param) => {
  61. return h("div", `${param.row.minScore}~${param.row.maxScore}`);
  62. }
  63. },
  64. {
  65. title: "数量",
  66. key: "levelCount"
  67. },
  68. {
  69. title: "占比",
  70. key: "levelProp",
  71. render: (h, param) => {
  72. return h("div", `${param.row.levelProp}%`);
  73. }
  74. },
  75. {
  76. title: "预设占比",
  77. key: "examLevelProp",
  78. render: (h, param) => {
  79. return h("div", `${param.row.examLevelProp}%`);
  80. }
  81. },
  82. {
  83. title: "差值",
  84. key: "diffProp",
  85. render: (h, param) => {
  86. return h("div", `${param.row.diffProp}%`);
  87. }
  88. },
  89. {
  90. title: "累计数量",
  91. key: "cumulateCount"
  92. },
  93. {
  94. title: "累计占比",
  95. key: "cumulateProp",
  96. render: (h, param) => {
  97. return h("div", `${param.row.cumulateProp}%`);
  98. }
  99. },
  100. {
  101. title: "调整",
  102. key: "adjustmentCount"
  103. }
  104. ]
  105. };
  106. },
  107. mounted() {
  108. this.initData();
  109. },
  110. methods: {
  111. async initData() {
  112. const subs = this.subjectId.split("-");
  113. this.levelData = await gradingStatData({
  114. questionId: this.questionId,
  115. workId: subs[0],
  116. subject: subs[1]
  117. });
  118. this.lineChartData = this.levelData.map(item => {
  119. return {
  120. name: item.code,
  121. value: item.levelProp
  122. };
  123. });
  124. },
  125. handleSpan({ row, column, rowIndex, columnIndex }) {
  126. if (rowIndex === 0 && columnIndex === 0) {
  127. return { rowspan: this.levelData.length, colspan: 1 };
  128. } else if (rowIndex > 0 && columnIndex === 0) {
  129. return { rowspan: 0, colspan: 0 };
  130. }
  131. },
  132. toExport() {}
  133. }
  134. };
  135. </script>