Blame view

src/views/setUp/student.vue 13.9 KB
4c4f7640   梁保满   路由表,路由前端文件
1
  <template>
23a6dc5f   阿宝   学校管理相关接口简单对接
2
3
4
    <div>
      <back-box>
        <template slot="title">
560c12f2   阿宝   学校设置,软件下载
5
          <span>学生管理</span>
23a6dc5f   阿宝   学校管理相关接口简单对接
6
7
8
9
10
11
12
13
14
        </template>
        <template slot="btns">
          <el-tooltip effect="dark" content="添加学生" placement="bottom">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              plain
              circle
dd5150c5   阿宝   数据同步
15
              @click="openAddDia"
23a6dc5f   阿宝   学校管理相关接口简单对接
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
            ></el-button>
          </el-tooltip>
        </template>
      </back-box>
      <div class="page-content">
        <div class="stu-box">
          <div class="stu-list">
            <div class="h-title">
              <el-select
                class="sel"
                v-model="query.gradeName"
                placeholder="选择年级"
                @change="changeGrade"
              >
                <el-option
                  v-for="item in gradeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
            <ul class="stu-ul">
              <li
                class="stu-item"
                v-for="item in classList"
                :key="item.classCode"
560c12f2   阿宝   学校设置,软件下载
44
                :class="query.classId == item.id ? 'active' : ''"
dd5150c5   阿宝   数据同步
45
                @click="classDetail(item)"
23a6dc5f   阿宝   学校管理相关接口简单对接
46
              >
0a4de034   阿宝   教师管理,学生管理班级设置
47
                <i class="el-icon-edit-outline" @click.stop="setClass(item)"></i>
23a6dc5f   阿宝   学校管理相关接口简单对接
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
                {{ item.className }}({{ item.studentCount }})
              </li>
            </ul>
          </div>
          <div class="stu-detail">
            <div class="answer-header">
              <div class="sel-box">
                <el-input
                  placeholder="请输入学生姓名"
                  v-model="query.studentName"
                  class="input-with-select"
                  @keyup.enter.native="_QueryData(1)"
                >
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    @click="_QueryData(1)"
                  ></el-button>
                </el-input>
                <el-input
                  placeholder="请输入学生学号"
                  v-model="query.studentCode"
                  class="input-with-select"
                  @keyup.enter.native="_QueryData(2)"
                >
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    @click="_QueryData(2)"
                  ></el-button>
                </el-input>
              </div>
            </div>
            <ul class="s-ul" v-loading="loading">
0a4de034   阿宝   教师管理,学生管理班级设置
82
83
84
85
86
              <li
                class="s-li"
                v-for="(item, index) in studentList"
                :key="item.id"
              >
bb4c8454   阿宝   添加,修改教师
87
                <el-popconfirm
0a4de034   阿宝   教师管理,学生管理班级设置
88
89
90
91
                  title="确定删除吗?"
                  @confirm="removeStu(item, index)"
                >
                  <i class="el-icon-delete" slot="reference"></i>
bb4c8454   阿宝   添加,修改教师
92
                </el-popconfirm>
23a6dc5f   阿宝   学校管理相关接口简单对接
93
94
                <p class="name">{{ item.studentName }}</p>
                <p class="p1">
dd5150c5   阿宝   数据同步
95
96
97
98
                  答题器:{{
                    (item.clickerList.length && item.clickerList[0].clickerSn) ||
                    "--"
                  }}
23a6dc5f   阿宝   学校管理相关接口简单对接
99
100
101
102
103
104
105
106
107
108
109
110
111
                </p>
                <p class="p1">长学号:{{ item.studentCode }}</p>
                <p class="p1">短学号:{{ item.shortNumber || "--" }}</p>
              </li>
            </ul>
            <el-empty
              :image-size="100"
              v-if="!studentList.length && loading == false"
              description="没有更多数据"
            ></el-empty>
          </div>
        </div>
      </div>
