Blame view

src/views/basic/test/components/multipleSubTest.vue 10.3 KB
86201e49   梁保满   即时测模块
1
2
3
4
  <template>
    <div class="table-box" ref="main" v-loading="loading">
      <div id="print-content">
        <!-- 多科多卷 -->
696f2d42   梁保满   fix:报表导出问题
5
6
7
8
9
10
11
12
13
14
15
16
        <el-table
          :data="tableData"
          :max-height="tableMaxHeight"
          border
          style="width: 100%"
        >
          <el-table-column
            prop="studentCode"
            label="学号"
            align="center"
            fixed
          ></el-table-column>
86201e49   梁保满   即时测模块
17
18
  
          <el-table-column prop="studentName" label="姓名" fixed align="center">
696f2d42   梁保满   fix:报表导出问题
19
20
            <template slot-scope="scoped"
              ><span class="click-b" @click="toPortrait(scoped.row)">
86201e49   梁保满   即时测模块
21
                {{ scoped.row.studentName }}
696f2d42   梁保满   fix:报表导出问题
22
23
              </span></template
            >
86201e49   梁保满   即时测模块
24
          </el-table-column>
696f2d42   梁保满   fix:报表导出问题
25
26
27
28
29
30
31
32
33
34
35
          <el-table-column
            align="center"
            v-for="(item, index) in answerList"
            :key="index"
            :label="item"
          >
            <el-table-column
              :prop="'examCount' + item"
              label="测练数"
              align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"
6b3dde63   梁保满   随堂问,即时测没有数据显示-,其他...
36
37
38
39
40
41
42
43
            >
              <template slot-scope="scoped">{{
                scoped.row["examCount" + item] ||
                Number(scoped.row["examCount" + item]) === 0
                  ? scoped.row["examCount" + item]
                  : "-"
              }}</template>
            </el-table-column>
696f2d42   梁保满   fix:报表导出问题
44
45
46
47
48
            <el-table-column
              :prop="'participationCount' + item"
              label="参与数"
              align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"
6b3dde63   梁保满   随堂问,即时测没有数据显示-,其他...
49
50
51
52
53
54
55
56
            >
              <template slot-scope="scoped">{{
                scoped.row["participationCount" + item] ||
                Number(scoped.row["participationCount" + item]) === 0
                  ? scoped.row["participationCount" + item]
                  : "-"
              }}</template>
            </el-table-column>
696f2d42   梁保满   fix:报表导出问题
57
58
59
60
61
            <el-table-column
              :prop="'score' + item"
              label="总分"
              align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"
6b3dde63   梁保满   随堂问,即时测没有数据显示-,其他...
62
63
64
65
66
67
68
69
            >
              <template slot-scope="scoped">{{
                scoped.row["score" + item] ||
                Number(scoped.row["score" + item]) === 0
                  ? scoped.row["score" + item]
                  : "-"
              }}</template>
            </el-table-column>
696f2d42   梁保满   fix:报表导出问题
70
71
72
73
74
            <el-table-column
              :prop="'classRank' + item"
              label="班名"
              align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"
6b3dde63   梁保满   随堂问,即时测没有数据显示-,其他...
75
76
77
78
79
80
81
82
            >
              <template slot-scope="scoped">{{
                scoped.row["classRank" + item] ||
                Number(scoped.row["classRank" + item]) === 0
                  ? scoped.row["classRank" + item]
                  : "-"
              }}</template>
            </el-table-column>
86201e49   梁保满   即时测模块
83
          </el-table-column>
22095aba   梁保满   接口联调
84
          <el-table-column label="查看雷达图" align="center">
86201e49   梁保满   即时测模块
85
            <template slot-scope="scoped">
696f2d42   梁保满   fix:报表导出问题
86
87
88
89
90
91
92
              <el-button
                @click="openChart(scoped.row)"
                type="primary"
                size="mini"
                circle
                icon="el-icon-arrow-right"
              ></el-button>
