Jelajahi Sumber

角色修改

xjc 2 tahun lalu
induk
melakukan
cf01e7bd43
4 mengubah file dengan 29 tambahan dan 15 penghapusan
  1. 3 2
      src/api/role.js
  2. 5 1
      src/filters/index.js
  3. 19 10
      src/views/menu7/menu7-2/index.vue
  4. 2 2
      vue.config.js

+ 3 - 2
src/api/role.js

@@ -21,10 +21,11 @@ const roleApi = {
             method: 'get',
         })
     },
-    edit(id) {
+    edit(data) {
         return request({
-            url: `/v1/admin/role/${id}`,
+            url: `/v1/admin/role/${data.id}`,
             method: 'put',
+            data
         })
     },
     del(id) {

+ 5 - 1
src/filters/index.js

@@ -28,7 +28,11 @@ const platform = value => {
     return "用户账号";
   } else if (value === 'admin') {
     return "管理员账号";
-  } else {
+  }else if (value === 'teacher') {
+    return "教师账号";
+  } else if (value === 'student') {
+    return "学生账号";
+  }else {
     return value;
   }
 }

+ 19 - 10
src/views/menu7/menu7-2/index.vue

@@ -45,7 +45,7 @@
           <el-input v-model="form.name" placeholder="请输入角色名称"></el-input>
         </el-form-item>
 
-        <el-form-item label="角色权限">
+        <el-form-item label="角色权限" v-if="form.platform == 'admin'">
           <el-input
             placeholder="请选择"
             @focus="showPermission = true"
@@ -202,7 +202,9 @@ export default {
         case "handleDetail":
           roleApi.getDetail(row.id).then((res) => {
             this.form = res.data;
-            this.form.permission_codes = res.data.permission_codes.split(",");
+            this.form.permission_codes = res.data.permission_codes
+              ? res.data.permission_codes.split(",")
+              : [];
             this.dialogType = "edit";
             this.dialogConfig.title = "编辑角色";
             this.open("edit");
@@ -241,20 +243,27 @@ export default {
         this.$refs.dialogAdd.config.title = "新增角色";
       } else {
         this.$refs.dialogAdd.config.title = "编辑角色";
-        this.$nextTick(() => {
+        if(this.form.platform=="admin"){
+          this.$nextTick(() => {
           this.$refs.ptree.setCheckedKeys(this.form.permission_codes);
         });
+        }
       }
       this.$refs.dialogAdd.open((cancel) => {
         this.$refs["form"].validate((valid) => {
           if (valid) {
-            let selPer = this.$refs.ptree.getCheckedKeys();
-            let selNodes = [];
-            this.$refs.ptree.getCheckedNodes().forEach((item) => {
-              selNodes.push(item.name);
-            });
-            this.form.permission_codes = selPer.join(",");
-            this.form.permission_names = selNodes.join(",");
+            if (this.form.platform == "admin") {
+              let selPer = this.$refs.ptree.getCheckedKeys();
+              let selNodes = [];
+              this.$refs.ptree.getCheckedNodes().forEach((item) => {
+                selNodes.push(item.name);
+              });
+              this.form.permission_codes = selPer.join(",");
+              this.form.permission_names = selNodes.join(",");
+            }else{
+              this.form.permission_codes = "";
+              this.form.permission_names = "";
+            }
             if (type == "edit") {
               roleApi.edit(this.form).then((res) => {
                 if (res.mess == "success") {

+ 2 - 2
vue.config.js

@@ -29,8 +29,8 @@ module.exports = {
         /* 使用代理 */
         proxy: {
             "/": {
-                target: "http://47.108.130.28:8000",
-                // target: "http://192.168.117.131:8000",
+                // target: "http://47.108.130.28:8000",
+                target: "http://192.168.117.131:8000",
                 // target: "http://47.104.213.35",
                 changeOrigin: true,
                 // ws: true,//websocket支持