dd5150c5   阿宝   数据同步
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
      <el-dialog title="添加学生" :visible.sync="diaStu" width="400">
        <el-form
          class="form-box"
          :model="formStu"
          :rules="rulesStu"
          label-width="160px"
        >
          <el-form-item label="所在班级:">
            <span>{{ formStu.className }}</span>
          </el-form-item>
          <el-form-item label="学生姓名:" prop="studentName">
            <el-col :span="10">
              <el-input maxlength="30" v-model.trim="formStu.studentName" />
            </el-col>
          </el-form-item>
          <el-form-item label="长学号:" prop="studentCode">
            <el-col :span="10">
              <el-input maxlength="30" v-model.trim="formStu.studentCode" />
            </el-col>
          </el-form-item>
          <el-form-item label="短学号:">
            <el-col :span="10">
              <el-input maxlength="30" v-model.trim="formStu.shortNumber" />
            </el-col>
          </el-form-item>
          <el-form-item label="性别:">
            <el-radio-group v-model="formStu.sex">
              <el-radio :label="1">男</el-radio>
              <el-radio :label="2">女</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="答题器编码:">
            <el-col :span="10">
              <el-input maxlength="30" v-model.trim="formStu.clickerSn" />
            </el-col>
          </el-form-item>
        </el-form>
23a6dc5f   阿宝   学校管理相关接口简单对接
149
        <div class="dialog-footer" slot="footer">
dd5150c5   阿宝   数据同步
150
151
          <el-button @click="addStu">确 定</el-button>
          <el-button @click="diaStu = false">取 消</el-button>
23a6dc5f   阿宝   学校管理相关接口简单对接
152
153
        </div>
      </el-dialog>
0a4de034   阿宝   教师管理,学生管理班级设置
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
      <el-dialog title="修改班级" :visible.sync="diaClass" width="400">
        <el-form
          class="form-box"
          ref="formClass"
          :model="formClass"
          :rules="rulesClass"
          label-width="160px"
        >
          <el-form-item label="所在年级:">
            <span>{{ formClass.gradeName }}</span>
          </el-form-item>
          <el-form-item label="班级名称:" prop="studentName">
            <el-col :span="10">
              <el-input maxlength="30" v-model.trim="formClass.className" />
            </el-col>
          </el-form-item>
          <el-form-item label="入学年份:" prop="studentCode">
            <el-col :span="10">
              <el-date-picker
                v-model="formClass.intoSchoolYear"
                type="year"
a37317f4   阿宝   使用分析,发卡记录
175
                value-format="yyyy"
0a4de034   阿宝   教师管理,学生管理班级设置
176
177
178
179
180
181
182
183
184
185
186
                placeholder="选择年"
              >
              </el-date-picker>
            </el-col>
          </el-form-item>
        </el-form>
        <div class="dialog-footer" slot="footer">
          <el-button @click="saveClass">确 定</el-button>
          <el-button @click="diaClass = false">取 消</el-button>
        </div>
      </el-dialog>
23a6dc5f   阿宝   学校管理相关接口简单对接
187
    </div>
4c4f7640   梁保满   路由表,路由前端文件
188
189
190
  </template>
  
  <script>
23a6dc5f   阿宝   学校管理相关接口简单对接
191
  import { downloadFile } from "@/utils";