86201e49   梁保满   即时测模块
93
94
95
96
97
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="down">
696f2d42   梁保满   fix:报表导出问题
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
        <el-button
          @click="openDown"
          type="primary"
          plain
          round
          icon="fa fa-cloud-download"
          >导出报表</el-button
        >
        <el-button
          v-if="!this.$store.getters.code"
          @click="print"
          type="primary"
          plain
          round
          icon="el-icon-printer"
          >打印</el-button
        >
86201e49   梁保满   即时测模块
115
      </div>
f45b3c05   LH_PC   云平台新UI界面
116
      <el-dialog :append-to-body="true"
696f2d42   梁保满   fix:报表导出问题
117
118
119
120
121
        class="chart-dia"
        :visible.sync="chartDia"
        :title="chartTitle"
        width="800"
      >
86201e49   梁保满   即时测模块
122
123
124
125
        <div class="chart-box">
          <RadarChart id="radarChart" :params="chartData" />
        </div>
      </el-dialog>
696f2d42   梁保满   fix:报表导出问题
126
127
128
129
130
131
132
133
      <ExportDia
        :exportStudent="exportStudent"
        :diaShow="diaShow"
        @cancel="cancel"
        @exportData="exportData"
        lastLabel="总分"
        type="雷达图"
      />
86201e49   梁保满   即时测模块
134
135
136
    </div>
  </template>
  <script>
696f2d42   梁保满   fix:报表导出问题
137
  import RadarChart from "@/components/charts/radarChart";
