Browse Source

修改院管理员的权限

plg 6 months ago
parent
commit
fd6cc8b459
3 changed files with 186 additions and 64 deletions
  1. 90 38
      src/components/Register.vue
  2. 24 23
      src/components/manageRegister.vue
  3. 72 3
      src/views/manage/userManage.vue

+ 90 - 38
src/components/Register.vue

@@ -28,10 +28,25 @@
                 placeholder="请选择组织架构"
                 v-model="ruleForm.group"
                 :options="groupData"
-                
                 clearable
               ></el-cascader>
             </el-form-item>
+            <el-form-item label="所属届" prop="grade">
+              <el-select
+                v-model="ruleForm.grade"
+                clearable
+                placeholder="请选择所属届"
+                style="width: 100%"
+              >
+                <el-option
+                  v-for="item in gradeOption"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                >
+                </el-option>
+              </el-select>
+            </el-form-item>
             <el-form-item label="学号" prop="studentNumber">
               <el-input v-model="ruleForm.studentNumber"></el-input>
             </el-form-item>
@@ -116,6 +131,7 @@ export default {
       }
     };
     return {
+      gradeOption: [],
       userInfo: "",
       //编辑返回的值
       userDetailData: {},
@@ -145,6 +161,8 @@ export default {
       ruleForm: {
         //所属组织架构
         group: "",
+        //所属届数
+        grade: "",
         //学号
         studentNumber: "",
         //姓名
@@ -157,10 +175,11 @@ export default {
       },
       isView: true,
       rules: {
-        group: [{ required: true, message: "请选择组织架构", trigger: "blur" }],
+        group: [{ required: true, message: "请选择组织架构", trigger: "change" }],
         studentNumber: [{ required: true, message: "请输入学号", trigger: "blur" }],
         name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
         sex: [{ required: true, message: "请选择性别", trigger: "blur" }],
+        grade: [{ required: true, message: "请选择届数", trigger: "change" }],
         // password: [{ required: true, message: "请输密码", trigger: "blur" }],
         // password: [{ required: true, validator: validatePass, trigger: "blur" }],
         // comPassword: [{ required: true, validator: validateComPass, trigger: "blur" }],
@@ -172,9 +191,29 @@ export default {
     // this.ruleForm.type = "3";
   },
   methods: {
+    //获取当前届数
+    getGradeFun() {
+      this.gradeOption = [];
+      //获取当前届数
+      //获取当前年份
+      let date = new Date();
+      let currentYear = date.getFullYear();
+      let preYear = currentYear - 12;
+      let list = [];
+      for (let i = preYear; i < currentYear + 1; i++) {
+        //
+        let obj = {
+          value: i + "",
+          label: i + "届",
+        };
+        list.push(obj);
+      }
+      this.gradeOption = list.reverse();
+    },
     resetData() {
       this.$refs["ruleForm"].clearValidate();
       //清空表单
+      this.ruleForm.grade = "";
       this.ruleForm.group = "";
       this.ruleForm.name = "";
       this.ruleForm.studentNumber = "";
@@ -184,27 +223,33 @@ export default {
     },
     //获取组织架构方法--------------------开始-----------------------
     getChannel() {
-      this.$http.get(`/org/findAllOrgByPOrgNo?orgNo=${this.userInfo.orgNo}`, {}, (res) => {
-        //  this.$toast.success({message:'成功'});
-        if (res && res.code == 200) {
-          //将值赋值给list
-          if (res.data.length > 0) {
-            let resAdd = this.addPro(res.data);
-            this.ppData = JSON.parse(JSON.stringify(resAdd));
-            let forRes = this.arrToTree(resAdd);
-            // console.log('格式化的结构')
-            // console.log(forRes)
-            let resultRes = this.deleteChildren(forRes);
+      this.$http.get(
+        `/org/findAllOrgByPOrgNo?orgNo=${this.userInfo.orgNo}`,
+        {},
+        (res) => {
+          //  this.$toast.success({message:'成功'});
+          if (res && res.code == 200) {
+            //将值赋值给list
+            if (res.data.length > 0) {
+              let resAdd = this.addPro(res.data);
+              this.ppData = JSON.parse(JSON.stringify(resAdd));
+              let forRes = this.arrToTree(resAdd);
+              // console.log('格式化的结构')
+              // console.log(forRes)
+              let resultRes = this.deleteChildren(forRes);
 
-            this.groupData = resultRes[0].children;
+              this.groupData = resultRes[0].children;
+              console.log("groupData");
+              console.log(this.groupData);
+            } else {
+              this.groupData = [];
+            }
+            // this.channelList = res.data;
           } else {
-            this.groupData = [];
+            this.$message.error(res.msg);
           }
-          // this.channelList = res.data;
-        } else {
-          this.$message.error(res.msg);
         }
-      });
+      );
     },
     //z增加
     addPro(val) {
@@ -279,6 +324,7 @@ export default {
     },
     open(val) {
       this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
+      this.getGradeFun();
       this.cancle();
       this.getChannel();
       this.dialogVisible = true;
@@ -295,6 +341,7 @@ export default {
       this.getChannel();
       this.dialogVisible = true;
       this.isView = false;
+      this.getGradeFun();
       this.queryUserDetail(val.id);
       //调用查询详情的接口
     },
@@ -311,19 +358,19 @@ export default {
           let a = [];
 
           //当角色等于2时
-          if (this.userInfo.roleType == "2") {
-            //
+          // if (this.userInfo.roleType == "2") {
+          //   //
 
-            a.push(res.data.orgNo);
-          }
-          //当角色等于1时
-          if (this.userInfo.roleType == "3") {
-            for (let i = 0; i < res.data.orgList.length; i++) {
-              if (i < 2) {
-                a.push(res.data.orgList[i].orgNo);
-              }
-            }
-          }
+          //   a.push(res.data.orgNo);
+          // }
+          // //当角色等于1时
+          // if (this.userInfo.roleType == "3") {
+          //   for (let i = 0; i < res.data.orgList.length; i++) {
+          //     if (i < 2) {
+          //       a.push(res.data.orgList[i].orgNo);
+          //     }
+          //   }
+          // }
           // a.push(this.userInfo.orgNo);
           // a.push(res.data.orgNo);
           //判断用户登录类型
@@ -342,7 +389,9 @@ export default {
           //回显性别
           this.ruleForm.sex = res.data.gender;
           //
-          this.ruleForm.group = a.reverse();
+          this.ruleForm.group =[res.data.orgNo];
+          this.ruleForm.grade = res.data.grade;
+          // this.ruleForm.group = a.reverse();
         } else {
           // this.$toast.fail(res.msg);
           this.$message.error(res.msg);
@@ -352,6 +401,7 @@ export default {
     cancle() {
       this.$refs["ruleForm"].clearValidate();
       //清空表单
+      this.ruleForm.grade = "";
       this.ruleForm.group = "";
       this.ruleForm.name = "";
       this.ruleForm.studentNumber = "";
@@ -372,9 +422,9 @@ export default {
       this.disableFlag = true;
       let validSp = [];
       if (this.isView) {
-        validSp = ["group", "studentNumber", "name", "sex"];
+        validSp = ["group", "studentNumber", "name", "sex", "grade"];
       } else {
-        validSp = ["group", "studentNumber", "name", "sex"];
+        validSp = ["group", "studentNumber", "name", "sex", "grade"];
       }
       let aa = [];
       this.$refs["ruleForm"].validateField(validSp, (valid) => {
@@ -382,13 +432,13 @@ export default {
           aa.push(valid);
           //判断是编辑还是新增
           if (this.isView) {
-            if (aa.length == 4) {
+            if (aa.length == 5) {
               this.register();
             } else {
               this.disableFlagStatus();
             }
           } else {
-            if (aa.length == 4) {
+            if (aa.length == 5) {
               this.editUserFun();
             } else {
               this.disableFlagStatus();
@@ -418,6 +468,7 @@ export default {
       this.$http.post(
         `/user/addOrUpdateUser`,
         {
+          grade: this.ruleForm.grade,
           orgNo: this.ruleForm.group[this.ruleForm.group.length - 1],
           orgName: this.groupName,
           userNo: this.ruleForm.studentNumber,
@@ -449,6 +500,7 @@ export default {
       let that = this;
       this.queryOrgName();
       this.userDetailData.orgNo = this.ruleForm.group[this.ruleForm.group.length - 1];
+      this.userDetailData.grade = this.ruleForm.grade;
       this.userDetailData.orgName = this.groupName;
       this.userDetailData.userName = this.ruleForm.name;
       this.userDetailData.gender = this.ruleForm.sex;
@@ -481,8 +533,8 @@ export default {
 };
 </script>
 <style lang="less" scoped>
-.el-form-item{
- margin-bottom: 5px !important;
+.el-form-item {
+  margin-bottom: 5px !important;
 }
 .dig_update /deep/.el-cascader {
   position: relative;

+ 24 - 23
src/components/manageRegister.vue

@@ -7,7 +7,7 @@
         :close-on-click-modal="false"
         width="40%"
         style="border-radius: 40px"
-        top="5vh"
+        top="15vh"
       >
         <div slot="title">
           <el-form
@@ -68,7 +68,7 @@
               </el-col>
             </el-row>
 
-            <el-form-item v-if="isView" label="密码" prop="password">
+            <!-- <el-form-item v-if="isView" label="密码" prop="password">
               <el-input
                 type="password"
                 v-model="ruleForm.password"
@@ -81,7 +81,7 @@
                 v-model="ruleForm.comPassword"
                 autocomplete="off"
               ></el-input>
-            </el-form-item>
+            </el-form-item> -->
             <div class="dig_button">
               <el-button type="info" round @click="resetData()">重置</el-button>
               <!-- <el-button type="success" round @click="submitForm('ruleForm')"
@@ -171,19 +171,19 @@ export default {
         //性别
         sex: "",
         //密码
-        password: "",
-        comPassword: "",
+        // password: "",
+        // comPassword: "",
       },
       isView: true,
       rules: {
-        group: [{ required: true, message: "请选择组织架构", trigger: "blur" }],
+        group: [{ required: true, message: "请选择组织架构", trigger: "change" }],
         // grade: [{ required: true, message: "请选择管理班级", trigger: "blur" }],
         studentNumber: [{ required: true, message: "请输入账号", trigger: "blur" }],
         name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
         sex: [{ required: true, message: "请选择性别", trigger: "blur" }],
         // password: [{ required: true, message: "请输密码", trigger: "blur" }],
-        password: [{ required: true, validator: validatePass, trigger: "blur" }],
-        comPassword: [{ required: true, validator: validateComPass, trigger: "blur" }],
+        // password: [{ required: true, validator: validatePass, trigger: "blur" }],
+        // comPassword: [{ required: true, validator: validateComPass, trigger: "blur" }],
       },
     };
   },
@@ -202,8 +202,8 @@ export default {
       this.ruleForm.group = "";
       this.ruleForm.name = "";
       this.ruleForm.studentNumber = "";
-      this.ruleForm.password = "";
-      this.ruleForm.comPassword = "";
+      // this.ruleForm.password = "";
+      // this.ruleForm.comPassword = "";
       this.ruleForm.sex = "";
     },
     //获取组织架构方法--------------------开始-----------------------
@@ -350,8 +350,8 @@ export default {
       this.ruleForm.group = "";
       this.ruleForm.name = "";
       this.ruleForm.studentNumber = "";
-      this.ruleForm.password = "";
-      this.ruleForm.comPassword = "";
+      // this.ruleForm.password = "";
+      // this.ruleForm.comPassword = "";
       this.ruleForm.sex = "";
       this.dialogVisible = false;
     },
@@ -367,7 +367,7 @@ export default {
       this.disableFlag = true;
       let validSp = [];
       if (this.isView) {
-        validSp = ["group", "studentNumber", "name", "sex", "password", "comPassword"];
+        validSp = ["group", "studentNumber", "name", "sex"];
       } else {
         validSp = ["group", "studentNumber", "name", "sex"];
       }
@@ -377,7 +377,7 @@ export default {
           aa.push(valid);
           //判断是编辑还是新增
           if (this.isView) {
-            if (aa.length == 6) {
+            if (aa.length == 4) {
               this.register();
             } else {
               this.disableFlagStatus();
@@ -417,9 +417,9 @@ export default {
           userNo: this.ruleForm.studentNumber.trim(),
           userName: this.ruleForm.name,
           gender: this.ruleForm.sex,
-          password: md5(this.ruleForm.password),
+          // password: md5(this.ruleForm.password),
           //roleType     1普通用户    roleType   管理员
-          roleType: "2",
+          roleType: "4",
         },
         (res) => {
           this.disableFlagStatus();
@@ -442,13 +442,13 @@ export default {
     editUserFun() {
       let that = this;
       this.queryOrgName();
-      if (this.ruleForm.group.length != 2) {
-        this.$message({
-          message: "院管理员请选择二级组织架构",
-          type: "error",
-        });
-        return;
-      }
+      // if (this.ruleForm.group.length != 2) {
+      //   this.$message({
+      //     message: "院管理员请选择二级组织架构",
+      //     type: "error",
+      //   });
+      //   return;
+      // }
       this.userDetailData.orgNo = this.ruleForm.group[this.ruleForm.group.length - 1];
       this.userDetailData.orgName = this.groupName;
       this.userDetailData.userName = this.ruleForm.name;
@@ -525,6 +525,7 @@ export default {
 }
 
 .dig_button {
+  margin-top:20px;
   display: flex;
   width: 100%;
   justify-content: space-around;

+ 72 - 3
src/views/manage/userManage.vue

@@ -88,6 +88,8 @@
             :formatter="genderFun"
           >
           </el-table-column>
+          <el-table-column prop="grade" label="届数" align="center" width="" :formatter="gradeFormatter">
+          </el-table-column>
           <el-table-column prop="orgName" label="所属组织架构" align="center" width="">
           </el-table-column>
           <el-table-column label="操作" width="510px" align="center">
@@ -156,6 +158,12 @@
               {{ view.studentNumber }}
             </div>
           </div>
+          <div class="user_out">
+            <div class="user_out_sub">届数</div>
+            <div class="user_out_subNext">
+              {{ view.grade }}
+            </div>
+          </div>
           <div class="user_out">
             <div class="user_out_sub">性别</div>
             <div class="user_out_subNext">
@@ -214,14 +222,31 @@
             :options="groupData"
             clearable
           ></el-cascader>
+
+          <el-select
+            v-model="grade"
+            clearable
+            placeholder="请选择所属届"
+            style="width: 100%; margin-top: 20px"
+          >
+            <el-option
+              v-for="item in gradeOption"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
           <el-upload
             class="upload-demo"
-            style="margin-top: 40px"
+            style="margin-top: 20px"
             drag
             :before-upload="beforeUploadFun"
             :action="
-              basePath + `/user/userImport?orgNo=${groupLead[groupLead.length - 1]}`
+              basePath +
+              `/user/userImport?orgNo=${groupLead[groupLead.length - 1]}&roleType=1&grade=${grade}`
             "
+            :headers="headers"
             :on-success="fileSuccess"
             :on-error="fileError"
           >
@@ -237,7 +262,7 @@
               color: #409eff;
               cursor: pointer;
             "
-            :href="basePath + '/user/templateDownload'"
+            :href="basePath + '/user/templateDownload?roleType=1'"
           >
             下载模版
           </a>
@@ -321,14 +346,25 @@ export default {
         studentNumber: "",
         sex: "",
         orgName: "",
+        //当前学生的届数
+        grade:''
       },
       channel: "",
       channelList: [{ name: "渠道天成", id: "1" }],
+      headers: {},
+      grade: "",
+      gradeOption: [],
     };
   },
   created() {},
   mounted() {
     this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
+    this.headers = {
+      Authorization: oSessionStorage.getItem("token")
+        ? `Bearer ${oSessionStorage.getItem("token")}`
+        : "",
+    };
+    this.getGradeFun();
     console.log("this.userInfo");
     console.log(this.userInfo);
     this.getChannel();
@@ -339,6 +375,30 @@ export default {
     this.searchTarget();
   },
   methods: {
+    gradeFormatter(row){
+      //格式化当前届数
+      return row.grade+'届'
+
+    },
+    //获取当前届数
+    getGradeFun() {
+      this.gradeOption = [];
+      //获取当前届数
+      //获取当前年份
+      let date = new Date();
+      let currentYear = date.getFullYear();
+      let preYear = currentYear - 12;
+      let list = [];
+      for (let i = preYear; i < currentYear + 1; i++) {
+        //
+        let obj = {
+          value: i,
+          label: i + "届",
+        };
+        list.push(obj);
+      }
+      this.gradeOption = list.reverse();
+    },
     //文件上传之前
     beforeUploadFun(file) {
       //查询是否选择了组织架构
@@ -349,6 +409,14 @@ export default {
         });
         return false;
       }
+
+      if (this.grade == "") {
+        this.$message({
+          message: "请选择所属届",
+          type: "error",
+        });
+        return false;
+      }
     },
     //文件上传成功
     fileSuccess(res) {
@@ -490,6 +558,7 @@ export default {
       this.view.studentNumber = row.userNo;
       this.view.sex = row.gender == "0" ? "女" : "男";
       this.view.orgName = row.orgName;
+      this.view.grade=row.grade+'届'
       this.centerDialogVisible = true;
     },
     addUser() {