4c4f7640   梁保满   路由表,路由前端文件
192
  export default {
23a6dc5f   阿宝   学校管理相关接口简单对接
193
194
195
    data() {
      return {
        url: "",
dd5150c5   阿宝   数据同步
196
        diaStu: false,
0a4de034   阿宝   教师管理,学生管理班级设置
197
        diaClass: false,
23a6dc5f   阿宝   学校管理相关接口简单对接
198
199
200
201
202
203
        query: {
          gradeName: "",
          classId: "",
          studentCode: "",
          studentName: "",
        },
dd5150c5   阿宝   数据同步
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
        formStu: {
          className: "",
          studentName: "",
          studentCode: "",
          shortNumber: "",
          sex: 1,
          clickerSn: "",
        },
        rulesStu: {
          studentName: [
            { required: true, message: "请输入学生名称", trigger: "blur" },
          ],
          studentCode: [
            { required: true, message: "请输入学生长学号", trigger: "blur" },
          ],
        },
0a4de034   阿宝   教师管理,学生管理班级设置
220
221
222
223
224
225
226
227
228
229
        formClass: {
          gradeName: "",
          className: "",
          intoSchoolYear: "",
        },
        rulesClass: {
          className: [
            { required: true, message: "请输入班级名称", trigger: "blur" },
          ],
        },
23a6dc5f   阿宝   学校管理相关接口简单对接
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
        gradeName: "",
        gradeList: [],
        classList: [],
        studentList: [],
        teacherDetail: {
          teacherName: "",
          loginName: "",
          sex: "",
          available: "",
          managerList: [],
          teacherCourseList: [],
          teacherGradeList: [],
        },
      };
    },
    async created() {
      await this._QueryDataGrade();
560c12f2   阿宝   学校设置,软件下载
247
      await this._QueryClass();
23a6dc5f   阿宝   学校管理相关接口简单对接
248
249
250
      this._QueryData(3);
    },
    methods: {
dd5150c5   阿宝   数据同步
251
252
253
254
255
256
257
258
259
260
261
      openAddDia() {
        this.formStu.studentName = "";
        this.formStu.studentCode = "";
        this.formStu.shortNumber = "";
        this.formStu.sex = 1;
        this.formStu.clickerSn = "";
        this.diaStu = true;
      },
      classDetail(obj) {
        this.query.classId = obj.id;
        this.formStu.className = obj.className;
23a6dc5f   阿宝   学校管理相关接口简单对接
262
263
        this._QueryData(3);
      },
0a4de034   阿宝   教师管理,学生管理班级设置
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
      setClass(obj) {
        this.formClass.gradeName = obj.gradeName;
        this.formClass.classId = obj.id;
        this.formClass.className = obj.className;
        this.formClass.intoSchoolYear = obj.intoSchoolYear + "";
        this.diaClass = true;
      },
      saveClass() {
        this.$refs.formClass.validate(async (valid) => {
          if (valid) {
            const { data, status, info } = await this.$request.updateClass({
              classId: this.formClass.classId,
              className: this.formClass.className,
              intoSchoolYear: this.formClass.intoSchoolYear,
            });
            if (status === 0) {
              this.$message.success("修改成功");
              this.diaClass = false;
              this._QueryClass();
            } else {
              this.$message.error(info);
            }
          } else {
            console.log("输入有误请检查!");
            return false;
          }
        });
      },
      async removeStu(obj, index) {
        const { data, status, info } = await this.$request.delStudent({
dd5150c5   阿宝   数据同步
294
295
296
297
          studentId: obj.id,
        });
        if (status === 0) {
          this.$message.success("删除成功");
0a4de034   阿宝   教师管理,学生管理班级设置
298
          this.studentList.splice(index, 1);
dd5150c5   阿宝   数据同步
299
300
301
302
303
304
305
        } else {
          this.$message.error(info);
        }
      },
      async changeGrade(val) {
        this.query.classId = "";
        await this._QueryClass(val);
23a6dc5f   阿宝   学校管理相关接口简单对接
306
307
        this._QueryData(3);
      },
dd5150c5   阿宝   数据同步
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
      async addStu() {
        let query = {};
        for (let key in this.formStu) {
          if (key != "className" && this.formStu[key]) {
            query[key] = this.formStu[key];
          }
        }
        this.loading = true;
        const { data, status, info } = await this.$request.addStudent({
          classId: this.query.classId,
          ...query,
        });
        this.loading = false;
        console.log(status);
        if (status === 0) {
          this.$message.success(info);
          this.diaStu = false;
          this._QueryData();
        } else {
          this.$message.error(info);
        }
      },
23a6dc5f   阿宝   学校管理相关接口简单对接
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
376
377
      async _QueryData(type) {
        let query = {};
        query.gradeName = this.query.gradeName;
        query.classId = this.query.classId;
        if (type == 1) {
          query.studentName = this.query.studentName;
          this.query.studentCode = "";
        } else if (type == 2) {
          query.studentCode = this.query.studentCode;
          this.query.studentName = "";
        } else if (type == 3) {
          this.query.studentName = "";
          this.query.studentCode = "";
        }
        this.loading = true;
        const { data, status, info } = await this.$request.studentList({
          ...query,
        });
        this.loading = false;
        console.log(status);
        if (status === 0) {
          this.studentList = data.list || [];
        } else {
          this.$message.error(info);
        }
      },
      async _QueryDataGrade() {
        this.loading = true;
        const { data, status, info } = await this.$request.gradeList();
        if (status === 0) {
          this.gradeList =
            data.list?.map((item) => {
              return {
                value: item.gradeName,
                label: item.gradeName,
              };
            }) || [];
          this.query.gradeName = this.gradeList[0]?.value;
        } else {
          this.$message.error(info);
        }
      },
      async _QueryClass(value) {
        const { data, status, info } = await this.$request.schoolClassList({
          gradeName: value || this.query.gradeName,
        });
        if (status === 0) {
          this.classList = [...data.list] || [];
560c12f2   阿宝   学校设置,软件下载
378
          this.query.classId = this.classList[0]?.id;
dd5150c5   阿宝   数据同步
379
          this.formStu.className = this.classList[0]?.className;
23a6dc5f   阿宝   学校管理相关接口简单对接
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
        } else {
          this.$message.error(info);
        }
      },
      async downExcel() {
        let data = await this.$request.downDevice({
          id: this.id,
        });
        if (data && !data.code) {
          let blob = new Blob([data], {
            type: "application/vnd.ms-excel;charset=utf-8",
          });
          downloadFile(`设备信息.xlsx`, blob);
        } else {
          this.$message.error(data.message);
        }
      },
    },
  };
