Blame view

src/views/basic/askTestQuestion/components/testSummaryReport.vue 10.4 KB
f45b3c05   LH_PC   云平台新UI界面
1
2
3
4
5
6
7
8
9
10
11
  <template>
      <div style="margin-right: 20px;width: 100%">
          <el-row class="row-type">
              <div style="float: right;">
                  <el-button type="primary" @click="_export" icon="el-icon-upload2" class="opration-btn">导出报表</el-button>
                  <el-button type="primary" @click="_print" icon="el-icon-printer" class="opration-btn">打印报表</el-button>
              </div>
          </el-row>
          <div id="print-content">
              <el-row class="row-table">
                  <el-table border class="default-table" :data="stageReport" style="width: 100%">
6bca489d   LH_PC   云平台二期UI
12
13
                      <el-table-column prop="studentCode" label="学号" fixed></el-table-column>
                      <el-table-column prop="studentName" label="姓名" fixed>
f45b3c05   LH_PC   云平台新UI界面
14
15
                          <template slot-scope="scoped">
                              {{ scoped.row.studentName }}
6bca489d   LH_PC   云平台二期UI
16
17
18
                          </template>
                      </el-table-column>
                      <el-table-column v-if="answerList" v-for="(item, index) in answerList" :key="index"
f45b3c05   LH_PC   云平台新UI界面
19
                          :label="item.title">
6bca489d   LH_PC   云平台二期UI
20
21
22
23
24
25
26
27
28
29
30
31
32
33
                          <template slot='header' slot-scope="scope" label="use show-overflow-tooltip"
                              show-overflow-tooltip>
                              <el-tooltip v-if="item.title != '阶段汇总'" effect="dark" :content="item.title"
                                  placement="left">
                                  <span class="overflowText overClick" @click="_headerClick(item)"
                                      style="color:rgb(121,138,245);width: 100%;height: 100%;">
                                      {{ item.title }}
                                  </span>
                              </el-tooltip>
                              <span v-else>
                                  {{ item.title }}
                              </span>
                          </template>
                          <el-table-column :prop="'score' + index" :label="index == 0 ? '总分' : '总分'"
f45b3c05   LH_PC   云平台新UI界面
34
35
36
37
38
39
40
41
42
43
                              :class-name="index % 2 == 0 ? 'bg' : ''">
                              <template slot-scope="scoped">
                                  {{
                      scoped.row["score" + index] ||
                          Number(scoped.row["score" + index]) === 0
                          ? scoped.row["score" + index]
                          : "-"
                  }}
                              </template>
                          </el-table-column>
6bca489d   LH_PC   云平台二期UI
44
                          <el-table-column :prop="'classRank' + index" label="排名"
f45b3c05   LH_PC   云平台新UI界面
45
46
47
48
49
50
51
52
53
                              :class-name="index % 2 == 0 ? 'bg' : ''">
                              <template slot-scope="scoped">{{
                      scoped.row["classRank" + index] ||
                          Number(scoped.row["classRank" + index]) === 0
                          ? scoped.row["classRank" + index]
                          : "-"
                  }}</template>
                          </el-table-column>
                      </el-table-column>
6bca489d   LH_PC   云平台二期UI
54
                      <el-table-column label="查看折线图" fixed="right" align="center" width="120">
f45b3c05   LH_PC   云平台新UI界面
55
56
57
58
59
60
61
62
63
64
65
                          <template slot-scope="scoped">
                              <el-button type="text" @click="_openLineChart(scoped.row)">查看</el-button>
                          </template>
                      </el-table-column>
                  </el-table>
              </el-row>
          </div>
          <!-- 折线图 -->
          <el-dialog class="chart-dia" :visible.sync="lineChart.visible" :title="lineChart.title" width="800"
              :append-to-body="true">
              <div class="chart-box">
6bca489d   LH_PC   云平台二期UI
66
                  <LineChart id="askLineChart" :params="lineChart.data" :xAxis="lineChart.xAxis" />
