Browse Source

用户管理

gzb
guozhongbo 9 months ago
parent
commit
43a8851968
1 changed files with 205 additions and 58 deletions
  1. 205
    58
      src/views/schoolSection/userManage/userManage.vue

+ 205
- 58
src/views/schoolSection/userManage/userManage.vue View File

5
       <div class="class_list">
5
       <div class="class_list">
6
         <div v-for="item in schoolInfo.children" :key="item.id">
6
         <div v-for="item in schoolInfo.children" :key="item.id">
7
           <div
7
           <div
8
-            :class="[curClass === item.id ? 'active' : '']"
8
+            :class="[curClass.id === item.id ? 'active' : '']"
9
             :title="item.name"
9
             :title="item.name"
10
             @click="selectClass(item)"
10
             @click="selectClass(item)"
11
           >
11
           >
80
       <div class="table_wrap">
80
       <div class="table_wrap">
81
         <Table :columns="columns" :data="searchForm.list">
81
         <Table :columns="columns" :data="searchForm.list">
82
           <template slot-scope="{ row }" slot="loginname">
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}}
83
+            <span
84
+              v-if="row.care === 1"
85
+              style="color: #fcc138"
86
+              class="ivu-icon iconfont icon-guanzhu-yiguanzhu"
87
+            ></span>
88
+            {{ row.loginname }}
84
           </template>
89
           </template>
85
           <template slot-scope="{ row }" slot="enabled">
90
           <template slot-scope="{ row }" slot="enabled">
86
             <i-switch
91
             <i-switch
97
           <template slot-scope="{ row }" slot="actionSlot">
102
           <template slot-scope="{ row }" slot="actionSlot">
98
             <div class="action_list">
103
             <div class="action_list">
99
               <div class="action_del" @click="toDel(row)">删除</div>
104
               <div class="action_del" @click="toDel(row)">删除</div>
100
-              <div class="action_success" @click="toCare(row)">重点关注</div>
105
+              <div class="action_success" @click="toCare(row)">
106
+                <span v-if="row.care === 2">重点关注</span>
107
+                <span v-else>取消关注</span>
108
+              </div>
101
             </div>
109
             </div>
102
           </template>
110
           </template>
103
         </Table>
111
         </Table>
116
         ></Page>
124
         ></Page>
117
       </div>
125
       </div>
118
     </div>
126
     </div>
127
+    <!-- 已存在列表 -->
128
+    <Modal
129
+      v-model="exitInfo.show"
130
+      :mask-closable="false"
131
+      class="exit_modal modal1"
132
+      title="提示"
133
+    >
134
+      <div class="exit">
135
+        <div>
136
+          <div v-if="exitInfo.studentsExisted.length > 0">
137
+            以下学生信息已存在
138
+            <Table border :columns="columns2" :data="exitInfo.studentsExisted">
139
+              <template slot-scope="{ row }" slot="usersex">
140
+                <span>
141
+                  {{
142
+                    row.usersex == 1 ? "男" : row.usersex == 2 ? "女" : "未知"
143
+                  }}
144
+                </span>
145
+              </template>
146
+            </Table>
147
+          </div>
148
+          <div v-if="exitInfo.usersExisted.length > 0">
149
+            已存在非本校账号列表
150
+            <Table border :columns="columns2" :data="exitInfo.usersExisted">
151
+              <template slot-scope="{ row }" slot="usersex">
152
+                <span>
153
+                  {{
154
+                    row.usersex == 1 ? "男" : row.usersex == 2 ? "女" : "未知"
155
+                  }}
156
+                </span>
157
+              </template>
158
+            </Table>
159
+          </div>
160
+        </div>
161
+      </div>
162
+    </Modal>
119
     <!-- 导入 -->
163
     <!-- 导入 -->
120
     <Modal
164
     <Modal
121
-        :mask-closable="false"
122
-        v-model="importInfo.show"
123
-        class="modal_tip"
124
-        title="导入"
165
+      :mask-closable="false"
166
+      v-model="importInfo.show"
167
+      class="modal_tip"
168
+      title="导入"
125
     >
169
     >
126
       <Upload
170
       <Upload
