Blame view

src/views/basic/test/components/multipleSubTest.vue 8.48 KB
86201e49   梁保满   即时测模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  <template>
    <div class="table-box" ref="main" v-loading="loading">
      <div id="print-content">
        <!-- 多科多卷 -->
        <el-table :data="tableData" :max-height="tableMaxHeight" border style="width: 100%">
          <el-table-column prop="studentCode" label="学号" align="center" fixed></el-table-column>
  
          <el-table-column prop="studentName" label="姓名" fixed align="center">
            <template slot-scope="scoped"><span class="click-b" @click="toPortrait(scoped.row)">
                {{ scoped.row.studentName }}
              </span></template>
          </el-table-column>
          <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' : ''"></el-table-column>
            <el-table-column :prop="'participationCount' + item" label="参与数" align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"></el-table-column>
            <el-table-column :prop="'score' + item" label="总分" align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"></el-table-column>
            <el-table-column :prop="'classRank' + item" label="班名" align="center"
              :class-name="index % 2 == 0 ? 'bg' : ''"></el-table-column>
          </el-table-column>
22095aba   梁保满   接口联调
23
          <el-table-column label="查看雷达图" align="center">
86201e49   梁保满   即时测模块
24
25
26
27
28
29
30
31
            <template slot-scope="scoped">
              <el-button @click="openChart(scoped.row)" type="primary" size="mini" circle
                icon="el-icon-arrow-right"></el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="down">
e17ec739   梁保满   随堂问,即时测导出爆表修改
32
        <el-button @click="openDown" type="primary" plain round icon="fa fa-cloud-download">导出报表</el-button>
86201e49   梁保满   即时测模块
33
34
35
36
37
38
39
40
        <el-button v-if="!this.$store.getters.code" @click="print" type="primary" plain round
          icon="el-icon-printer">打印</el-button>
      </div>
      <el-dialog class="chart-dia" :visible.sync="chartDia" :title="chartTitle" width="800">
        <div class="chart-box">
          <RadarChart id="radarChart" :params="chartData" />
        </div>
      </el-dialog>
e17ec739   梁保满   随堂问,即时测导出爆表修改
41
      <ExportDia :exportStudent="exportStudent" :diaShow="diaShow" @cancel="cancel" @exportData="exportData" />