4c4f7640   梁保满   路由表,路由前端文件
399
400
  </script>
  
23a6dc5f   阿宝   学校管理相关接口简单对接
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
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
  <style lang="scss" scoped>
  .page-content {
    padding: 20px;
  }
  .stu-box {
    display: flex;
    background: #f8f8f8;
    border-radius: 10px;
    overflow: hidden;
    .stu-list {
      max-height: 80vh;
      .h-title {
        height: 40px;
        overflow-y: scroll;
        line-height: 40px;
        background: #eee;
      }
      .stu-item {
        font-size: 16px;
        color: #7f7f7f;
        line-height: 36px;
        cursor: pointer;
        padding-left: 12px;
        position: relative;
        .el-icon-edit-outline {
          position: absolute;
          top: 8px;
          right: 12px;
          font-size: 20px;
          display: none;
          &:hover {
            color: #667ffd;
          }
        }
        &:hover {
          background: #eee;
          .el-icon-edit-outline {
            display: block;
          }
        }
        &.active {
          color: #667ffd;
        }
      }
      .sel {
        width: 180px;
        :deep(.el-input__inner) {
          font-size: 16px;
          padding-left: 0;
          border: none;
          background: transparent;
        }
        :deep(.el-icon-arrow-up:before) {
          content: "\e78f";
        }
      }
    }
    .stu-detail {
      flex: 1;
      border-left: 0.5px solid #eee;
      .s-ul {
        display: flex;
        flex-wrap: wrap;
        padding-left: 20px;
        .s-li {
          width: 180px;
          height: 120px;
          box-shadow: 2px 2px 5px #7f7f7f;
          border-radius: 10px;
          margin: 0 20px 20px 0;
          padding: 0 12px 5px;
          position: relative;
          .el-icon-delete {
            position: absolute;
            top: 8px;
            right: 8px;
            font-size: 18px;
            padding: 2px;
            display: none;
            cursor: pointer;
            &:hover {
              color: #667ffd;
            }
          }
          &:hover {
            .el-icon-delete {
              display: block;
            }
          }
          .name {
            text-align: center;
            font-size: 16px;
            line-height: 18px;
            padding: 10px 0;
          }
          .p1 {
            color: #7f7f7f;
            line-height: 20px;
            padding-bottom: 5px;
          }
        }
      }
    }
  }
4c4f7640   梁保满   路由表,路由前端文件
505
  </style>