archived.vue
13.2 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
376
377
378
379
380
381
382
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
409
410
411
412
413
414
415
416
417
418
<template>
<div>
<back-box>
<template slot="title">
<span>分班</span>
</template>
</back-box>
<div class="page-content">
<el-steps :active="step" align-center class="step">
<el-step title="1 解散班级"></el-step>
<el-step title="2 导入班级名单"></el-step>
<el-step title="3 分班后任课老师"></el-step>
</el-steps>
<ul v-loading="loading">
<li v-show="step == 0" style="padding:0px 200px;">
<el-row class="row-subfix" style="margin-top: 20px;">
<el-row class="row-subfix">
<div class="row-line">
<span class="line-subfix">选择年级:</span>
<span class="line-value">
<el-select class="sel" v-model="grade" placeholder="选择年级" @change="changeGrade">
<el-option v-for="item in gradeList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</span>
</div>
</el-row>
<el-row class="row-subfix" style="margin-top: 20px;">
<span class="line-subfix" style="float: left;">选择班级:</span>
<div class="row-line"
style="float: left; background:rgb(245,247,250);padding:15px;width: calc(100% - 220px); border-radius:5px;">
<span class="line-value" style="min-height: 300px;border-radius: 4px; background: rgb(247,247,250);">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
@change="handleCheckAllChange">全选</el-checkbox>
<el-checkbox-group v-model="checkedClass" style="margin-top: 15px;">
<el-checkbox v-for="(item, index) in classList" :label="item.id" :key="item.id">
{{ item.className }}
</el-checkbox>
</el-checkbox-group>
</span>
</div>
</el-row>
</el-row>
<el-row class="row-subfix form-item" style="margin-top: 20px;">
<span class="line-subfix" style="float: left;"> <i class="el-icon-warning" /></span>
<div class="row-line" style="float: left; width: calc(100% - 220px); border-radius:5px;">
<div>请谨慎操作,班级归档后,学生解除班级关系且相关老师任课信息将不存在。</div>
<div style="margin-top: 10px;opacity: 0.7;">如需保存解散前的班级名单与任课信息,可点击“保存名单”按钮。</div>
</div>
</el-row>
<div style="margin:0px auto;width: 30%;">
<el-button style="background: rgb(218,225,235) ;color:black;border:none !important;"
@click="toClazz">取消</el-button>
<el-button type="primary" @click="_downNameList">保存名单</el-button>
<el-popconfirm confirm-button-text="确定" cancel-button-text="取消" title="确定要将所选班级解散吗吗?"
@confirm="_ClassArchiving">
<el-button slot="reference" v-loading="loadingDown"
style="background: rgb(242,168,65) ;color:white;margin-left: 10px;border:none !important;">确定解散</el-button>
</el-popconfirm>
</div>
</li>
<li v-show="step == 1">
<el-row class="row-subfix form-item">
<div class="row-line" style="float: left;">
<div>通过导入EXCEL文件方式添加班级名单,请按需求下载对应班级类型板并填写班级名单信息后,导入系统:</div>
<div style="margin-top: 10px;opacity: 0.7;margin-left:20px;">
行政班定义:由固定学生、固定教室构成,由专门的班主任进行管理;
</div>
<div style="margin-top: 5px;opacity: 0.7;margin-left:20px;">
教学班定义:由不同行政班的学生临时组成,没有专门的班主任,是在选课制基础上,由于教学的需要而产生的。
</div>
</div>
</el-row>
<el-row class="row-subfix form-item" style="margin-top: 20px;">
<el-button :icon="'el-icon-document'" @click="_downTemplate(0)">下载行政班名单模板</el-button>
<el-button :icon="'el-icon-document'" @click="_downTemplate(1)">下载教学班名单模板</el-button>
</el-row>
<el-row class="row-subfix form-item" style="margin-top: 20px;">
<upload id="downTeacher" drag :url="urlClazz"
style="border:rgb(219,226,235) dashed 1px;width: 100%;padding:40px 0px;border-radius: 5px;"
@upSuccess="upStudentSuccess" fileName="学生名单模板">
<p class="down-txt" slot="down">
通过Excel名单导入学生名单模板
</p>
</upload>
</el-row>
</li>
<li v-show="step == 2">
<el-row class="row-subfix form-item">
<div class="row-line" style="float: left;">
<div>通过导入EXCEL文件方式添加教师任课信息,请按需求下载板并填写任课信息后,导入系统:</div>
</div>
</el-row>
<el-row class="row-subfix form-item" style="margin-top: 20px;">
<el-button :icon="'el-icon-document'" @click="_downTemplate(2)">下载任课信息模板</el-button>
</el-row>
<el-row class="row-subfix form-item" style="margin-top: 20px;">
<upload id="downTeacher" drag :url="urlTeacher"
style="border:rgb(219,226,235) dashed 1px;width: 100%;padding:40px 0px;border-radius: 5px;"
@upSuccess="upTeacherSuccess" fileName="任课老师名单模板">
<p class="down-txt" slot="down">
通过Excel名单导入任课老师名单模板
</p>
</upload>
</el-row>
</li>
<li v-show="step != 0">
<div class="btn-box">
<el-button class="btn" round @click="step -= 1">上一步</el-button>
<el-button v-show="step != 2" class="btn" type="primary" round @click="step += 1">下一步</el-button><el-button
v-show="step == 2" class="btn" type="primary" round @click="toClazz">完成</el-button>
</div>
</li>
</ul>
</div>
</div>
</template>
<script>
import { downloadFile } from "utils";
export default {
data() {
return {
loading: false,
loadingClass: false,
loadingDown: false,
step: 0,
grade: "",
gradeList: [],
checkAll: false,
checkedClass: [],
classList: [],
urlClazz: "/api_html/school/manager/importClassAndStudent",
urlTeacher: "/api_html/school/manager/importTeacher",
isIndeterminate: true
};
},
watch: {
checkedClass(value) {
this.checkAll = value.length == this.classList.length;
this.isIndeterminate = value.length > 0 && value.length < this.classList.length;
}
},
created() {
this._QueryDataGrade();
},
methods: {
async _downNameList() {
this.loadingDown = true;
await this.downStudentExcel();
await this.downTeacherExcel();
this.loadingDown = false;
},
handleCheckAllChange(val) {
if (val) this.checkedClass = this.classList.map(item => item.id);
else this.checkedClass = [];
},
async _downTemplate(type) {
var template = type == 0 ? this.$request.classAndStudentTemplate : this.$request.tClassAndStudentTemplate;
if (type == 2) template = await this.$request.teacherTemplate;
console.log(type)
let data = await template();
if (data && !data.code) {
let blob = new Blob([data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
downloadFile(type == 2 ? "教师任课信息" : type == 0 ? "行政班名单模板" : "教学班名单模板", blob);
}
else {
this.$message.error(data.info);
}
// const classAndStudentTemplate =
// type == 0
// ? this.$request.classAndStudentTemplate ? type == 2 :
// await this.$request.teacherTemplate()
// : this.$request.tClassAndStudentTemplate;
// let data = await classAndStudentTemplate();
// if (data && !data.code) {
// let blob = new Blob([data], {
// type: "application/vnd.ms-excel;charset=utf-8",
// });
// downloadFile(type == 0 ? type == 2 ? "教师任课信息模板" : "行政班名单模板" : "教学班名单模板", blob);
// } else {
// this.$message.error(data.info);
// }
},
toClazz() {
this.$router.push({
path: "/setUpClazz",
});
},
//切换年级
changeGrade() {
this._QueryClass();
},
//学生名单上传成功回调
upStudentSuccess(res) {
this.$message.closeAll();
this.$message({
showClose: true,
message: `成功(${res.data.success})`,
type: "success",
duration: 10000,
});
},
//任课老师名单上传成功回调
upTeacherSuccess(res) {
this.$message.closeAll();
this.$message({
showClose: true,
message: `成功(${res.data.success})`,
type: "success",
duration: 10000,
});
},
//导出学生名单
async downStudentExcel() {
const exportClassAndStudent = this.$request.exportClassAndStudent;
let data = await exportClassAndStudent();
if (data) {
let blob = new Blob([data], {
type: "application/vnd.ms-excel;charset=utf-8",
});
downloadFile(`班级名单.xlsx`, blob);
} else {
this.$message.error("下载失败");
}
},
//导出任课老师名单
async downTeacherExcel() {
let data = await this.$request.exportTeacher();
if (data) {
let blob = new Blob([data], {
type: "application/vnd.ms-excel;charset=utf-8",
});
downloadFile(`教师名单.xlsx`, blob);
} else {
this.$message.error("下载失败");
}
// let data = await this.$request.exportNoClassTeacher();
// if (data) {
// let blob = new Blob([data], {
// type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
// });
// downloadFile("未分配教师 名单.xlsx", blob);
// } else {
// this.$message.error("下载失败");
// }
},
//班级归档
async _ClassArchiving() {
if (!this.checkedClass.length) {
this.$message.warning("班级不能为空,请选择班级~");
return;
}
this.loading = true;
const { status, info } = await this.$request.classArchiving({
classIds: [...this.checkedClass],
});
this.loading = false;
if (status === 0) {
this.$message.success("班级归档成功!");
this.step = 1;
this._QueryDataGrade();
} else {
this.$message.error(info);
}
},
//年级列表
async _QueryDataGrade() {
const { data, status, info } = await this.$request.gradeList();
if (status === 0) {
this.gradeList =
data.list?.map((item) => {
return {
value: item.grade,
label: item.gradeName,
};
}) || [];
this.grade = this.gradeList[0]?.value;
this._QueryClass();
} else {
this.$message.error(info);
}
},
//班级列表
async _QueryClass() {
this.classList = [];
this.loadingClass = true;
const { data, status, info } = await this.$request.schoolClassList({
grade: this.grade,
type: 0
});
this.loadingClass = false;
if (status === 0) {
this.classList = (data.list && [...data.list]) || [];
this.checkedClass = this.classList.map(item => item.id);
} else {
this.$message.error(info);
}
},
},
};
</script>
<style lang="scss" scoped>
.page-content {
width: 100%;
padding: 20px;
box-sizing: border-box;
}
.step {
margin-bottom: 40px;
}
.form-item {
width: 70%;
display: flex;
margin: 0 auto 20px;
.check-box {
flex: 1;
}
.all-check {
margin-right: 30px;
}
&:first-of-type {
.s-txt {
line-height: 40px;
}
}
.s-txt {
width: 160px;
flex-shrink: 0;
}
.sel {
:deep(.el-input__inner) {
border-radius: 20px;
}
}
:deep(.el-checkbox) {
margin-bottom: 12px;
}
.tips {
display: flex;
align-items: center;
color: #666;
}
.el-icon-warning {
font-size: 20px;
color: #ec7f8c;
margin-right: 10px;
}
}
.btn-box {
width: 80%;
margin: 60px auto 0;
display: flex;
justify-content: flex-end;
.btn {
margin: 0 10px;
}
}
.step-item {
text-align: center;
}
.step-item2 {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
color: #000;
font-weight: 500;
.p2 {
font-size: 16px;
margin: 0 0 20px -68px;
.btn {
margin-right: 14px;
}
}
.p1 {
width: 450px;
text-align: left;
margin-bottom: 20px;
}
}
:deep(.down-txt) {
justify-content: center;
padding-left: 0;
}
</style>