Blame view

src/views/portrait/detail.vue 11.5 KB
77ebf04d   梁保满   个人版
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
  <template>
    <div>
      <back-box>
        <template slot="title">
          <span>学生测练表现</span>
        </template>
      </back-box>
      <div class="answer-header">
        <div class="sel-box">
          <el-select
            class="sel"
            multiple
            v-model="query.subjectNames"
            placeholder="选择科目"
            collapse-tags
            @change="changeSub"
          >
            <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   梁保满   软件下载,学校,班级老师等报表导入...
63
64
65
66
        <p class="tips">
          {{ studentName }}(学号:{{ studentCode }}) 测练总次数:{{ count }}
        </p>
        <div class="chart" v-if="tableData.length">
77ebf04d   梁保满   个人版
67
68
69
70
71
72
73
          <template v-if="type == 1">
            <radarChart id="radarChart" :params="radarChartData" />
          </template>
          <template v-else>
            <lineChart id="lineChart" :params="lineChartData" :xAxis="xAxis" />
          </template>
        </div>
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
74
  
77ebf04d   梁保满   个人版
75
76
77
78
79
80
81
82
83
84
85
86
87
        <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   梁保满   软件下载,学校,班级老师等报表导入...
88
              prop="examCount"
77ebf04d   梁保满   个人版
89
90
91
92
              label="参与测练数"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
93
              prop="highestScore"
77ebf04d   梁保满   个人版
94
95
96
97
              label="班最高分"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
98
              prop="avgScore"
77ebf04d   梁保满   个人版
99
100
101
102
              label="班平均分"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
103
              prop="examScore"
77ebf04d   梁保满   个人版
104
105
106
107
108
109
110
111
112
113
114
              label="个人得分"
              align="center"
            ></el-table-column>
          </el-table>
          <el-table
            v-show="type == 2"
            :data="tableData"
            border
            style="width: 100%"
          >
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
115
              prop="title"
77ebf04d   梁保满   个人版
116
117
118
119
              label="课堂测练"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
120
              prop="examScore"
77ebf04d   梁保满   个人版
121
122
123
124
              label="个人成绩"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
125
              prop="avgScore"
77ebf04d   梁保满   个人版
126
127
128
129
              label="平均成绩"
              align="center"
            ></el-table-column>
            <el-table-column
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
130
              prop="classRank"
77ebf04d   梁保满   个人版
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
              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 {
        id: "",
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
149
150
        studentName: "",
        studentCode: "",
77ebf04d   梁保满   个人版
151
152
153
154
155
156
157
158
159
160
161
162
163
        classId: "",
        subjectNames: [],
        type: 1,
        query: {
          //搜索条件
          subjectNames: [],
          startDay: "",
          endDay: "",
          day: "",
        },
        date: "",
        subjectList: [], //科目
        radarChartData: {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
164
165
          indicator: [],
          num: [],
77ebf04d   梁保满   个人版
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
        },
        lineChartData: [
          {
            name: "班平均分",
            value: [95, 85, 90, 86, 92],
          },
          {
            name: "个人成绩",
            value: [90, 80, 95, 82, 95],
          },
          {
            name: "班级排名",
            value: [2, 3, 1, 5, 6],
          },
        ],
        xAxis: ["卷1", "卷2", "卷3", "卷4", "卷5"],
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
182
183
        tableData: [],
        count: 0, //测练数
77ebf04d   梁保满   个人版
184
185
186
187
188
      };
    },
    async created() {
      this.id = this.$route.query.id;
      this.classId = this.$route.query.classId;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
189
190
      this.studentCode = this.$route.query.studentCode;
      this.studentName = this.$route.query.studentName;
77ebf04d   梁保满   个人版
191
      this.subjectNames = this.$route.query.subjectNames?.split(",") || [];
77ebf04d   梁保满   个人版
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
      await this._QuerySubjectList();
      await this.setDate(1);
      let startDay = this.query?.startDay;
      if (!startDay) {
        this.query.startDay = new Date();
        this.query.endDay = new Date();
      }
    },
    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 == "全部";
        });
        this.type =
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
211
212
213
          this.query.subjectNames.length > 1
            ? 1
            : this.query.subjectNames[0] == "全部" && this.subjectList.length != 2
77ebf04d   梁保满   个人版
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
            ? 1
            : 2;
      },
      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() {
03bce046   梁保满   个人版调整
288
        const { data, status, info } = await this.$request.pSubjectList({
77ebf04d   梁保满   个人版
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
          classId: this.classId,
        });
        if (status === 0) {
          this.subjectList =
            data.subjectNames?.map((item) => {
              return {
                value: item,
                label: item,
              };
            }) || [];
          this.subjectList.unshift({
            value: "全部",
            label: "全部",
          });
          if (this.subjectNames.length == 0) {
            this.query.subjectNames.push(this.subjectList[0]?.value);
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
305
306
          } else {
            this.query.subjectNames = [...this.subjectNames];
77ebf04d   梁保满   个人版
307
          }
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
308
309
310
311
312
313
314
          this.type =
            this.query.subjectNames.length > 1
              ? 1
              : this.query.subjectNames[0] == "全部" &&
                this.subjectList.length != 2
              ? 1
              : 2;
77ebf04d   梁保满   个人版
315
316
317
318
319
320
321
322
323
324
325
326
        } 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   梁保满   软件下载,学校,班级老师等报表导入...
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
        delete query.subjectNames;
        let subjectNames;
        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];
        }
        const { data, status, info } = await this.$request.studentExamReport({
          studentId: this.id,
          subjectNames: subjectNames,
77ebf04d   梁保满   个人版
346
347
348
349
          ...query,
        });
        this.loading = false;
        if (status === 0) {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
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
376
377
378
379
380
381
382
          this.count = 0;
          this.tableData = data.list || [];
          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   梁保满   个人版
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
        } 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>