Blame view

src/views/portrait/index.vue 8.85 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
63
64
65
66
67
68
69
70
71
  <template>
    <div>
      <back-box>
        <template slot="title">
          <span>{{ "学生画像" }}</span>
        </template>
      </back-box>
      <div class="answer-header">
        <div class="sel-box">
          <el-select
            class="sel"
            v-model="query.classId"
            placeholder="选择班级"
            @change="changeclass"
          >
            <el-option
              v-for="item in classList"
              :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">
        <ul class="stu-ul">
          <li class="stu-li" v-for="item in tableData" :key="item.studentId">
            <div class="tx">
              <i class="fa fa-mortar-board"></i>
              <p>{{ item.studentCode }}</p>
            </div>
            <div class="info">
              <p class="p1">
                {{ item.studentName }} <i class="fa fa-calculator"></i>
                {{ item.clickerSn }}
              </p>
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
72
73
              <p class="p2">{{ gradeName(item.grade) }}</p>
              <p class="p3">最近活跃:{{ item.modifiedTime }}</p>
77ebf04d   梁保满   个人版
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
            </div>
            <el-button
              class="btn"
              type="primary"
              round
              circle
              icon="el-icon-right"
              @click="linkDetail(item)"
            ></el-button>
          </li>
        </ul>
      </div>
    </div>
  </template>
  
  <script>
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
90
  import { formatDate, setGradeName } from "utils";
77ebf04d   梁保满   个人版
91
92
93
94
  import BusEvent from "@/utils/busEvent";
  export default {
    data() {
      return {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
95
        role: "",
77ebf04d   梁保满   个人版
96
97
98
99
100
101
102
103
104
        query: {
          //搜索条件
          classId: "",
          startDay: "",
          endDay: "",
          day: "",
        },
        date: "",
        classList: [],
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
105
        tableData: [],
77ebf04d   梁保满   个人版
106
107
108
109
110
111
        page: 1,
        size: 20,
        total: 0,
      };
    },
    async created() {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
112
113
114
      this.role =
        this.$store.getters.info.showRole ||
        this.$store.getters.info.permissions[0].role;
77ebf04d   梁保满   个人版
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      await this._QueryClassList();
      await this.setDate(1);
      let startDay = this.query?.startDay;
      if (!startDay) {
        this.query.startDay = new Date();
        this.query.endDay = new Date();
      }
    },
    activated() {
      const that = this;
      BusEvent.$on("keepAlive", async function () {
        await that._QueryClassList();
        await that.setDate(1);
        let startDay = that.query?.startDay;
        if (!startDay) {
          that.query.startDay = new Date();
          that.query.endDay = new Date();
        }
      });
    },
    methods: {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
136
137
138
      gradeName(type) {
        return setGradeName(type);
      },
77ebf04d   梁保满   个人版
139
140
141
142
      linkDetail(obj) {
        this.$router.push({
          path: "/portraitDetail",
          query: {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
143
144
145
146
            studentName: obj.studentName,
            studentCode: obj.studentCode,
            id: obj.id,
            classId: this.query.classId,
77ebf04d   梁保满   个人版
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
          },
        });
      },
      changeclass() {
        this.page = 1;
        this._QueryData();
      },
      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 _QueryClassList() {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
225
226
227
228
229
230
        let fetchClassList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pClassList
            : this.$request.fetchClassList;
  
        const { data, status, info } = await fetchClassList();
77ebf04d   梁保满   个人版
231
232
233
        if (status === 0) {
          this.classList = data.list.map((item) => {
            return {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
234
              value: this.role == "ROLE_PERSONAL" ? item.id : item.classId,
77ebf04d   梁保满   个人版
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
              label: item.className,
            };
          });
          this.query.classId = this.classList[0]?.value;
        } 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   梁保满   软件下载,学校,班级老师等报表导入...
251
252
253
254
255
        let studentList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pStudentList
            : this.$request.tStudentList;
        const { data, status, info } = await studentList({
77ebf04d   梁保满   个人版
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
          ...query,
          page: this.page,
          size: this.size,
        });
        this.loading = false;
        if (status === 0) {
          this.tableData = (data?.list && [...data?.list]) || [];
          this.total = data.count || 0;
        } else {
          this.$message.error(info);
        }
      },
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .page-content {
    padding: 0 20px;
  }
  .stu-ul {
    border-radius: 20px;
    background: #f8f8f8;
    padding: 12px;
    .stu-li {
      border-radius: 12px;
      background: #fff;
      display: flex;
      align-items: center;
      padding: 12px 10px;
      margin-bottom: 16px;
      &:last-of-type {
        margin-bottom: 0;
      }
      .tx {
3617eaad   梁保满   长水账号设置
291
        width: 100px;
77ebf04d   梁保满   个人版
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
        height: 80px;
        background: #667ffd;
        border-radius: 8px;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 16px;
        color: #fff;
        margin-right: 12px;
        .fa-mortar-board {
          font-size: 32px;
        }
      }
      .info {
        flex: 1;
        .p1 {
          font-size: 18px;
          color: #333;
          .fa-calculator {
            font-size: 20px;
            color: #a6a6a6;
            margin: 0 5px 10px 10px;
          }
        }
        .p2 {
          font-size: 16px;
          padding-bottom: 6px;
        }
        .p3 {
          font-size: 16px;
          color: #7f7f7f;
        }
      }
      .btn {
        margin-right: 40px;
        &.is-circle {
          padding: 8px;
        }
        :deep(.el-icon-right) {
          font-size: 22px;
          font-weight: bold;
        }
      }
    }
  }
  </style>