86201e49   梁保满   即时测模块
42
43
44
45
46
47
48
49
    </div>
  </template>
  <script>
  import RadarChart from "@/components/charts/radarChart"
  
  import { downloadFile, tablePrint } from "@/utils";
  export default {
    components: {
e17ec739   梁保满   随堂问,即时测导出爆表修改
50
      RadarChart,
86201e49   梁保满   即时测模块
51
52
53
54
    },
    props: {
      role: "",
      ids: Array,
7812e986   梁保满   班主任查看报表添加额外信息
55
56
      classId: String,
      subjectName: String,
86201e49   梁保满   即时测模块
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    },
    data() {
      return {
        tableMaxHeight: null,
        answerList: [], //设置多卷内容供tableStage表格数据用
        tableData: [],
        loading: false,
        exportLoading: false,
        chartData: {
          indicator: [
            {
              name: '', max: 100,
              axisLabel: {
                show: true,
                showMaxLabel: true,
86201e49   梁保满   即时测模块
72
73
74
75
76
77
78
              },
            },
          ],
          seriesData: []
        },
        chartDia: false,
        chartTitle: "",
e17ec739   梁保满   随堂问,即时测导出爆表修改
79
80
81
82
  
        //导出相关
        diaShow: false,
        exportStudent: []
86201e49   梁保满   即时测模块
83
84
85
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      }
    },
    computed: {
      subjectList: function () {
        return this.subjectName?.split(",")
      }
    },
    created() {
      this.phaseExamReport()
    },
    mounted() {
      this.tableMaxHeight = this.$refs.main.offsetHeight;
    },
    methods: {
      print() {
        tablePrint("print-content", this.title + this.tabList[this.type]);
      },
      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   梁保满   接口联调
136
      //查看雷达图
86201e49   梁保满   即时测模块
137
      openChart(obj) {
7812e986   梁保满   班主任查看报表添加额外信息
138
  
86201e49   梁保满   即时测模块
139
        this.chartTitle = obj.studentName + '-多科-多课时作答表现图'
7812e986   梁保满   班主任查看报表添加额外信息
140
        let max = 0;
5f80d60e   梁保满   备题试卷模版
141
142
        const dataList = obj.dataList.slice(1, obj.dataList.length)
        let subjectList = dataList.map(item => {
7812e986   梁保满   班主任查看报表添加额外信息
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
          let score = Number(item.highestScore || item.score)
          max = score > max ? score : max
          return item.subjectName
        })
        max += 10
        max = max > 150 ? 150 : max
        this.chartData = {
          indicator: [
            {
              name: '', max: max,
              axisLabel: {
                show: true,
                showMaxLabel: true,
              },
            },
          ],
          seriesData: []
        }
86201e49   梁保满   即时测模块
161
162
163
        subjectList.map((item, index) => {
          if (index < 1) {
            this.chartData.indicator[index].name = item
7812e986   梁保满   班主任查看报表添加额外信息
164
            this.chartData.indicator[index].max = max
86201e49   梁保满   即时测模块
165
          } else {
7812e986   梁保满   班主任查看报表添加额外信息
166
            this.chartData.indicator.push({ name: item, max: max })
86201e49   梁保满   即时测模块
167
168
          }
        })
e17ec739   梁保满   随堂问,即时测导出爆表修改
169
        // 为了美观
86201e49   梁保满   即时测模块
170
171
172
173
        if (this.chartData.indicator.length < 3) {
          let num = this.chartData.indicator.length
          for (let i = 0; i < 6; i++) {
            if (i >= num) {
7812e986   梁保满   班主任查看报表添加额外信息
174
              this.chartData.indicator.push({ name: "", max: max })
86201e49   梁保满   即时测模块
175
176
177
178
179
            }
          }
        }
        this.chartData.seriesData = [
          {
5f80d60e   梁保满   备题试卷模版
180
            value: dataList.map(item => item.highestScore),
22095aba   梁保满   接口联调
181
            name: '班级最高分'
86201e49   梁保满   即时测模块
182
183
          },
          {
5f80d60e   梁保满   备题试卷模版
184
            value: dataList.map(item => item.avgScore),
22095aba   梁保满   接口联调
185
186
187
            name: '班平均分'
          },
          {
5f80d60e   梁保满   备题试卷模版
188
            value: dataList.map(item => item.score),
22095aba   梁保满   接口联调
189
            name: '本人得分'
86201e49   梁保满   即时测模块
190
191
192
193
194
195
196
197
198
          },
        ]
        this.chartDia = true
  
  
      },
      async phaseExamReport() {
        this.loading = true;
        const { data, status, info } = await this.$request.cTPhaseExamReport({
7812e986   梁保满   班主任查看报表添加额外信息
199
          classId: this.classId,
86201e49   梁保满   即时测模块
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
          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];
e17ec739   梁保满   随堂问,即时测导出爆表修改
225
          this.exportStudent = [...this.tableData]
86201e49   梁保满   即时测模块
226
227
228
229
230
        } else {
          this.$message.error(info);
        }
      },
      //导出
e17ec739   梁保满   随堂问,即时测导出爆表修改
231
232
233
234
235
236
237
      openDown() {
        this.diaShow = true;
      },
      cancel() {
        this.diaShow = false;
      },
      async exportData(arr) {
86201e49   梁保满   即时测模块
238
239
        if (this.exportLoading == true) return;
        this.exportLoading = true;
e17ec739   梁保满   随堂问,即时测导出爆表修改
240
241
        let studentIds = arr
        let query = {};
384a2a54   梁保满   请求头添加班主任信息,bug修改
242
        if (studentIds.length > 0) {
e17ec739   梁保满   随堂问,即时测导出爆表修改
243
          query.studentIds = studentIds
384a2a54   梁保满   请求头添加班主任信息,bug修改
244
245
        } else {
          query.studentIds = []
e17ec739   梁保满   随堂问,即时测导出爆表修改
246
        }
f9916d4c   梁保满   导出摸板
247
248
249
  
  
        const data = await this.$request.cTExportPhaseExamReport({
049db2b2   梁保满   接口联调
250
251
          classId: this.classId,
          examIds: this.ids,
e17ec739   梁保满   随堂问,即时测导出爆表修改
252
          ...query
86201e49   梁保满   即时测模块
253
254
255
256
257
258
259
260
        });
        this.exportLoading = false;
        if (data) {
          let blob = new Blob([data], {
            type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
          });
          downloadFile(
            this.status
f9916d4c   梁保满   导出摸板
261
262
              ? "即时测-已归档多科汇总报表.xlsx"
              : "即时测-多科汇总报表.xlsx",
86201e49   梁保满   即时测模块
263
264
            blob
          );
f9916d4c   梁保满   导出摸板
265
          this.$message.success("下载成功");
049db2b2   梁保满   接口联调
266
          this.cancel()
86201e49   梁保满   即时测模块
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
        } else {
          this.$message.error("下载失败");
        }
      },
    }
  };
  </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>