|
@@ -62,14 +62,14 @@
|
62
|
62
|
/>
|
63
|
63
|
</div>
|
64
|
64
|
<div>
|
65
|
|
- <Button type="primary" class="primary_btn" @click="userExport()"
|
|
65
|
+ <Button type="primary" class="primary_btn" @click="userImport()"
|
66
|
66
|
>用户导入</Button
|
67
|
67
|
>
|
68
|
68
|
<Button
|
69
|
69
|
style="margin: 0 10px"
|
70
|
70
|
type="primary"
|
71
|
71
|
class="primary_btn"
|
72
|
|
- @click="toAdd()"
|
|
72
|
+ @click="userExport()"
|
73
|
73
|
>用户导出</Button
|
74
|
74
|
>
|
75
|
75
|
<Button type="primary" class="primary_btn" @click="toAdd()"
|
|
@@ -79,6 +79,9 @@
|
79
|
79
|
</div>
|
80
|
80
|
<div class="table_wrap">
|
81
|
81
|
<Table :columns="columns" :data="searchForm.list">
|
|
82
|
+ <template slot-scope="{ row }" slot="loginname">
|
|
83
|
+ <span v-if="row.care === 1" style="color: #FCC138" class="ivu-icon iconfont icon-guanzhu-yiguanzhu"></span> {{row.loginname}}
|
|
84
|
+ </template>
|
82
|
85
|
<template slot-scope="{ row }" slot="enabled">
|
83
|
86
|
<i-switch
|
84
|
87
|
size="large"
|
|
@@ -113,6 +116,45 @@
|
113
|
116
|
></Page>
|
114
|
117
|
</div>
|
115
|
118
|
</div>
|
|
119
|
+ <!-- 导入 -->
|
|
120
|
+ <Modal
|
|
121
|
+ :mask-closable="false"
|
|
122
|
+ v-model="importInfo.show"
|
|
123
|
+ class="modal_tip"
|
|
124
|
+ title="导入"
|
|
125
|
+ >
|
|
126
|
+ <Upload
|
|
127
|
+ v-if="importInfo.show"
|
|
128
|
+ type="drag"
|
|
129
|
+ action
|
|
130
|
+ accept=".xls,.xlsx"
|
|
131
|
+ :before-upload="handleUpload"
|
|
132
|
+ >
|
|
133
|
+ <div style="padding: 30px 0; background: #f8f8f9">
|
|
134
|
+ <Button
|
|
135
|
+ type="primary"
|
|
136
|
+ class="primary_btn"
|
|
137
|
+ style="font-size: 16px"
|
|
138
|
+ >
|
|
139
|
+ <Icon type="ios-cloud-upload-outline" size="18"></Icon>上传excel
|
|
140
|
+ </Button>
|
|
141
|
+ <div style="margin-top: 10px; color: #999">支持上传xlsx/xls文件</div>
|
|
142
|
+ </div>
|
|
143
|
+ </Upload>
|
|
144
|
+ <div v-if="importInfo.file" class="files_list">
|
|
145
|
+ {{ importInfo.file.name }}
|
|
146
|
+ </div>
|
|
147
|
+ <div class="import_tip">
|
|
148
|
+ 导入数据需按照模板填写信息,
|
|
149
|
+ <span class="theme_color" @click="download()">下载表格模板</span>
|
|
150
|
+ </div>
|
|
151
|
+ <div slot="footer">
|
|
152
|
+ <Button @click="importInfo.show = false">取消</Button>
|
|
153
|
+ <Button @click="ok_import" class="primary_btn" :loading="wait_flag" type="primary"
|
|
154
|
+ >保存</Button
|
|
155
|
+ >
|
|
156
|
+ </div>
|
|
157
|
+ </Modal>
|
116
|
158
|
<!-- 新建 -->
|
117
|
159
|
<Modal
|
118
|
160
|
class="modal1"
|
|
@@ -216,38 +258,44 @@
|
216
|
258
|
<script>
|
217
|
259
|
import {
|
218
|
260
|
class_list,
|
|
261
|
+ user_care,
|
|
262
|
+ user_delete,
|
219
|
263
|
user_disabled,
|
220
|
264
|
user_enable,
|
221
|
265
|
user_list
|
222
|
266
|
} from "@/api/school";
|
223
|
|
-import {user_add, user_edit} from "@/api/school";
|
224
|
|
-import {generateRandomString} from "@/utils";
|
|
267
|
+import { user_add, user_edit } from "@/api/school";
|
225
|
268
|
|
226
|
269
|
export default {
|
227
|
270
|
data() {
|
228
|
271
|
const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,32}$/;
|
229
|
272
|
// 密码验证
|
230
|
273
|
const pwdCheck = (rule, value, callback) => {
|
231
|
|
- console.log(value)
|
232
|
|
- if (!reg.test(this.addInfo.loginpwd)) {
|
|
274
|
+ if (!reg.test(value)) {
|
233
|
275
|
return callback(new Error("密码格式不正确!"));
|
234
|
276
|
}
|
235
|
|
- console.log(this.addInfo.loginpwd)
|
|
277
|
+ callback();
|
236
|
278
|
};
|
237
|
279
|
// 重复密码验证
|
238
|
280
|
const pwdAgainCheck = async (rule, value, callback) => {
|
239
|
|
- if (!reg.test(this.addInfo.loginpwd1)) {
|
|
281
|
+ if (!value) {
|
240
|
282
|
return callback(new Error("确认密码不能为空!"));
|
241
|
283
|
}
|
242
|
|
- if (!reg.test(this.addInfo.loginpwd1)) {
|
|
284
|
+ if (!reg.test(value)) {
|
243
|
285
|
return callback(new Error("密码格式不正确!"));
|
244
|
286
|
}
|
245
|
|
- if (this.addInfo.loginpwd != this.addInfo.loginpwd1) {
|
|
287
|
+ if (this.addInfo.loginpwd != value) {
|
246
|
288
|
return callback(new Error("两次输入密码不一致!"));
|
247
|
289
|
}
|
|
290
|
+ callback();
|
248
|
291
|
};
|
249
|
292
|
return {
|
250
|
293
|
userInfo: {},
|
|
294
|
+ importInfo: {
|
|
295
|
+ show: false,
|
|
296
|
+ file: null
|
|
297
|
+ },
|
|
298
|
+ wait_flag: false,
|
251
|
299
|
showLoading: false,
|
252
|
300
|
care_list: [
|
253
|
301
|
{ id: 0, title: "请选择关注状态" },
|
|
@@ -338,7 +386,7 @@ export default {
|
338
|
386
|
},
|
339
|
387
|
{
|
340
|
388
|
title: "登录名",
|
341
|
|
- key: "loginname",
|
|
389
|
+ slot: "loginname",
|
342
|
390
|
align: "center"
|
343
|
391
|
},
|
344
|
392
|
{
|
|
@@ -388,13 +436,53 @@ export default {
|
388
|
436
|
},
|
389
|
437
|
methods: {
|
390
|
438
|
classChange() {
|
391
|
|
- if(this.schoolInfo.children.length === 0){
|
|
439
|
+ if (this.schoolInfo.children.length === 0) {
|
392
|
440
|
return;
|
393
|
441
|
}
|
394
|
|
- let classInfo = this.schoolInfo.children.filter(v=>v.id === this.addInfo.classid)[0];
|
|
442
|
+ let classInfo = this.schoolInfo.children.filter(
|
|
443
|
+ (v) => v.id === this.addInfo.classid
|
|
444
|
+ )[0];
|
395
|
445
|
this.addInfo.classname = classInfo.name;
|
396
|
446
|
},
|
397
|
|
- userImport() {},
|
|
447
|
+ download(){
|
|
448
|
+ //下载模版
|
|
449
|
+ let url = "../../../../doc/student.xls";
|
|
450
|
+ console.log(url)
|
|
451
|
+ const a = document.createElement("a"); // 创建a标签
|
|
452
|
+ a.setAttribute("download", "学生信息模版"); // download属性
|
|
453
|
+ a.setAttribute("href", url); // href链接
|
|
454
|
+ a.click(); // 自执行点击事件
|
|
455
|
+ },
|
|
456
|
+ ok_import(){
|
|
457
|
+ //确定导入
|
|
458
|
+ },
|
|
459
|
+ //导入
|
|
460
|
+ userImport() {
|
|
461
|
+ this.importInfo = {
|
|
462
|
+ show: true,
|
|
463
|
+ file: null
|
|
464
|
+ }
|
|
465
|
+ },
|
|
466
|
+ // 上传文件
|
|
467
|
+ handleUpload(file) {
|
|
468
|
+ let str = file.name.split(".");
|
|
469
|
+ let suffix = str[str.length - 1];
|
|
470
|
+ suffix = suffix.toLowerCase();
|
|
471
|
+ if (suffix === "xls" || suffix === "xlsx") {
|
|
472
|
+ this.import_obj.file = file;
|
|
473
|
+ this.import_img = true;
|
|
474
|
+ this.form_data = new FormData();
|
|
475
|
+ this.form_data.append("file", file);
|
|
476
|
+ this.form_data.append("schoolid", this.userInfo.schoolid);
|
|
477
|
+ this.form_data.append("createid", this.userInfo.userid);
|
|
478
|
+ this.form_data.append("classid", this.form_list.classid);
|
|
479
|
+ this.form_data.append("groupid", 1);
|
|
480
|
+ } else {
|
|
481
|
+ this.import_obj.file = undefined;
|
|
482
|
+ this.$Message.error("请上传excel文件");
|
|
483
|
+ }
|
|
484
|
+ return false;
|
|
485
|
+ },
|
398
|
486
|
userExport() {},
|
399
|
487
|
toAdd() {
|
400
|
488
|
this.addInfo = {
|
|
@@ -418,19 +506,26 @@ export default {
|
418
|
506
|
console.log(this.addInfo);
|
419
|
507
|
this.$refs.addForm.validate((valid) => {
|
420
|
508
|
if (valid) {
|
421
|
|
- console.log(this.addInfo.classid)
|
422
|
|
- if(!this.addInfo.classid){
|
423
|
|
- this.$Message.error("请选择班级!")
|
424
|
|
- return
|
425
|
|
- }
|
|
509
|
+ console.log(this.addInfo.classid);
|
|
510
|
+ if (this.addInfo.userphone) {
|
|
511
|
+ var filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
|
512
|
+ if (!filter.test(this.addInfo.userphone)) {
|
|
513
|
+ this.$Message.error("手机号码格式不正确!");
|
|
514
|
+ return;
|
|
515
|
+ }
|
|
516
|
+ }
|
|
517
|
+ if (!this.addInfo.classid) {
|
|
518
|
+ this.$Message.error("请选择班级!");
|
|
519
|
+ return;
|
|
520
|
+ }
|
426
|
521
|
let form = {
|
427
|
522
|
username: this.addInfo.username,
|
428
|
523
|
loginname: this.addInfo.loginname,
|
429
|
524
|
loginpwd: this.addInfo.loginpwd,
|
430
|
525
|
classid: this.addInfo.classid,
|
431
|
526
|
classname: this.addInfo.classname,
|
432
|
|
- schoolid: this.addInfo.schoolid,
|
433
|
|
- regionid: this.addInfo.regionid,
|
|
527
|
+ schoolid: this.addInfo.schoolid || 1,
|
|
528
|
+ regionid: this.userInfo.regionid,
|
434
|
529
|
enabled: this.addInfo.enabled,
|
435
|
530
|
studentno: this.addInfo.studentno,
|
436
|
531
|
userphone: this.addInfo.userphone,
|
|
@@ -456,8 +551,29 @@ export default {
|
456
|
551
|
}
|
457
|
552
|
});
|
458
|
553
|
},
|
459
|
|
- toCare(row) {},
|
460
|
|
- toDel(row) {},
|
|
554
|
+ toEdit(row) {},
|
|
555
|
+ toCare(row) {
|
|
556
|
+ user_care({ userid: row.userid, rversion: row.rversion }).then((res) => {
|
|
557
|
+ if (res.code === 0) {
|
|
558
|
+ this.searchList();
|
|
559
|
+ this.$Message.success(res.msg);
|
|
560
|
+ } else {
|
|
561
|
+ this.$Message.error(res.msg);
|
|
562
|
+ }
|
|
563
|
+ });
|
|
564
|
+ },
|
|
565
|
+ toDel(row) {
|
|
566
|
+ user_delete({ userid: row.userid, rversion: row.rversion }).then(
|
|
567
|
+ (res) => {
|
|
568
|
+ if (res.code === 0) {
|
|
569
|
+ this.searchList();
|
|
570
|
+ this.$Message.success(res.msg);
|
|
571
|
+ } else {
|
|
572
|
+ this.$Message.error(res.msg);
|
|
573
|
+ }
|
|
574
|
+ }
|
|
575
|
+ );
|
|
576
|
+ },
|
461
|
577
|
enabledChange(row) {
|
462
|
578
|
let api = row.enabled === 1 ? user_enable : user_disabled;
|
463
|
579
|
api({
|
|
@@ -617,4 +733,19 @@ export default {
|
617
|
733
|
}
|
618
|
734
|
}
|
619
|
735
|
}
|
|
736
|
+.modal_tip{
|
|
737
|
+ .files_list{
|
|
738
|
+ height: 30px;
|
|
739
|
+ line-height: 30px;
|
|
740
|
+ }
|
|
741
|
+ .import_tip{
|
|
742
|
+ height: 30px;
|
|
743
|
+ line-height: 30px;
|
|
744
|
+ text-align: center;
|
|
745
|
+ .theme_color{
|
|
746
|
+ color: #339dff;
|
|
747
|
+ cursor: pointer;
|
|
748
|
+ }
|
|
749
|
+ }
|
|
750
|
+}
|
620
|
751
|
</style>
|