Blame view

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