Blame view

src/views/portrait/detail.vue 13 KB
77ebf04d   梁保满   个人版
1
2
3
4
5
6
7
8
9
10
  <template>
    <div>
      <back-box>
        <template slot="title">
          <span>学生测练表现</span>
        </template>
      </back-box>
      <div class="answer-header">
        <div class="sel-box">
          <el-select
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
11
12
13
14
15
16
17
18
19
20
21
22
23
24
            v-if="role == 'ROLE_JIAOSHI'"
            class="sel"
            v-model="query.subjectNames"
            placeholder="选择科目"
          >
            <el-option
              v-for="item in subjectList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-select
3617eaad   梁保满   长水账号设置
25
            v-else
77ebf04d   梁保满   个人版
26
            class="sel"
77ebf04d   梁保满   个人版
27
28
            v-model="query.subjectNames"
            placeholder="选择科目"
3617eaad   梁保满   长水账号设置
29
            multiple
10cf4c8c   梁保满   学生画像接口调整
30
            @change="changeSub"
77ebf04d   梁保满   个人版
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
          >
            <el-option
              v-for="item in subjectList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <div class="d1">
            <el-date-picker
              v-model="query.startDay"
              type="date"
              @change="handleChangeTimeStart"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
            ~
            <el-date-picker
              v-model="query.endDay"
              type="date"
              placeholder="选择日期时间"
              @change="handleChangeTimeEnd"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </div>
          <p class="p1">
            <span @click="setDate(1)" :class="[date == 1 ? 'active' : '', 's1']"
              >今天</span
            >
            <span @click="setDate(2)" :class="[date == 2 ? 'active' : '', 's1']"
              >本周</span
            >
            <span @click="setDate(3)" :class="[date == 3 ? 'active' : '', 's1']"
              >本月</span
            >
            <span @click="setDate(4)" :class="[date == 4 ? 'active' : '', 's1']"
              >本季度</span
            >
          </p>
          <el-button type="primary" round @click="_QueryData()">筛选</el-button>
        </div>
      </div>
      <div class="page-content">
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
77
78
79
80
        <p class="tips">
          {{ studentName }}(学号:{{ studentCode }}) 测练总次数:{{ count }}
        </p>
        <div class="chart" v-if="tableData.length">
77ebf04d   梁保满   个人版
81
82
83
84
85
86
87
          <template v-if="type == 1">
            <radarChart id="radarChart" :params="radarChartData" />
          </template>
          <template v-else>
            <lineChart id="lineChart" :params="lineChartData" :xAxis="xAxis" />
          </template>
        </div>
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
88
  
77ebf04d   梁保满   个人版
89
90
91
92
93
94
95
96
97
98
99
100
101
        <div class="tab-box">
          <el-table
            v-show="type == 1"
            :data="tableData"
            border
            style="width: 100%"
          >
            <el-table-column
              prop="subjectName"
              label="科目"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
102
              prop="examCount"
77ebf04d   梁保满   个人版
103
104
105
106
              label="参与测练数"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
107
              prop="highestScore"
77ebf04d   梁保满   个人版
108
109
110
111
              label="班最高分"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
112
              prop="avgScore"
77ebf04d   梁保满   个人版
113
114
115
116
              label="班平均分"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
117
              prop="examScore"
77ebf04d   梁保满   个人版
118
119
120
121
122
123
124
125
126
127
128
              label="个人得分"
              align="center"
            ></el-table-column>
          </el-table>
          <el-table
            v-show="type == 2"
            :data="tableData"
            border
            style="width: 100%"
          >
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
129
              prop="title"
77ebf04d   梁保满   个人版
130
131
132
133
              label="课堂测练"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
134
              prop="examScore"
77ebf04d   梁保满   个人版
135
136
137
138
              label="个人成绩"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
139
              prop="avgScore"
77ebf04d   梁保满   个人版
140
141
142
143
              label="平均成绩"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
144
              prop="classRank"