127
-          v-if="importInfo.show"
128
-          type="drag"
129
-          action
130
-          accept=".xls,.xlsx"
131
-          :before-upload="handleUpload"
171
+        v-if="importInfo.show"
172
+        type="drag"
173
+        action
174
+        accept=".xls,.xlsx"
175
+        :before-upload="handleUpload"
132
       >
176
       >
133
         <div style="padding: 30px 0; background: #f8f8f9">
177
         <div style="padding: 30px 0; background: #f8f8f9">
134
-          <Button
135
-              type="primary"
136
-              class="primary_btn"
137
-              style="font-size: 16px"
138
-          >
178
+          <Button type="primary" class="primary_btn" style="font-size: 16px">
139
             <Icon type="ios-cloud-upload-outline" size="18"></Icon>上传excel
179
             <Icon type="ios-cloud-upload-outline" size="18"></Icon>上传excel
140
           </Button>
180
           </Button>
141
           <div style="margin-top: 10px; color: #999">支持上传xlsx/xls文件</div>
181
           <div style="margin-top: 10px; color: #999">支持上传xlsx/xls文件</div>
150
       </div>
190
       </div>
151
       <div slot="footer">
191
       <div slot="footer">
152
         <Button @click="importInfo.show = false">取消</Button>
192
         <Button @click="importInfo.show = false">取消</Button>
153
-        <Button @click="ok_import"    class="primary_btn" :loading="wait_flag" type="primary"
154
-        >保存</Button
193
+        <Button
194
+          @click="ok_import"
195
+          class="primary_btn"
196
+          :loading="wait_flag"
197
+          type="primary"
198
+          >保存</Button
155
         >
199
         >
156
       </div>
200
       </div>
157
     </Modal>
201
     </Modal>
174
           <Input v-model="addInfo.username" placeholder="请输入姓名"></Input>
218
           <Input v-model="addInfo.username" placeholder="请输入姓名"></Input>
175
         </FormItem>
219
         </FormItem>
176
         <FormItem label="性别" style="width: calc(50% - 10px)">
220
         <FormItem label="性别" style="width: calc(50% - 10px)">
177
-          <RadioGroup v-model="addInfo.sex">
221
+          <RadioGroup v-model="addInfo.usersex">
178
             <Radio :label="1">男</Radio>
222
             <Radio :label="1">男</Radio>
179
             <Radio :label="2">女</Radio>
223
             <Radio :label="2">女</Radio>
180
             <Radio :label="0">未知</Radio>
224
             <Radio :label="0">未知</Radio>
262
   user_delete,
306
   user_delete,
263
   user_disabled,
307
   user_disabled,
264
   user_enable,
308
   user_enable,
265
-  user_list
309
+  user_export,
310
+  user_import,
311
+  user_list,
312
+  user_un_care
266
 } from "@/api/school";
313
 } from "@/api/school";
267
 import { user_add, user_edit } from "@/api/school";
314
 import { user_add, user_edit } from "@/api/school";
315
+import { exportToExcel } from "@/utils/exportToExcel";
268
 
316
 
269
 export default {
317
 export default {
270
   data() {
318
   data() {
295
         show: false,
343
         show: false,
296
         file: null
344
         file: null
297
       },
345
       },
346
+      exitInfo: {
347
+        show: false,
348
+        studentsExisted: [],
349
+        usersExisted: []
350
+      },
351
+      columns2: [
352
+        {
353
+          title: "姓名",
354
+          key: "username",
355
+          minWidth: 140,
356
+          align: "center"
357
+        },
358
+        {
359
+          title: "登录名",
360
+          key: "loginname",
361
+          minWidth: 140,
362
+          align: "center"
363
+        },
364
+        {
365
+          title: "性别",
366
+          key: "usersex",
367
+          align: "center",
368
+          slot: "usersex"
369
+        }
370
+      ],
371
+      form_data: null,
298
       wait_flag: false,
372
       wait_flag: false,
299
       showLoading: false,
373
       showLoading: false,
300
       care_list: [
374
       care_list: [
312
         { id: 1, title: "管控中" },
386
         { id: 1, title: "管控中" },
313
         { id: 2, title: "解除管控" }
387
         { id: 2, title: "解除管控" }
314
       ],
388
       ],
315
-      curClass: 0,
389
+      curClass: {
390
+        id: 0,
391
+        name: ""
392
+      },
316
       addInfo: {
393
       addInfo: {
317
         show: false,
394
         show: false,
318
         userid: null,
395
         userid: null,
430
     this.userInfo = JSON.parse(
507
     this.userInfo = JSON.parse(
431
       localStorage.getItem("xh_control_userInfo")
508
       localStorage.getItem("xh_control_userInfo")
432
     ).content;
509
     ).content;
433
-    console.log(this.userInfo);
434
     this.init();
510
     this.init();
435
     this.searchList();
511
     this.searchList();
436
   },
512
   },
444
       )[0];
520
       )[0];
