GradeAnalysis.vue 3.2 KB

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