77ebf04d   梁保满   个人版
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
              label="班级排名"
              align="center"
            ></el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </template>
  
  <script>
  import { formatDate } from "utils";
  import radarChart from "@/components/charts/radarChart";
  import lineChart from "@/components/charts/lineChart";
  export default {
    components: { radarChart, lineChart },
    data() {
      return {
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
162
        role: "",
77ebf04d   梁保满   个人版
163
        id: "",
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
164
165
        studentName: "",
        studentCode: "",
77ebf04d   梁保满   个人版
166
167
168
169
170
171
172
173
174
175
176
177
178
        classId: "",
        subjectNames: [],
        type: 1,
        query: {
          //搜索条件
          subjectNames: [],
          startDay: "",
          endDay: "",
          day: "",
        },
        date: "",
        subjectList: [], //科目
        radarChartData: {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
179
180
          indicator: [],
          num: [],
77ebf04d   梁保满   个人版
181
        },
10cf4c8c   梁保满   学生画像接口调整
182
183
        lineChartData: [],
        xAxis: [],
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
184
185
        tableData: [],
        count: 0, //测练数
77ebf04d   梁保满   个人版
186
187
188
      };
    },
    async created() {
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
189
190
191
      this.role =
        this.$store.getters.info.showRole ||
        this.$store.getters.info.permissions[0].role;
77ebf04d   梁保满   个人版
192
193
      this.id = this.$route.query.id;
      this.classId = this.$route.query.classId;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
194
195
      this.studentCode = this.$route.query.studentCode;
      this.studentName = this.$route.query.studentName;
c065091a   梁保满   即时测跳转画像参数调整
196
197
198
      this.query.startDay = this.$route.query.startDay || "";
      this.query.endDay = this.$route.query.endDay || "";
      this.date = this.$route.query.date || 1;
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
199
      if (this.role != "ROLE_JIAOSHI") {
10cf4c8c   梁保满   学生画像接口调整
200
201
202
203
        this.subjectNames =
          (this.$route.query.subjectNames &&
            this.$route.query.subjectNames.split(",")) ||
          [];
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
204
205
206
      } else {
        this.subjectNames = this.$route.query.subjectNames;
      }
77ebf04d   梁保满   个人版
207
      await this._QuerySubjectList();
c065091a   梁保满   即时测跳转画像参数调整
208
      
77ebf04d   梁保满   个人版
209
210
      let startDay = this.query?.startDay;
      if (!startDay) {
c065091a   梁保满   即时测跳转画像参数调整
211
        await this.setDate(1);
77ebf04d   梁保满   个人版
212
213
        this.query.startDay = new Date();
        this.query.endDay = new Date();
c065091a   梁保满   即时测跳转画像参数调整
214
215
      }else{
        this._QueryData()
77ebf04d   梁保满   个人版
216
217
218
219
220
221
222
223
224
225
226
227
      }
    },
    methods: {
      changeSub(val) {
        let sub;
        if (val && val.length) {
          let leng = val.length - 1;
          sub = val[leng];
        }
        this.query.subjectNames = val.filter((item) => {
          return sub != "全部" ? item != "全部" : item == "全部";
        });
10cf4c8c   梁保满   学生画像接口调整
228
229
230
231
232
233
        // this.type =
        //   this.query.subjectNames.length > 1
        //     ? 1
        //     : this.query.subjectNames[0] == "全部" && this.subjectList.length > 2
        //     ? 1
        //     : 2;
77ebf04d   梁保满   个人版
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
      },
      setDate(index) {
        const that = this;
        this.date = index == this.date ? "" : index;
        let aYear = new Date().getFullYear();
        let aMonth = new Date().getMonth() + 1;
        that.query.day = "";
        that.query.startDay = "";
        that.query.endDay = "";
        switch (index) {
          case 1:
            that.query.day = formatDate(new Date(), "yyyy-MM-dd");
            that.query.startDay = that.query.day;
            that.query.endDay = that.query.day;
            that.tabIndex = 1;
            break;
          case 2:
            let day = new Date().getDay();
            if (day == 0) {
              //中国式星期天是一周的最后一天
              day = 7;
            }
            day--;
            let aTime = new Date().getTime() - 24 * 60 * 60 * 1000 * day;
            that.query.startDay = formatDate(new Date(aTime), "yyyy-MM-dd");
            that.query.endDay = formatDate(new Date(), "yyyy-MM-dd");
            break;
          case 3:
            aMonth = aMonth < 10 ? "0" + aMonth : aMonth;
            that.query.startDay = `${aYear}-${aMonth}-01`;
            that.query.endDay = formatDate(new Date(), "yyyy-MM-dd");
            break;
          case 4:
            if (aMonth > 0 && aMonth < 4) {
              aMonth = "1";
            } else if (aMonth > 3 && aMonth < 7) {
              aMonth = "4";
            } else if (aMonth > 6 && aMonth < 10) {
              aMonth = "7";
            } else {
              aMonth = "10";
            }
  
            aMonth = aMonth < 10 ? "0" + aMonth : aMonth;
            that.query.startDay = `${aYear}-${aMonth}-01`;
            that.query.endDay = formatDate(new Date(), "yyyy-MM-dd");
            break;
        }
        this.page = 1;
        this._QueryData();
      },
      handleChangeTimeStart(val) {
        this.query.day = "";
        this.date = "";
        if (this.query.endDay) {
          if (new Date(val).getTime() > new Date(this.query.endDay).getTime()) {
            this.$message.error("任务结束时间不能任务开始时间前面,请重新设置");
            this.query.startDay = "";
          }
        }
      },
      handleChangeTimeEnd(val) {
        this.query.day = "";
        this.date = "";
        if (this.query.startDay) {
          if (new Date(val).getTime() < new Date(this.query.startDay).getTime()) {
            this.$message.error("任务结束时间不能任务开始时间前面,请重新设置");
            this.query.endDay = "";
          }
        }
      },
      async _QuerySubjectList() {
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
306
307
308
        let subjectList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pSubjectList
38bdc422   梁保满   学生画像班主任和任课教师接口区分
309
310
            : this.role == "ROLE_BANZHUREN"
            ? this.$request.cTSubjectList
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
311
312
            : this.$request.tSubjectList;
        const { data, status, info } = await subjectList({
77ebf04d   梁保满   个人版
313
314
315
316
317
318
319
320
321
322
          classId: this.classId,
        });
        if (status === 0) {
          this.subjectList =
            data.subjectNames?.map((item) => {
              return {
                value: item,
                label: item,
              };
            }) || [];
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
323
324
325
326
327
328
329
330
331
332
333
334
335
336
          if (this.role != "ROLE_JIAOSHI") {
            this.subjectList.unshift({
              value: "全部",
              label: "全部",
            });
            if (this.subjectNames.length == 0) {
              this.query.subjectNames.push(this.subjectList[0]?.value);
            } else {
              this.query.subjectNames = [...this.subjectNames];
            }
            this.type =
              this.query.subjectNames.length > 1
                ? 1
                : this.query.subjectNames[0] == "全部" &&
3617eaad   梁保满   长水账号设置
337
                  this.subjectList.length > 2
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
338
339
                ? 1
                : 2;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
340
          } else {
3617eaad   梁保满   长水账号设置
341
            this.type = 2;
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
342
343
344
345
346
            if (!this.subjectNames) {
              this.query.subjectNames = this.subjectList[0]?.value;
            } else {
              this.query.subjectNames = this.subjectNames;
            }
77ebf04d   梁保满   个人版
347
          }
77ebf04d   梁保满   个人版
348
349
350
351
352
353
354
355
356
357
358
359
        } else {
          this.$message.error(info);
        }
      },
      async _QueryData() {
        this.loading = true;
        let query = {};
        for (let key in this.query) {
          if (this.query[key] != "") {
            query[key] = this.query[key];
          }
        }
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
360
361
        delete query.subjectNames;
        let subjectNames;
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
        if (this.role != "ROLE_JIAOSHI") {
          if (
            this.query.subjectNames.length == 1 &&
            this.query.subjectNames[0] == "全部"
          ) {
            subjectNames = this.subjectList
              .filter((item) => {
                return item.value != "全部";
              })
              .map((item) => {
                return item.value;
              });
          } else {
            subjectNames = [...this.query.subjectNames];
          }
10cf4c8c   梁保满   学生画像接口调整
377
378
379
380
381
382
          this.type =
            subjectNames.length > 1
              ? 1
              : subjectNames[0] == "全部" && this.subjectList.length > 2
              ? 1
              : 2;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
383
        } else {
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
384
          subjectNames = [this.query.subjectNames];
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
385
        }
10cf4c8c   梁保满   学生画像接口调整
386
  
76eb1bf6   梁保满   授课端版本管理,学生画像接口联调
387
388
389
390
391
        let studentExamReport =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pStudentExamReport
            : this.$request.tStudentExamReport;
        const { data, status, info } = await studentExamReport({
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
392
393
          studentId: this.id,
          subjectNames: subjectNames,
77ebf04d   梁保满   个人版
394
395
396
397
          ...query,
        });
        this.loading = false;
        if (status === 0) {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
398
          this.count = 0;
38bdc422   梁保满   学生画像班主任和任课教师接口区分
399
          this.tableData = data?.list || [];
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
          if (this.type == 1) {
            this.radarChartData.indicator = [];
            this.radarChartData.num = [
              { name: "班最高分", value: [] },
              { name: "班平均分", value: [] },
              { name: "本人得分", value: [] },
            ];
            this.tableData.map((item) => {
              this.count += item.examCount;
              this.radarChartData.indicator.push({
                name: item.subjectName,
              });
              this.radarChartData.num[0].value.push(item.highestScore);
              this.radarChartData.num[1].value.push(item.avgScore);
              this.radarChartData.num[2].value.push(item.examScore);
            });
          } else {
            this.count = data.count;
            this.xAxis = [];
            this.lineChartData = [
              { name: "班平均分", value: [] },
              { name: "个人成绩", value: [] },
              { name: "班级排名", value: [] },
            ];
            this.tableData.map((item) => {
              this.xAxis.push(item.title);
              this.lineChartData[0].value.push(item.avgScore);
              this.lineChartData[1].value.push(item.examScore);
              this.lineChartData[2].value.push(item.classRank);
            });
          }
77ebf04d   梁保满   个人版
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
        } else {
          this.$message.error(info);
        }
      },
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .page-content {
    padding: 0 20px;
  }
  .tips {
    padding-left: 20px;
    font-size: 16px;
    color: #a3a4a8;
    font-weight: 400;
    font-style: normal;
  }
  .chart {
    height: 300px;
  }
  .tab-box {
    padding: 20px;
  }
  </style>