analysis.vue
10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
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
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
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
229
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
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
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<template>
<div>
<back-box>
<template slot="title">
<span>{{
types == 1 ? "单课分析" :
types == 2 ? `${className}-${subjectNames[0]}汇总分析` :
`${className}-多科汇总分析` }}</span>
</template>
</back-box>
<div class="page-content">
<div class="tab-box">
<span class="tab-item" v-for="(item, index) in tabList" :key="index" :class="type == item.value ? 'active' : ''"
@click="setType(item.value)">{{ item.name }}</span>
</div>
<div v-loading="loading">
<div id="print-content">
<!-- 学生答题情况 -->
<Detail v-if="type == 1" :types="types" :detail="detail" :id="id" />
<!-- 学生答题情况 -->
<Example v-if="type == 1" :types="types" :tableData="tableData" />
<!-- 学生问答 -->
<AnswerQustion v-if="type == 2" :types="types" :tableData="tableData" :subjectNames="subjectNames" />
<!-- 学生互动表现 -->
<Interact v-if="type == 3" :types="types" :tableData="tableData" />
<!-- 签到明细 -->
<Report v-if="type == 4" :tableData="tableData" />
</div>
<div class="pagination-box" v-show="type == 1">
<el-pagination small="" layout="total,prev, pager, next" :hide-on-single-page="true" :total="total"
@current-change="changePage" :current-page="page" :page-size="size">
</el-pagination>
</div>
<p class="down">
<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>
</p>
</div>
<ExportDia :exportStudent="exportStudent" :diaShow="diaShow" @cancel="cancel" @exportData="exportData" :type="types==3?'雷达图':'折线图'"/>
</div>
</div>
</template>
<script>
import { downloadFile, tablePrint } from "@/utils";
import Detail from "./components/detail.vue"
import Example from "./components/example.vue"
import AnswerQustion from "./components/answerQustion.vue"
import Interact from "./components/interact.vue"
import Report from "./components/report.vue"
export default {
components: {
Detail, Example, AnswerQustion, Interact, Report
},
data() {
return {
role: "",
loading: false,
classId: "",
className: "",
subjectNames: "",
id: [],
type: 1,
tabList: [],
detail: {},
tableData: [],
page: 1,
size: 20,
total: 0,
status: 0,
//导出相关
diaShow: false,
exportStudent: [],
};
},
created() {
this.role =
this.$store.getters.info.showRole ||
this.$store.getters.info.permissions[0].role;
this.types = Number(this.$route.query.types)
this.className = this.$route.query.className
const queryData = JSON.parse(this.$route.query.params)
this.classId = queryData.classId
console.log(this.$route.query)
this.subjectNames = this.$route.query.subjectNames.split(',')
if (this.types == 1) {
this.tabList = [{ name: "答题表现", value: 1 },
{ name: "学生问答表现", value: 2 },
{ name: "学生互动表现", value: 3 },
{ name: "签到明细", value: 4 },]
} else if (this.types == 2) {
this.tabList = [{ name: "答题表现", value: 1 },
{ name: "学生问答表现", value: 2 },
{ name: "学生互动表现", value: 3 }]
} else if (this.types == 3) {
this.tabList = [
{ name: "学生问答表现", value: 2 },
{ name: "学生互动表现", value: 3 }]
}
this.type = this.tabList[0].value
this.id = JSON.parse(this.$route.query.id)
this.status = this.$route.query.status ? this.$route.query.status : 0;
this._QueryData();
this.types != 1 ?this._QueryDataQuestionRank():'';
this.types != 3 ? this.periodDetail() : '';
},
methods: {
print() {
tablePrint(
"print-content",
this.detail.title + "_" + this.tabList[this.type - 1]
);
},
setType(type) {
this.type = type;
this.page = 1;
this._QueryData();
},
setDuration(times) {
let m = parseInt(times / 1000 / 60);
let s = parseInt((times / 1000) % 60);
let ms = times;
let aTime;
if (times == 0) {
aTime = `0`;
} else {
if (m == 0 && s == 0) {
aTime = `${ms}毫秒`;
} else if (m == 0 && s != 0) {
aTime = `${s}秒`;
} else if (m != 0 && s != 0) {
aTime = `${m}分${s}秒`;
}
}
return aTime;
},
changePage(page) {
this.page = page;
this._QueryData();
},
async periodDetail() {
const periodDetail = this.role == "ROLE_PERSONAL" ?
this.$request.pPeriodDetail :
this.$request.periodDetail;
let { data, info, status } = await periodDetail({
periodIds: this.id,
});
if (status == 0) {
this.detail = { ...data };
this.detail.duration = this.detail.duration
? (this.detail.duration / 60).toFixed(2)
: 0;
this.detail.consumingDuration = this.detail.consumingDuration
? (this.detail.consumingDuration / 60).toFixed(2)
: 0;
} else {
this.$message.error(info);
}
},
async _QueryData() {
let queryData;
let query = {};
if (this.role == "ROLE_PERSONAL") {
if (this.types == 1) {
query.page = this.page
query.size = this.size
queryData = this.type == 1
? this.$request.pPeriodQuestionReport
: this.$request.pPeriodStudentReport;
}
else if (this.types == 2) {
queryData = this.type == 1
? this.$request.pPeriodQuestionReport
: this.type == 2 ? this.$request.phaseAnswerReport : this.$request.phaseInteractiveReport;
} else if (this.types == 3) {
queryData = this.type == 2 ? this.$request.pPhaseAnswerReport : this.$request.pPhaseInteractiveReport;
}
} else {
if (this.types == 1) {
query.page = this.page
query.size = this.size
queryData = this.type == 1
? this.$request.periodQuestionReport
: this.$request.periodStudentReport;
} else if (this.types == 2) {
queryData = this.type == 1
? this.$request.periodQuestionReport
: this.type == 2 ? this.$request.phaseAnswerReport : this.$request.phaseInteractiveReport;
} else if (this.types == 3) {
queryData = this.type == 2 ? this.$request.cTPhaseAnswerReport : this.$request.cTPhaseInteractiveReport;
}
}
if (this.types == 1) {
query.periodId = this.id[0]
query.type = this.type - 1
} else {
query.periodIds = this.id
if (this.types == 3) {
query.subjectNames = this.subjectNames
}
}
this.loading = true;
let { data, info, status } = await queryData({
classId: this.classId,
...query,
});
this.loading = false;
if (status === 0) {
this.tableData = data?.list || []
this.total = data.count;
} else {
this.$message.error(info);
}
},
async _QueryDataQuestionRank() {
let queryData;
let query = {};
query.periodIds = this.id
if (this.types == 2) {
queryData = this.$request.phaseAnswerReport
} else if (this.types == 3) {
queryData = this.$request.cTPhaseAnswerReport
}
if (this.types != 1) {
query.classId = this.classId
}
this.loading = true;
let { data, info, status } = await queryData({
onlyRate: true,
...query,
});
this.loading = false;
console.log(data)
if (status === 0) {
this.exportStudent = data?.list && [...data?.list] || []
} else {
this.$message.error(info);
}
},
//导出
openDown() {
this.diaShow = true;
},
cancel() {
this.diaShow = false;
},
async exportData(arr) {
if (this.exportLoading == true) return;
this.exportLoading = true;
let studentIds = arr
let query = {};
if(studentIds != null){
if (studentIds.length > 0) {
query.studentIds = studentIds
} else {
query.studentIds = []
}
}
let exportPeriodReport = ""
if (this.types == 1) {
query.periodId = this.id[0]
exportPeriodReport = this.role == "ROLE_PERSONAL" ? this.$request.pExportPeriodReport : this.$request.exportPeriodReport
} else if(this.types == 2){
query.periodIds = this.id
exportPeriodReport = this.role == "ROLE_PERSONAL" ?this.$request.pExportPhaseAnswerReport:this.$request.exportPhaseAnswerReport
}else{
query.periodIds = this.id
exportPeriodReport = this.$request.cTExportPhaseAnswerReport
}
const data = await exportPeriodReport({
classId: this.classId,
...query
});
this.exportLoading = false;
if (data) {
this.cancel()
let blob = new Blob([data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
let name = this.types == 1 ? "随堂问-单课时报表.xlsx" :
this.types == 2 ? `随堂问-${this.className}-${this.subjectNames[0]}汇总分析报表.xlsx` :
`随堂问-${this.className}-多科汇总分析报表.xlsx`
downloadFile(this.status ? "随堂问-已归档单课时报表.xlsx" : name, blob);
} else {
this.$message.error("下载失败");
}
},
},
};
</script>
<style>
div::-webkit-scrollbar {
width: 3px;
height: 10px;
}
div::-webkit-scrollbar-thumb {
border-radius: 10px;
background-color: #ccc;
}
</style>
<style lang="scss" scoped>
.down {
padding-top: 20px;
width: 100%;
display: flex;
justify-content: space-between;
}
.red {
color: #f30;
}
.page-content {
padding: 20px 20px 0;
}
.tab-box {
width: 800px;
margin: 0 auto 12px;
background: #f8f8f8;
border-radius: 20px;
display: flex;
.tab-item {
flex: 1;
height: 40px;
line-height: 40px;
text-align: center;
font-size: 16px;
color: #666;
font-weight: 500;
background: transparent;
border-radius: 20px;
cursor: pointer;
&.active {
background: #667ffd;
color: #fff;
}
}
}
:deep(.el-dialog__body) {
padding-top: 0;
}
.el-dialog {
.down-item {
font-size: 15px;
margin-bottom: 10px;
.tit {
line-height: 18px;
padding: 10px 0;
}
}
.export-tit {
text-align: center;
font-size: 16px;
padding-bottom: 10px;
}
}
.dialog-footer {
text-align: center;
}
</style>