445
       this.addInfo.classname = classInfo.name;
521
       this.addInfo.classname = classInfo.name;
446
     },
522
     },
447
-    download(){
523
+    download() {
448
       //下载模版
524
       //下载模版
449
       let url = "../../../../doc/student.xls";
525
       let url = "../../../../doc/student.xls";
450
-      console.log(url)
451
       const a = document.createElement("a"); // 创建a标签
526
       const a = document.createElement("a"); // 创建a标签
452
       a.setAttribute("download", "学生信息模版"); // download属性
527
       a.setAttribute("download", "学生信息模版"); // download属性
453
       a.setAttribute("href", url); // href链接
528
       a.setAttribute("href", url); // href链接
454
       a.click(); // 自执行点击事件
529
       a.click(); // 自执行点击事件
455
     },
530
     },
456
-    ok_import(){
457
-      //确定导入
531
+    //确定导入
532
+    ok_import() {
533
+      if (!this.importInfo.file) {
534
+        this.$Message.error("请选择上传文件");
535
+        return;
536
+      }
537
+      this.wait_flag = true;
538
+      let that = this;
539
+      user_import(this.form_data)
540
+        .then((res) => {
541
+          this.wait_flag = false;
542
+          if (res.code == 0) {
543
+            this.importInfo = {
544
+              show: false,
545
+              file: null
546
+            };
547
+            if (res.obj.code == 0) {
548
+              this.$Message.success("导入成功");
549
+              this.searchList();
550
+            } else {
551
+              this.exitInfo = {
552
+                show: true,
553
+                studentsExisted: res.obj.studentsExisted,
554
+                usersExisted: res.obj.usersExisted
555
+              };
556
+            }
557
+          } else {
558
+            this.$Message.error(res.msg);
559
+          }
560
+          this.form_data = null;
561
+        })
562
+        .catch(() => {
563
+          that.wait_flag = false;
564
+        });
458
     },
565
     },
459
     //导入
566
     //导入
460
     userImport() {
567
     userImport() {
461
       this.importInfo = {
568
       this.importInfo = {
462
         show: true,
569
         show: true,
463
-            file: null
464
-      }
570
+        file: null
571
+      };
465
     },
572
     },
466
     // 上传文件
573
     // 上传文件
467
     handleUpload(file) {
574
     handleUpload(file) {
469
       let suffix = str[str.length - 1];
576
       let suffix = str[str.length - 1];
470
       suffix = suffix.toLowerCase();
577
       suffix = suffix.toLowerCase();
471
       if (suffix === "xls" || suffix === "xlsx") {
578
       if (suffix === "xls" || suffix === "xlsx") {
472
-        this.import_obj.file = file;
579
+        this.importInfo.file = file;
473
         this.import_img = true;
580
         this.import_img = true;
474
         this.form_data = new FormData();
581
         this.form_data = new FormData();
475
         this.form_data.append("file", file);
582
         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);
583
+        this.form_data.append("schoolid", 1);
584
+        this.form_data.append("regionid", this.userInfo.regionid);
480
       } else {
585
       } else {
481
-        this.import_obj.file = undefined;
586
+        this.importInfo.file = null;
482
         this.$Message.error("请上传excel文件");
587
         this.$Message.error("请上传excel文件");
483
       }
588
       }
484
       return false;
589
       return false;
485
     },
