Parcourir la source

用户管理-新建可以创建班级

gzb
wangzhonglu il y a 8 mois
Parent
révision
bbe7a7cd7a
1 fichiers modifiés avec 41 ajouts et 8 suppressions
  1. 41
    8
      src/views/schoolSection/userManage/userManage.vue

+ 41
- 8
src/views/schoolSection/userManage/userManage.vue Voir le fichier

@@ -14,7 +14,11 @@
14 14
         全部班级
15 15
       </div>
16 16
       <div class="class_list">
17
-        <div v-for="item in schoolInfo.children" :key="item.id">
17
+        <div
18
+          v-for="item in schoolInfo.children"
19
+          :key="`${item.id}_${item.name}`"
20
+          v-show="item.id !== -1"
21
+        >
18 22
           <div
19 23
             :class="[
20 24
               'class_item',
@@ -174,7 +178,7 @@
174 178
         </FormItem>
175 179
       </Form>
176 180
       <div slot="footer" style="text-align: right">
177
-        <Button @click="exitInfo.show = false">取消</Button>
181
+        <Button @click="classInfo.show = false">取消</Button>
178 182
         <Button @click="saveclassInfo()" type="primary" class="primary_btn"
179 183
           >保存</Button
180 184
         >
@@ -302,12 +306,15 @@
302 306
             placeholder="请选择班级"
303 307
             style="width: 300px"
304 308
             @on-change="classChange()"
309
+            @on-create="createClassInfo"
310
+            filterable
311
+            allow-create
305 312
           >
306 313
             <template v-if="schoolInfo.children.length > 0">
307 314
               <Option
308 315
                 v-for="item in schoolInfo.children"
309 316
                 :value="item.id"
310
-                :key="item.id"
317
+                :key="`${item.id}_${item.name}`"
311 318
                 >{{ item.name }}</Option
312 319
               >
313 320
             </template>
@@ -641,7 +648,9 @@ export default {
641 648
               rversion: this.selectedModel.rversion
642 649
             }).then((res) => {
643 650
               if (res.code === 0) {
651
+                this.curClass.id = null;
644 652
                 this.init();
653
+                this.searchList();
645 654
                 this.$Message.success(res.msg);
646 655
               } else {
647 656
                 this.$Message.error(res.msg);
@@ -682,6 +691,18 @@ export default {
682 691
       this.$refs.moreMenuRef.style.left = `-9999px`;
683 692
       this.$refs.moreMenuRef.style.top = `-9999px`;
684 693
     },
694
+    // 创建班级
695
+    createClassInfo(name) {
696
+      this.schoolInfo.children = this.schoolInfo.children.filter(
697
+        (item) => item.id !== -1
698
+      );
699
+      this.schoolInfo.children.push({
700
+        id: -1,
701
+        name
702
+      });
703
+      this.addInfo.classid = -1;
704
+      this.addInfo.classname = name;
705
+    },
685 706
     classChange() {
686 707
       if (this.schoolInfo.children.length === 0) {
687 708
         return;
@@ -689,7 +710,9 @@ export default {
689 710
       let classInfo = this.schoolInfo.children.filter(
690 711
         (v) => v.id === this.addInfo.classid
691 712
       )[0];
692
-      this.addInfo.classname = classInfo.name;
713
+      if (classInfo) {
714
+        this.addInfo.classname = classInfo.name;
715
+      }
693 716
     },
694 717
     download() {
695 718
       //下载模版
@@ -753,7 +776,9 @@ export default {
753 776
         this.form_data = new FormData();
754 777
         this.form_data.append("file", file);
755 778
         this.form_data.append("schoolid", this.powerParams.objectid);
756
-        this.form_data.append("regionid", this.powerParams.objectid);
779
+        let _regionids = this.$store.state.userPower.regionids;
780
+        _regionids = [..._regionids];
781
+        this.form_data.append("regionid", _regionids.pop());
757 782
       } else {
758 783
         this.importInfo.file = null;
759 784
         this.$Message.error("请上传excel文件");
@@ -825,22 +850,27 @@ export default {
825 850
             this.$Message.error("请选择班级!");
826 851
             return;
827 852
           }
853
+          let _regionids = this.$store.state.userPower.regionids;
854
+          _regionids = [..._regionids];
828 855
           let form = {
829 856
             username: this.addInfo.username,
830 857
             loginname: this.addInfo.loginname,
831 858
             usersex: this.addInfo.usersex,
832 859
             loginpwd: this.addInfo.loginpwd,
833
-            classid: this.addInfo.classid,
834
-            classname: this.addInfo.classname,
835 860
             rtype: this.powerParams.rtype,
836 861
             objectid: this.powerParams.objectid,
837
-            regionid: this.powerParams.objectid,
862
+            regionid: _regionids.pop(),
838 863
             schoolid: this.addInfo.schoolid || 1,
839 864
             enabled: this.addInfo.enabled,
840 865
             studentno: this.addInfo.studentno,
841 866
             userphone: this.addInfo.userphone,
842 867
             cardid: this.addInfo.cardid
843 868
           };
869
+          if (this.addInfo.classid && this.addInfo.classid !== -1) {
870
+            form.classid = this.addInfo.classid;
871
+          } else {
872
+            form.classname = this.addInfo.classname;
873
+          }
844 874
           let api = this.addInfo.userid ? user_edit : user_add;
845 875
           this.showLoading = true;
846 876
           api(form).then((res) => {
@@ -849,6 +879,9 @@ export default {
849 879
               this.addInfo.show = false;
850 880
               this.$Message.success(res.msg);
851 881
               this.searchList();
882
+              if (!form.classid) {
883
+                this.init();
884
+              }
852 885
             } else {
853 886
               this.$Message.error(res.msg);
854 887
             }

Chargement…
Annuler
Enregistrer