GradeAnalysisExport.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="grade-analysis-export analysis-export-modal">
  3. <div class="print-box">
  4. <h1>
  5. 分档详情数据
  6. </h1>
  7. <div class="quality-info">
  8. <p>科目:{{ pageInfo.subjectName }}</p>
  9. <p>考区:{{ pageInfo.areaName }}</p>
  10. <p>截止时间:{{ currentTime }}</p>
  11. </div>
  12. <div class="print-chart">
  13. <div class="print-chart-title">详细数值表:</div>
  14. <table class="export-table">
  15. <tr>
  16. <th>科目</th>
  17. <th>档位</th>
  18. <th>范围</th>
  19. <th>数量</th>
  20. <th>占比</th>
  21. <th>预设占比</th>
  22. <th>差值</th>
  23. <th>累计数量</th>
  24. <th>累计占比</th>
  25. <th>调整</th>
  26. </tr>
  27. <tr v-for="(item, index) in chartData.levelData" :key="index">
  28. <td>{{ item.subjectName }}</td>
  29. <td>{{ item.code }}</td>
  30. <td>{{ item.minScore }} ~ {{ item.maxScore }}</td>
  31. <td>{{ item.levelCount }}</td>
  32. <td>{{ item.levelProp }}%</td>
  33. <td>{{ item.examLevelProp }}%</td>
  34. <td>{{ item.diffProp }}%</td>
  35. <td>{{ item.cumulateCount }}</td>
  36. <td>{{ item.cumulateProp }}%</td>
  37. <td>{{ item.adjustmentCount }}</td>
  38. </tr>
  39. </table>
  40. </div>
  41. <div class="print-chart" v-if="chartData.lineChartData">
  42. <div class="print-chart-title">档位分布曲线图:</div>
  43. <div class="print-chart-body">
  44. <echart-render
  45. :chart-data="chartData.lineChartData"
  46. :animation-is-open="false"
  47. chart-type="line"
  48. ref="lineChart"
  49. v-if="!showImg"
  50. ></echart-render>
  51. <img src="" ref="lineChartImg" v-show="showImg" />
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import EchartRender from "@/components/EchartRender";
  59. import { download, formatDate } from "@/plugins/utils";
  60. import html2canvas from "html2canvas";
  61. export default {
  62. name: "grade-analysis-export",
  63. components: { EchartRender },
  64. props: {
  65. chartData: {
  66. type: Object,
  67. default() {
  68. return {};
  69. }
  70. },
  71. pageInfo: {
  72. type: Object,
  73. default() {
  74. return {};
  75. }
  76. }
  77. },
  78. data() {
  79. return {
  80. currentTime: formatDate(),
  81. showImg: false
  82. };
  83. },
  84. mounted() {
  85. this.$nextTick(() => {
  86. this.$refs.lineChartImg.src = this.$refs.lineChart.getDataURL({
  87. backgroundColor: "#fff"
  88. });
  89. this.showImg = true;
  90. this.$nextTick(() => {
  91. this.toExport();
  92. });
  93. });
  94. },
  95. methods: {
  96. async toExport() {
  97. const canvas = await html2canvas(this.$el.childNodes[0], {
  98. allowTaint: true
  99. }).catch(() => {});
  100. if (!canvas) {
  101. this.$emit("on-exported", false);
  102. return;
  103. }
  104. let result = true;
  105. await download({
  106. type: "post",
  107. url: `${this.GLOBAL.domain}/api/exportPdf`,
  108. data: {
  109. content: [canvas.toDataURL().split(",")[1]]
  110. },
  111. fileName: `${this.pageInfo.subjectName}-${this.pageInfo.areaName}-分档详情分析.pdf`
  112. }).catch(() => {
  113. result = false;
  114. });
  115. this.$emit("on-exported", result);
  116. }
  117. }
  118. };
  119. </script>