f45b3c05   LH_PC   云平台新UI界面
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
              </div>
          </el-dialog>
          <ExportDia :exportStudent="exportStudent" :diaShow="diaShow" @cancel="cancel" @exportData="exportData"
              :type="'折线图'" />
      </div>
  </template>
  <script>
  import { formatDate } from "utils";
  import { downloadFile, tablePrint } from "@/utils";
  import LineChart from "@/components/charts/lineChart";
  export default {
      name: "testSummaryReport",
      components: {
          LineChart
      },
      props: {
          testReportIds: Array,
6bca489d   LH_PC   云平台二期UI
84
85
          queryParams: Object,
          role: "",
f45b3c05   LH_PC   云平台新UI界面
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
      },
      async created() {
          await this._phaseExamReport();
          // await this._changeType();
      },
      watch: {
          $props: {
              handler: async function (val) {
                  await this._phaseExamReport();
              },
              deep: false,
          }
      },
      data() {
          return {
              page: 1,
              size: 10,
              total: 0,
              diaShow: false,
              stageReport: [],
              exportStudent: [],
              answerList: null,
              //折线图数据对象
              lineChart: {
                  data: [],
                  xAxis: [],
                  title: "",
                  visible: false
              },
          };
      },
      methods: {
6bca489d   LH_PC   云平台二期UI
118
119
120
          _headerClick(currentItem) {
              this.$emit("headerClick", currentItem);
          },
f45b3c05   LH_PC   云平台新UI界面
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
          async _export() {
              this.diaShow = true;
          },
          cancel() {
              this.diaShow = false;
          },
          async _phaseExamReport() {
              const phaseExamReport =
                  this.role == "ROLE_PERSONAL"
                      ? this.$request.pPhaseExamReport
                      : this.$request.phaseExamReport;
  
              let query = {
                  examIds: this.$props.testReportIds,
                  classIds: [this.$props.queryParams.class],
6bca489d   LH_PC   云平台二期UI
136
137
138
                  subjectName: [this.$props.queryParams.subject],
                  startDay: this.$props.queryParams.dateRange[0] ?? null,
                  endDay: this.$props.queryParams.dateRange[1] ?? null,
f45b3c05   LH_PC   云平台新UI界面
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
              };
  
              const { data, status, info } = await phaseExamReport({
                  ...query
              });
  
              if (status != 0) {
                  this.$message.error(info);
                  return;
              }
  
              this.total = data.count;
              let dataIdsList = [],
                  dataList = [];
              data?.list.map((item) => {
                  item.examList.map((items) => {
                      if (!dataIdsList.includes(items.title)) {
                          dataIdsList.push(items.title);
                          dataList.push(items);
                      }
                  });
              });
6bca489d   LH_PC   云平台二期UI
161
              console.log('lsit', data?.list)
f45b3c05   LH_PC   云平台新UI界面
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
              this.stageReport = data?.list.map((item) => {
                  let params = {};
                  dataIdsList.map((ids, index) => {
                      params["score" + index] = "--";
                      params["classRank" + index] = "--";
                      item.examList.map((items) => {
                          if (items.title == ids) {
                              params["score" + index] = Number(items.score);
                              params["classRank" + index] = items.classRank;
                          }
                      });
                  });
                  return {
                      ...item,
                      ...params,
                  };
              });
  
              this.answerList = dataList;
  
              this.exportStudent = [...this.stageReport];
          },
          async exportData(arr) {
              let studentIds = arr;
              let query = {};
              if (studentIds != null) {
                  if (studentIds.length > 0) {
                      query.studentIds = studentIds;
                  } else {
                      query.studentIds = [];
                  }
              }
  
              const exportPhaseExamReport =
                  this.role == "ROLE_PERSONAL"
                      ? this.$request.pExportPhaseExamReport
                      : this.$request.exportPhaseExamReport;
  
6bca489d   LH_PC   云平台二期UI
200
  
f45b3c05   LH_PC   云平台新UI界面
201
202
203
204
              const data = await exportPhaseExamReport({
                  examIds: this.$props.testReportIds,
                  classIds: [this.$props.queryParams.class],
                  subjectName: [this.$props.queryParams.subject],
6bca489d   LH_PC   云平台二期UI
205
206
                  startDay: this.$props.queryParams?.dateRange[0] ?? null,
                  endDay: this.$props.queryParams?.dateRange[1] ?? null,
f45b3c05   LH_PC   云平台新UI界面
207
208
209
                  ...query
              });
  
6bca489d   LH_PC   云平台二期UI
210
  
f45b3c05   LH_PC   云平台新UI界面
211
              if (data) {
6bca489d   LH_PC   云平台二期UI
212
  
f45b3c05   LH_PC   云平台新UI界面
213
214
215
216
217
218
                  this.cancel();
  
                  let blob = new Blob([data], {
                      type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                  });
  
6bca489d   LH_PC   云平台二期UI
219
                  let name = `即时测-${this.$props.queryParams.subject}-单科多卷报表.xlsx`;
f45b3c05   LH_PC   云平台新UI界面
220
221
222
223
224
225
226
227
228
229
  
                  downloadFile(this.status ? "即时测-已归档单课时报表.xlsx" : name, blob);
              } else {
                  this.$message.error("下载失败");
              }
          },
          _print() {
              tablePrint("print-content", "即时测-已归档单课时报表");
          },
          _titleClick() { },
6bca489d   LH_PC   云平台二期UI
230
231
232
          _openLineChart(chartRow) { 
              var subejct = this.$props.role == 'ROLE_BANZHUREN' ? this.$props.queryParams.subjects[0] : this.$props.queryParams.subject;
              this.lineChart.title = `${chartRow.studentName}-${subejct}-即时测-多卷作答表现图`;
f45b3c05   LH_PC   云平台新UI界面
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
              this.lineChart.visible = true;
              let score = [];
              let classRank = [];
              let avgScore = [];
              const examList = chartRow.examList.slice(1, chartRow.examList.length);
              this.lineChart.xAxis = examList.map((item) => {
                  score.push(item.score);
                  classRank.push(item.classRank);
                  avgScore.push(item.avgScore);
                  return item.title;
              });
              this.lineChart.data = [
                  {
                      name: "班级排名",
                      value: classRank,
                  },
                  {
                      name: "班平均分",
                      value: avgScore,
                  },
                  {
                      name: "个人成绩",
                      value: score,
                  },
              ];
          },
      }
  };
  </script>
  <style scoped lang="scss">
  .opration-btn {
      margin-right: 10px;
  }
  
  .opration-select {
      margin-left: 10px;
  }
  
  .row-line {
      width: calc(20% - 2px);
      border: 1px solid #ebeef5;
      background: #f5f7fa;
      display: inline-block;
      height: 40px;
      line-height: 40px;
  
      .line-subfix {
          margin-left: 10px;
  
      }
  }
  
  .row-table {
      margin-top: 20px;
  }
  
  .chart-dia {
      .chart-box {
f45b3c05   LH_PC   云平台新UI界面
291
292
293
294
295
296
297
          height: 300px;
      }
  
      :deep(.el-dialog__body) {
          padding: 0 0 20px 0;
      }
  }
6bca489d   LH_PC   云平台二期UI
298
299
300
301
  
  .overClick:hover {
      cursor: pointer;
  }
f45b3c05   LH_PC   云平台新UI界面
302
  </style>