86201e49   梁保满   即时测模块
138
139
140
141
  
  import { downloadFile, tablePrint } from "@/utils";
  export default {
    components: {
e17ec739   梁保满   随堂问,即时测导出爆表修改
142
      RadarChart,
86201e49   梁保满   即时测模块
143
144
145
146
    },
    props: {
      role: "",
      ids: Array,
7222c2eb   梁保满   汇总前置条件修改,教学,行政可汇总
147
      classIds: Array,
7812e986   梁保满   班主任查看报表添加额外信息
148
      subjectName: String,
86201e49   梁保满   即时测模块
149
150
151
152
153
154
155
156
157
158
159
    },
    data() {
      return {
        tableMaxHeight: null,
        answerList: [], //设置多卷内容供tableStage表格数据用
        tableData: [],
        loading: false,
        exportLoading: false,
        chartData: {
          indicator: [
            {
696f2d42   梁保满   fix:报表导出问题
160
161
              name: "",
              max: 100,
86201e49   梁保满   即时测模块
162
163
164
              axisLabel: {
                show: true,
                showMaxLabel: true,
86201e49   梁保满   即时测模块
165
166
167
              },
            },
          ],
696f2d42   梁保满   fix:报表导出问题
168
          seriesData: [],
86201e49   梁保满   即时测模块
169
170
171
        },
        chartDia: false,
        chartTitle: "",
e17ec739   梁保满   随堂问,即时测导出爆表修改
172
173
174
  
        //导出相关
        diaShow: false,
696f2d42   梁保满   fix:报表导出问题
175
176
        exportStudent: [],
      };
86201e49   梁保满   即时测模块
177
178
179
    },
    computed: {
      subjectList: function () {
696f2d42   梁保满   fix:报表导出问题
180
181
        return this.subjectName?.split(",");
      },
86201e49   梁保满   即时测模块
182
183
    },
    created() {
696f2d42   梁保满   fix:报表导出问题
184
      this.phaseExamReport();
86201e49   梁保满   即时测模块
185
186
187
188
189
190
    },
    mounted() {
      this.tableMaxHeight = this.$refs.main.offsetHeight;
    },
    methods: {
      print() {
696f2d42   梁保满   fix:报表导出问题
191
        tablePrint("print-content", this.subjectName + "汇总报表");
86201e49   梁保满   即时测模块
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
      },
      toPortrait(obj) {
        //暂时不上线
        return;
        if (this.$store.getters.code) {
          return;
        }
        let subjectNames = [];
        subjectNames =
          this.role == "ROLE_BANZHUREN"
            ? [...this.query["subjectNames"]]
            : [this.query["subjectNames"]];
        if (
          this.query["subjectNames"] &&
          this.query["subjectNames"]?.length == 1 &&
          this.query["subjectNames"][0] == "全部"
        ) {
          subjectNames = this.subjectList.map((item) => {
            return item.value;
          });
          subjectNames?.shift();
        }
        //去学生画像
        this.$router.push({
          path: "/portraitDetail",
          query: {
            id: obj.studentId,
            classId: this.query.classId,
            subjectNames: subjectNames.join(","),
            studentName: obj.studentName,
            studentCode: obj.studentCode,
            startDay: this.query.startDay,
            endDay: this.query.endDay,
            date: this.date,
          },
        });
      },
22095aba   梁保满   接口联调
229
      //查看雷达图
86201e49   梁保满   即时测模块
230
      openChart(obj) {
696f2d42   梁保满   fix:报表导出问题
231
        this.chartTitle = obj.studentName + "-多科-多课时作答表现图";
7812e986   梁保满   班主任查看报表添加额外信息
232
        let max = 0;
696f2d42   梁保满   fix:报表导出问题
233
234
235
236
237
238
239
240
        const dataList = obj.dataList.slice(1, obj.dataList.length);
        let subjectList = dataList.map((item) => {
          let score = Number(item.highestScore || item.score);
          max = score > max ? score : max;
          return item.subjectName;
        });
        max += 10;
        max = max > 150 ? 150 : max;
7812e986   梁保满   班主任查看报表添加额外信息
241
242
243
        this.chartData = {
          indicator: [
            {
696f2d42   梁保满   fix:报表导出问题
244
245
              name: "",
              max: max,
7812e986   梁保满   班主任查看报表添加额外信息
246
247
248
249
250
251
              axisLabel: {
                show: true,
                showMaxLabel: true,
              },
            },
          ],
696f2d42   梁保满   fix:报表导出问题
252
253
          seriesData: [],
        };
86201e49   梁保满   即时测模块
254
255
        subjectList.map((item, index) => {
          if (index < 1) {
696f2d42   梁保满   fix:报表导出问题
256
257
            this.chartData.indicator[index].name = item;
            this.chartData.indicator[index].max = max;
86201e49   梁保满   即时测模块
258
          } else {
696f2d42   梁保满   fix:报表导出问题
259
            this.chartData.indicator.push({ name: item, max: max });
86201e49   梁保满   即时测模块
260
          }
696f2d42   梁保满   fix:报表导出问题
261
        });
e17ec739   梁保满   随堂问,即时测导出爆表修改
262
        // 为了美观
86201e49   梁保满   即时测模块
263
        if (this.chartData.indicator.length < 3) {
696f2d42   梁保满   fix:报表导出问题
264
          let num = this.chartData.indicator.length;
86201e49   梁保满   即时测模块
265
266
          for (let i = 0; i < 6; i++) {
            if (i >= num) {
696f2d42   梁保满   fix:报表导出问题
267
              this.chartData.indicator.push({ name: "", max: max });
86201e49   梁保满   即时测模块
268
269
270
271
272
            }
          }
        }
        this.chartData.seriesData = [
          {
696f2d42   梁保满   fix:报表导出问题
273
274
            value: dataList.map((item) => item.highestScore),
            name: "班级最高分",
86201e49   梁保满   即时测模块
275
276
          },
          {
696f2d42   梁保满   fix:报表导出问题
277
278
            value: dataList.map((item) => item.avgScore),
            name: "班平均分",
22095aba   梁保满   接口联调
279
280
          },
          {
696f2d42   梁保满   fix:报表导出问题
281
282
            value: dataList.map((item) => item.score),
            name: "本人得分",
86201e49   梁保满   即时测模块
283
          },
696f2d42   梁保满   fix:报表导出问题
284
285
        ];
        this.chartDia = true;
86201e49   梁保满   即时测模块
286
287
288
289
      },
      async phaseExamReport() {
        this.loading = true;
        const { data, status, info } = await this.$request.cTPhaseExamReport({
7222c2eb   梁保满   汇总前置条件修改,教学,行政可汇总
290
          classIds: this.classIds,
86201e49   梁保满   即时测模块
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
          examIds: this.ids,
          subjectNames: this.subjectList,
        });
        this.loading = false;
        if (status === 0) {
          this.total = data.count;
          let subjectName = [];
          this.tableData = data?.list.map((item) => {
            let params = {};
            item.dataList.map((items, index) => {
              if (!subjectName.includes(items.subjectName)) {
                subjectName.push(items.subjectName);
              }
              params["examCount" + items.subjectName] = items.examCount;
              params["participationCount" + items.subjectName] =
                items.participationCount;
              params["score" + items.subjectName] = items.score;
              params["classRank" + items.subjectName] = items.classRank;
            });
            return {
              ...item,
              ...params,
            };
          });
          this.answerList = [...subjectName];
696f2d42   梁保满   fix:报表导出问题
316
          this.exportStudent = [...this.tableData];
86201e49   梁保满   即时测模块
317
318
319
320
321
        } else {
          this.$message.error(info);
        }
      },
      //导出
e17ec739   梁保满   随堂问,即时测导出爆表修改
322
323
324
325
326
327
328
      openDown() {
        this.diaShow = true;
      },
      cancel() {
        this.diaShow = false;
      },
      async exportData(arr) {
86201e49   梁保满   即时测模块
329
330
        if (this.exportLoading == true) return;
        this.exportLoading = true;
696f2d42   梁保满   fix:报表导出问题
331
        let studentIds = arr;
e17ec739   梁保满   随堂问,即时测导出爆表修改
332
        let query = {};
696f2d42   梁保满   fix:报表导出问题
333
        if (studentIds != null) {
ce278878   梁保满   2-2 bugfix
334
          if (studentIds.length > 0) {
696f2d42   梁保满   fix:报表导出问题
335
            query.studentIds = studentIds;
ce278878   梁保满   2-2 bugfix
336
          } else {
696f2d42   梁保满   fix:报表导出问题
337
            query.studentIds = [];
ce278878   梁保满   2-2 bugfix
338
          }
e17ec739   梁保满   随堂问,即时测导出爆表修改
339
        }
f9916d4c   梁保满   导出摸板
340
  
f9916d4c   梁保满   导出摸板
341
        const data = await this.$request.cTExportPhaseExamReport({
7222c2eb   梁保满   汇总前置条件修改,教学,行政可汇总
342
          classIds: this.classIds,
049db2b2   梁保满   接口联调
343
          examIds: this.ids,
696f2d42   梁保满   fix:报表导出问题
344
          ...query,
86201e49   梁保满   即时测模块
345
346
347
348
349
350
351
352
        });
        this.exportLoading = false;
        if (data) {
          let blob = new Blob([data], {
            type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          });
          downloadFile(
            this.status
f9916d4c   梁保满   导出摸板
353
354
              ? "即时测-已归档多科汇总报表.xlsx"
              : "即时测-多科汇总报表.xlsx",
86201e49   梁保满   即时测模块
355
356
            blob
          );
f9916d4c   梁保满   导出摸板
357
          this.$message.success("下载成功");
696f2d42   梁保满   fix:报表导出问题
358
          this.cancel();
86201e49   梁保满   即时测模块
359
360
361
362
        } else {
          this.$message.error("下载失败");
        }
      },
696f2d42   梁保满   fix:报表导出问题
363
    },
86201e49   梁保满   即时测模块
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
  };
  </script>
  <style lang="scss" scoped>
  .table-box {
    padding: 20px;
  }
  
  .down {
    padding-top: 20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  
  .chart-dia {
    .chart-box {
      width: 100%;
      height: 400px;
    }
  
    :deep(.el-dialog__body) {
      padding: 0 0 20px 0;
    }
  }
  </style>