Browse Source

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

gzb
wangzhonglu 8 months ago
parent
commit
bbe7a7cd7a
1 changed files with 41 additions and 8 deletions
  1. 41
    8
      src/views/schoolSection/userManage/userManage.vue

+ 41
- 8
src/views/schoolSection/userManage/userManage.vue View File

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

Loading…
Cancel
Save