590
     },
486
-    userExport() {},
591
+    //导出
592
+    userExport() {
593
+      user_export({ schoolid: 1 }).then((res) => {
594
+        if (res.code === 0) {
595
+          exportToExcel(
596
+            [
597
+              {
598
+                list: res.obj.map((item) => {
599
+                  return {
600
+                    登录名: item.loginname,
601
+                    姓名: item.username,
602
+                    班级: item.classname,
603
+                    状态: item.enabled === 1 ? "启用" : "禁用",
604
+                    最后登录时间: item.lasttime || ""
605
+                  };
606
+                }),
607
+                name: this.curClass.name
608
+              }
609
+            ],
610
+            this.curClass.name
611
+          );
612
+        } else {
613
+          this.$Message.error(res.msg);
614
+        }
615
+      });
616
+    },
487
     toAdd() {
617
     toAdd() {
488
       this.addInfo = {
618
       this.addInfo = {
489
         show: true,
619
         show: true,
490
         userid: null,
620
         userid: null,
491
-        sex: 1,
621
+        usersex: 1,
492
         username: "",
622
         username: "",
493
         loginname: "",
623
         loginname: "",
494
         loginpwd: "",
624
         loginpwd: "",
503
       };
633
       };
504
     },
634
     },
505
     saveAddInfo() {
635
     saveAddInfo() {
506
-      console.log(this.addInfo);
507
       this.$refs.addForm.validate((valid) => {
636
       this.$refs.addForm.validate((valid) => {
508
         if (valid) {
637
         if (valid) {
509
-          console.log(this.addInfo.classid);
510
           if (this.addInfo.userphone) {
638
           if (this.addInfo.userphone) {
511
             var filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
639
             var filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
512
             if (!filter.test(this.addInfo.userphone)) {
640
             if (!filter.test(this.addInfo.userphone)) {
521
           let form = {
649
           let form = {
522
             username: this.addInfo.username,
650
             username: this.addInfo.username,
523
             loginname: this.addInfo.loginname,
651
             loginname: this.addInfo.loginname,
652
+            usersex: this.addInfo.usersex,
524
             loginpwd: this.addInfo.loginpwd,
653
             loginpwd: this.addInfo.loginpwd,
525
             classid: this.addInfo.classid,
654
             classid: this.addInfo.classid,
526
             classname: this.addInfo.classname,
655
             classname: this.addInfo.classname,
531
             userphone: this.addInfo.userphone,
660
             userphone: this.addInfo.userphone,
532
             cardid: this.addInfo.cardid
661
             cardid: this.addInfo.cardid
533
           };
662
           };
534
-          //编辑
535
-          // if (this.addInfo.appid) {
536
-          //   form.userid = this.addInfo.userid;
537
-          //   form.rversion = this.addInfo.rversion;
538
-          // }
539
-          console.log(form);
540
           let api = this.addInfo.userid ? user_edit : user_add;
663
           let api = this.addInfo.userid ? user_edit : user_add;
541
           api(form).then((res) => {
664
           api(form).then((res) => {
542
             if (res.code === 0) {
665
             if (res.code === 0) {
543
               this.addInfo.show = false;
666
               this.addInfo.show = false;
544
-              console.log(res.obj);
545
               this.$Message.success(res.msg);
667
               this.$Message.success(res.msg);
546
               this.searchList();
668
               this.searchList();
547
             } else {
669
             } else {
551
         }
673
         }
552
       });
674
       });
553
     },
675
     },
554
-    toEdit(row) {},
555
     toCare(row) {
676
     toCare(row) {
556
-      user_care({ userid: row.userid, rversion: row.rversion }).then((res) => {
677
+      let api = row.care === 1 ? user_un_care : user_care;
678
+      api({ userid: row.userid, rversion: row.rversion }).then((res) => {
557
         if (res.code === 0) {
679
         if (res.code === 0) {
558
           this.searchList();
680
           this.searchList();
559
           this.$Message.success(res.msg);
681
           this.$Message.success(res.msg);
589
       });
711
       });
590
     },
712
     },
591
     selectClass(item) {
713
     selectClass(item) {
592
-      this.curClass = item.id;
714
+      this.curClass = item;
715
+      this.searchList();
593
     },
716
     },
594
     init() {
717
     init() {
595
       this.showLoading = true;
718
       this.showLoading = true;
598
         if (res.code === 0) {
721
         if (res.code === 0) {
599
           this.schoolInfo = res.obj;
722
           this.schoolInfo = res.obj;
600
           if (this.schoolInfo.children.length > 0) {
723
           if (this.schoolInfo.children.length > 0) {
601
-            this.curClass = this.schoolInfo.children[0].id;
724
+            this.curClass = this.schoolInfo.children[0];
602
           }
725
           }
603
-          console.log(res.obj);
604
         } else {
726
         } else {
605
           this.$Message.error(res.msg);
727
           this.$Message.error(res.msg);
606
         }
728
         }
629
         page: this.searchForm.page,
751
         page: this.searchForm.page,
630
         size: this.searchForm.size,
752
         size: this.searchForm.size,
631
         schoolid: this.searchForm.schoolid,
753
         schoolid: this.searchForm.schoolid,
632
-        classid: this.curClass,
754
+        classid: this.curClass.id,
633
         care: this.searchForm.care,
755
         care: this.searchForm.care,
634
         enabled: this.searchForm.enabled,
756
         enabled: this.searchForm.enabled,
635
         control: this.searchForm.control,
757
         control: this.searchForm.control,
639
         if (res.code === 0) {
761
         if (res.code === 0) {
640
           this.searchForm.list = res.obj.data;
762
           this.searchForm.list = res.obj.data;
641
           this.searchForm.total = res.obj.total;
763
           this.searchForm.total = res.obj.total;
642
-          console.log(this.searchForm.list);
643
         } else {
764
         } else {
644
           this.$Message.error(res.msg);
765
           this.$Message.error(res.msg);
645
         }
766
         }
674
         line-height: 30px;
795
         line-height: 30px;
675
         height: 30px;
796
         height: 30px;
676
         text-align: center;
797
         text-align: center;
677
-        cursor: p;
798
+        cursor: pointer;
678
       }
799
       }
679
       .active {
800
       .active {
680
         border-radius: 6px;
801
         border-radius: 6px;
685
   .user_list {
806
   .user_list {
686
     width: calc(100% - 216px);
807
     width: calc(100% - 216px);
687
     height: 100%;
808
     height: 100%;
809
+    overflow-y: auto;
688
     border-radius: 15px;
810
     border-radius: 15px;
689
     background-color: white;
811
     background-color: white;
690
   }
812
   }
733
     }
855
     }
734
   }
856
   }
735
 }
857
 }
736
-.modal_tip{
737
-  .files_list{
858
+.modal_tip {
859
+  .files_list {
738
     height: 30px;
860
     height: 30px;
739
     line-height: 30px;
861
     line-height: 30px;
740
   }
862
   }
741
-  .import_tip{
863
+  .import_tip {
742
     height: 30px;
864
     height: 30px;
743
     line-height: 30px;
865
     line-height: 30px;
744
     text-align: center;
866
     text-align: center;
745
-    .theme_color{
867
+    .theme_color {
746
       color: #339dff;
868
       color: #339dff;
747
       cursor: pointer;
869
       cursor: pointer;
748
     }
870
     }
749
   }
871
   }
750
 }
872
 }
873
+// 存在信息
874
+.exit_modal {
875
+  /deep/ .ivu-modal {
876
+    .ivu-modal-content {
877
+      .exit {
878
+        div {
879
+          // margin-bottom: 10px;
880
+          font-size: 18px;
881
+          line-height: 40px;
882
+        }
883
+      }
884
+      .ivu-table {
885
+        -moz-user-select: none;
886
+        -khtml-user-select: none;
887
+        user-select: none;
888
+      }
889
+      div .ivu-table-header thead tr > th {
890
+        height: 40px;
891
+      }
892
+      .ivu-modal-footer {
893
+        display: none;
894
+      }
895
+    }
896
+  }
897
+}
751
 </style>
898
 </style>

Loading…
Cancel
Save