Prechádzať zdrojové kódy

权限相关界面和功能

刘洋 1 rok pred
rodič
commit
46429fba10

+ 4 - 4
src/assets/styles/base.scss

@@ -121,19 +121,19 @@ body {
 
 /* part */
 .part-box {
-  margin-bottom: 20px;
+  margin-bottom: 16px;
   background-color: $--color-white;
   // border-radius: 20px;
   border-radius: 8px;
-  padding: 30px;
+  padding: 16px;
 }
 .part-box-border {
   border: 1px solid $--color-border;
 }
 
 .el-form.part-filter-form {
-  padding: 20px 0 5px;
-
+  // padding: 20px 0 5px;
+  padding:5px 0 5px;
   /* element-ui*/
   .el-form-item {
     margin-bottom: 15px;

+ 2 - 1
src/assets/styles/element-variables.scss

@@ -6,7 +6,8 @@ For example, to overwrite the theme color:
 // $--color-primary: #705eff;
 $--color-primary: #6D5FF6;
 $--color-success: #1fb46f;
-$--color-danger: #ff7240;
+// $--color-danger: #ff7240;
+$--color-danger: #F56C6C;
 
 // $--border-radius-base: 10px;
 

+ 15 - 3
src/assets/styles/pages.scss

@@ -1127,11 +1127,11 @@
   align-items: stretch;
 
   .folder-list {
-    width: 380px;
+    width: 298px;
     margin-right: 20px;
     flex-grow: 0;
     flex-shrink: 0;
-    padding: 15px;
+    padding: 15px 12px;
     background-color: #fff;
     border-radius: 10px;
     overflow-x: hidden;
@@ -1144,12 +1144,24 @@
     border-radius: 10px;
     overflow-x: hidden;
     overflow-y: auto;
+    &>.el-table{
+      .cell{
+        .rich-text{
+          width:100%;
+          &>div{
+            overflow: hidden;
+            white-space: nowrap;
+            text-overflow: ellipsis;
+          }
+        }
+      }
+    }
   }
 }
 // folder-tree
 .folder-tree {
   .node-icon {
-    margin-right: 8px;
+    margin-right: 6px;
     width: 18px;
     height: 14px;
   }

+ 2 - 1
src/assets/styles/variables.scss

@@ -9,7 +9,8 @@ $--color-text-placeholder: #9a9dab !default;
 // $--color-primary: #705eff !default;
 $--color-primary: #6D5FF6 !default;
 $--color-success: #1fb46f !default;
-$--color-danger: #ff7240 !default;
+// $--color-danger: #ff7240 !default;
+$--color-danger: #F56C6C !default;
 $--color-warning-lighter: rgba(253, 203, 90, 1) !default;
 $--color-danger: rgba(254, 108, 105, 1) !default;
 $--color-info: #909399 !default;

+ 1 - 5
src/modules/card/views/CardManage.vue

@@ -292,11 +292,7 @@ export default {
       user: (state) => state.user,
     }),
     onlyAssignTeacher() {
-      return this.user.roleList.some(
-        (role) =>
-          role.roleCode == "ASSIGN_TEACHER" ||
-          role.roleCode == "SUBJECT_TEACHER"
-      );
+      return ["ASSIGN_TEACHER", "SUBJECT_TEACHER"].includes(this.user.role);
     },
   },
   mounted() {

+ 1 - 1
src/modules/paper-export/views/PaperTemplateManage.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="paper-template-manage">
     <div class="part-box">
-      <h2 class="part-box-title">试卷模板管理</h2>
+      <!-- <h2 class="part-box-title">试卷模板管理</h2> -->
       <!-- 搜索 -->
       <el-form class="part-filter-form" inline :model="searchForm">
         <el-form-item label="版头名称">

+ 1 - 1
src/modules/paper/views/AuditPaper.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="audit-paper">
     <div class="part-box">
-      <h2 class="part-box-title">试卷审核</h2>
+      <!-- <h2 class="part-box-title">试卷审核</h2> -->
       <el-tabs v-model="activeName" @tab-click="tabChange">
         <el-tab-pane label="待审核列表" name="wait" lazy>
           <audit-paper-wait ref="AuditPaperWait"></audit-paper-wait>

+ 64 - 52
src/modules/portal/views/home/HomeSide.vue

@@ -8,6 +8,32 @@
     </div>
     <div class="menu-wrap">
       <el-menu
+        class="el-menu-vertical-demo"
+        active-text-color="#705eff"
+        text-color="#383b4a"
+        router
+        :default-active="defaultActiveCode"
+      >
+        <el-submenu
+          v-for="(menu1, index) in menuList"
+          :key="menu1.code"
+          :index="menu1.code"
+        >
+          <template slot="title">
+            <i :class="'icon icon-' + MENU_ICONS[index]"></i>
+            <span>{{ menu1.name }}</span>
+          </template>
+          <el-menu-item
+            v-for="menu2 in menu1.subRolePrivilege"
+            :key="menu2.code"
+            :index="menu2.code"
+            :route="{ path: menu2.privilegeUri }"
+          >
+            <span style="margin-left: 9px">{{ menu2.name }}</span>
+          </el-menu-item>
+        </el-submenu>
+      </el-menu>
+      <!-- <el-menu
         v-if="menuList.length > 0"
         class="el-menu-vertical-demo"
         active-text-color="#705eff"
@@ -21,7 +47,6 @@
           :index="menu1.nodeCode"
         >
           <template slot="title">
-            <!-- <i class="el-icon-menu"></i> <span>{{ menu1.name }}</span> -->
             <i :class="menu1.icon" style="color: red"></i>
             <span>{{ menu1.name }}</span>
           </template>
@@ -35,7 +60,7 @@
             <span style="margin-left: 9px">{{ menu2.name }}</span>
           </el-menu-item>
         </el-submenu>
-      </el-menu>
+      </el-menu> -->
     </div>
 
     <el-menu
@@ -61,20 +86,6 @@
         <span> 回收站 </span>
       </el-menu-item>
     </el-menu>
-    <!-- <ul class="other-menus">
-      <li class="el-menu-item">
-        <i class="icon icon-safe"></i>
-        <span>安全设置</span>
-      </li>
-      <li class="el-menu-item">
-        <i class="icon icon-fast"></i>
-        <span>快捷路径</span>
-      </li>
-      <li class="el-menu-item red" @click="toPage('/questions/recycle')">
-        <i class="el-icon-delete" style="font-size: 16px"></i>
-        <span>回收站</span>
-      </li>
-    </ul> -->
   </div>
 </template>
 
@@ -123,14 +134,14 @@ const routesToMenu = [
     groupCode: "REPORTS_MENUS",
   },
 ];
-const MENU_ICONS = {
-  base_info: "base",
-  course_manage: "course",
-  structure_manage: "create-paper",
-  question_bank: "question-book",
-  paper_manage: "paper-book",
-  ques_manage: "question",
-};
+// const MENU_ICONS = {
+//   base_info: "base",
+//   course_manage: "course",
+//   structure_manage: "create-paper",
+//   question_bank: "question-book",
+//   paper_manage: "paper-book",
+//   ques_manage: "question",
+// };
 
 import { mapMutations } from "vuex";
 import { UPDATE_CURRENT_PATHS } from "../../store/currentPaths";
@@ -146,27 +157,26 @@ export default {
       menuList: [],
       curRoutePath: "",
       isCollapse: false,
+      MENU_ICONS: ["base", "course", "question-book", "paper-book"],
+      defaultActiveCode: "base_info",
+      menuKey: Math.random() + "",
     };
   },
   computed: {
     ...mapState({ user: (state) => state.user }),
-    menuList1() {
-      return this.menuList
-        .filter((m) => m.parentId === null && m.ext1 === "menu")
-        .map((m) => {
-          m.icon = `icon icon-${MENU_ICONS[m.code]}`;
-          return m;
-        });
-    },
   },
   watch: {
     $route() {
       this.updatePath();
     },
+    menuList() {
+      this.updatePath();
+    },
   },
   async created() {
     this.group = routesToMenu.find((v) => this.$route.path.startsWith(v.path));
     this.menuList = await this.getUserPrivileges();
+    console.log("menuList", this.menuList);
     this.UPDATE_MENU_LIST(this.menuList);
     this.updatePath();
   },
@@ -188,11 +198,6 @@ export default {
 
       return res.data;
     },
-    menuList2(menu1) {
-      return this.menuList.filter(
-        (m) => m.parentId === menu1.id && m.ext1 === "menu"
-      );
-    },
     updatePath() {
       // console.log("home update");
       let curRoutePath = this.$route.path;
@@ -200,23 +205,30 @@ export default {
         curRoutePath = curRoutePath.slice(0, -2) + "/0";
       }
       this.curRoutePath = curRoutePath;
-      let currentPaths = [];
-      let part = this.menuList.find((v) => v.ext5 === curRoutePath);
-
-      if (!part) {
-        this.UPDATE_CURRENT_PATHS(
-          [localMenusConfig[this.$route.name]].filter(Boolean)
-        );
-        return;
+      let arr = [];
+      loop: for (let i = 0; i < this.menuList.length; i++) {
+        arr = [];
+        let item = this.menuList[i];
+        if (item.privilegeUri == curRoutePath) {
+          arr.push(item.name);
+          this.menuKey = Math.random() + "";
+          break;
+        } else {
+          let sub = item.subRolePrivilege.find(
+            (v) => v.privilegeUri == curRoutePath
+          );
+          if (sub) {
+            arr.push(item.name, sub.name);
+            this.defaultActiveCode = sub.code;
+            this.menuKey = Math.random() + "";
+            break loop;
+          }
+        }
       }
-      currentPaths.unshift(part.name);
-      while (this.menuList.find((v) => v.id === part.parentId)) {
-        part = this.menuList.find((v) => v.id === part.parentId);
-        currentPaths.unshift(part.name);
+      if (!arr.length) {
+        arr = [localMenusConfig[this.$route.name]].filter(Boolean);
       }
-      // console.log(currentPaths);
-      this.UPDATE_CURRENT_PATHS(currentPaths);
-      console.log("currentPaths", currentPaths);
+      this.UPDATE_CURRENT_PATHS(arr);
     },
   },
 };

+ 3 - 0
src/modules/portal/views/home/LinkTitles.vue

@@ -26,5 +26,8 @@ export default {
   computed: {
     ...mapState(["currentPaths"]),
   },
+  mounted() {
+    console.log(this.$route);
+  },
 };
 </script>

+ 4 - 1
src/modules/question/components/QuestionFolder.vue

@@ -63,6 +63,7 @@
           >
             <el-form-item prop="name">
               <el-input
+                style="width: 125px"
                 v-model="modalForm.name"
                 placeholder="请输入文件夹名称"
                 clearable
@@ -70,10 +71,11 @@
             </el-form-item>
             <el-form-item>
               <el-button
-                type="primary"
+                type="success"
                 icon="el-icon-check"
                 :disabled="loading"
                 @click="toModifyFolder"
+                circle
               ></el-button>
               <!-- 新增的时候可以删除临时文件 -->
               <el-button
@@ -82,6 +84,7 @@
                 :disabled="loading"
                 style="margin-left: 6px"
                 @click="toRemoveFolder(node, data)"
+                circle
               ></el-button>
             </el-form-item>
           </el-form>

+ 1 - 1
src/modules/question/views/QuestionAudit.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="question-audit">
     <div class="part-box">
-      <h2 class="part-box-title">试题审核</h2>
+      <!-- <h2 class="part-box-title">试题审核</h2> -->
       <el-tabs v-model="activeName" @tab-click="tabChange">
         <el-tab-pane label="待审核列表" name="wait" lazy>
           <audit-question-wait ref="AuditQuestionWait"></audit-question-wait>

+ 2 - 2
src/modules/question/views/QuestionManage.vue

@@ -2,7 +2,7 @@
   <div class="content question-manage">
     <!-- 正文信息 -->
     <div class="part-box">
-      <h2 class="part-box-title">题库列表</h2>
+      <!-- <h2 class="part-box-title">题库列表</h2> -->
 
       <el-form class="part-filter-form" :inline="true" :model="filter">
         <el-form-item label="课程名称">
@@ -158,7 +158,7 @@
             width="50"
             align="center"
           ></el-table-column>
-          <el-table-column label="题干" min-width="200">
+          <el-table-column label="题干" min-width="200" show-overflow-tooltip>
             <div slot-scope="scope" @click="toViewQuestion(scope.row)">
               <rich-text
                 class="row-question-body"

+ 1 - 1
src/modules/questions/views/CheckDuplicateList.vue

@@ -2,7 +2,7 @@
   <section class="content">
     <!-- 正文信息 -->
     <div class="part-box">
-      <h2 class="part-box-title">题库查重</h2>
+      <!-- <h2 class="part-box-title">题库查重</h2> -->
 
       <el-form class="part-filter-form" :inline="true" :model="formSearch">
         <el-form-item label="课程名称">

+ 0 - 2
src/modules/questions/views/Course.vue

@@ -1,8 +1,6 @@
 <template>
   <section element-loading-text="请稍后..." class="content">
     <div class="part-box">
-      <h2 class="part-box-title">课程列表</h2>
-
       <el-form
         ref="primaryForm"
         class="part-filter-form"

+ 1 - 3
src/modules/questions/views/ExportTemplate.vue

@@ -1,8 +1,6 @@
 <template>
   <section class="content">
     <div class="part-box">
-      <h2 class="part-box-title">模板管理</h2>
-
       <!-- 表单 -->
       <el-form class="part-filter-form" inline :model="formSearch">
         <el-form-item v-if="isSuperAdmin" label="学校">
@@ -299,7 +297,7 @@ export default {
   computed: {
     ...mapState({ user: (state) => state.user }),
     isSuperAdmin() {
-      return this.user.roleList.some((role) => role.roleCode == "SUPER_ADMIN");
+      return this.user.role === "SUPER_ADMIN";
     },
   },
   watch: {

+ 1 - 1
src/modules/questions/views/GenPaper.vue

@@ -1,7 +1,7 @@
 <template>
   <section class="content gen-paper">
     <div class="part-box">
-      <h2 class="part-box-title">卷库列表</h2>
+      <!-- <h2 class="part-box-title">卷库列表</h2> -->
 
       <el-form class="part-filter-form" :inline="true" :model="formSearch">
         <el-form-item label="课程名称">

+ 169 - 13
src/modules/questions/views/OrgProperty.vue

@@ -210,7 +210,7 @@
       </el-form>
 
       <!-- 组卷配置 -->
-      <el-form v-if="activeName === 'tab4'" label-width="120px">
+      <!-- <el-form v-if="activeName === 'tab4'" label-width="120px">
         <el-form-item label="综合组卷">
           <el-radio-group v-model="form.properties.PAPER_BUILD_SYNTHESIS">
             <el-radio label="true">开启</el-radio>
@@ -220,7 +220,42 @@
             *开启跨课程组卷模式,支持将多个课程试题组到一份试卷下
           </div>
         </el-form-item>
-      </el-form>
+      </el-form> -->
+      <div v-show="activeName === 'tab4'">
+        <el-form label-width="60px" inline>
+          <el-form-item label="角色">
+            <el-select v-model="roleCode" placeholder="请选择">
+              <el-option
+                v-for="item in roleList"
+                :key="item.id"
+                :label="item.name"
+                :value="item.code"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" @click="searchTree"> 查询 </el-button>
+          </el-form-item>
+        </el-form>
+        <div class="part-box tree-box">
+          <el-tree
+            ref="authTree"
+            :data="treeData"
+            show-checkbox
+            node-key="code"
+            :props="defaultTreeProps"
+            @check-change="treeCheckChange"
+            @check="tab4Entered = true"
+          >
+            <span class="custom-tree-node" slot-scope="{ node, data }">
+              <span>{{ node.label }}</span>
+              <span v-if="data.privilegeType == 'BUTTON'" class="is-btn">
+                按钮
+              </span>
+            </span>
+          </el-tree>
+        </div>
+      </div>
 
       <!-- AI命题 -->
       <el-form v-if="activeName === 'tab5'" size="small" label-width="120px">
@@ -307,6 +342,8 @@ export default {
   name: "OrgProperty",
   data() {
     return {
+      tab4Entered: false,
+      treeCheckedCodes: [],
       style: {
         label_width_tab1: "120px",
         label_width_tab2: "120px",
@@ -325,15 +362,19 @@ export default {
           name: "查重配置",
           val: "tab3",
         },
+        // {
+        //   name: "组卷配置",
+        //   val: "tab4",
+        // },
         {
-          name: "组卷配置",
+          name: "角色管理",
           val: "tab4",
         },
         {
           name: "AI命题",
           val: "tab5",
         },
-        { name: "组卷置", val: "tab6" },
+        { name: "组卷置", val: "tab6" },
       ],
       activeName: "tab2",
       rootOrgName: "",
@@ -359,7 +400,7 @@ export default {
           OPTION_DUPLICATE_THRESHOLD: 94,
           CHECK_DUPLICATE_COUNT: 5,
           // 综合组卷
-          PAPER_BUILD_SYNTHESIS: "false",
+          // PAPER_BUILD_SYNTHESIS: "false",
           // AI命题
           AI_QUESTION_REMAINDER: 0,
           USE_AI_QUESTION: "false",
@@ -368,6 +409,8 @@ export default {
           GEN_PAPER_QUESTION_COUNT: "",
         },
       },
+      roleCode: "",
+      roleList: [],
       rules: {
         // code: [{ required: true, validator: validateCode, trigger: "blur" }],
       },
@@ -376,6 +419,11 @@ export default {
       tradeOptions: [10000, 20000, 50000],
       tradeList: [],
       loading: false,
+      defaultTreeProps: {
+        label: "name",
+        children: "subRolePrivilege",
+      },
+      treeData: [],
     };
   },
   computed: {
@@ -443,6 +491,17 @@ export default {
         }
       });
     },
+    getRoleList() {
+      this.$httpWithMsg
+        .post(QUESTION_API + "/rolePrivilege/getRoles")
+        .then((res) => {
+          this.roleList = res.data;
+          if (res.data?.length) {
+            this.roleCode = res.data[0].code;
+          }
+        });
+    },
+    searchTree() {},
     setParams() {
       for (let i of this.form.properties.ROOT_ORG_QUESTION_TYPES1) {
         this.form.properties.ROOT_ORG_QUESTION_TYPES.push(i);
@@ -477,7 +536,7 @@ export default {
         );
       }
     },
-    save() {
+    async save() {
       // this.setParams();
       let url = QUESTION_API + "/org/saveOrgProperties";
       let GEN_PAPER_QUESTION_START = this.form.properties.timeRange[0];
@@ -490,14 +549,24 @@ export default {
           GEN_PAPER_QUESTION_END,
         },
       };
-      // this.$httpWithMsg.put(url, this.form).then(() => {
-      this.$httpWithMsg.put(url, params).then(() => {
-        this.$notify({
-          type: "success",
-          message: "保存成功!",
-        });
-        this.back();
+      let res = await this.$httpWithMsg.put(url, params).catch(() => {});
+      if (!res) return;
+      if (this.tab4Entered) {
+        let res2 = await this.$httpWithMsg
+          .post(QUESTION_API + "/rolePrivilege/savePrivilege", {
+            privileges: this.treeCheckedCodes,
+            rootOrgId: this.form.orgId,
+            role: this.roleCode,
+          })
+          .catch(() => {});
+        if (!res2) return;
+      }
+
+      this.$notify({
+        type: "success",
+        message: "保存成功!",
       });
+      this.back();
     },
     async getTradeList() {
       const res = await orgAiTransactionListApi(this.form.orgId);
@@ -531,6 +600,93 @@ export default {
     back() {
       this.$router.push({ path: "/questions/school" });
     },
+    treeCheckChange(curNode, isChecked) {
+      let keys = this.$refs.authTree.getCheckedKeys(true);
+      if (curNode.privilegeType === "BUTTON" && isChecked) {
+        keys = Array.from(new Set([...keys, curNode.mountPageCode]));
+        this.$refs.authTree.setCheckedKeys(keys);
+      }
+      // this.treeCheckedCodes = [...keys].filter(
+      //   (key) => !key.endsWith("__page")
+      // );
+      this.$nextTick(() => {
+        let nodes = this.$refs.authTree.getCheckedNodes(false, true);
+        this.treeCheckedCodes = nodes
+          .map((item) => item.code)
+          .filter((key) => !key.endsWith("__page"));
+      });
+    },
+  },
+  watch: {
+    activeName(val) {
+      if (val === "tab4" && !this.tab4Entered) {
+        this.$nextTick(() => {
+          this.getRoleList();
+        });
+      }
+    },
+    roleCode(val) {
+      this.$httpWithMsg
+        .post(
+          QUESTION_API +
+            `/rolePrivilege/getRolePrivileges?roleCode=${val}&rootOrgId=${this.form.orgId}`
+        )
+        .then((res) => {
+          let checkedLeafCodes = [];
+          res.data.forEach((level1) => {
+            if (level1.subRolePrivilege?.length) {
+              level1.subRolePrivilege = level1.subRolePrivilege.map(
+                (level2) => {
+                  if (level2.subRolePrivilege?.length) {
+                    level2.subRolePrivilege = level2.subRolePrivilege.map(
+                      (v) => {
+                        v.mountPageCode = level2.code + "__page";
+                        v.enable && checkedLeafCodes.push(v.code);
+                        return v;
+                      }
+                    );
+                    level2.subRolePrivilege.unshift({
+                      code: level2.code + "__page",
+                      enable: level2.enable,
+                      name: "页面",
+                      privilegeType: "PAGE",
+                    });
+                    checkedLeafCodes.push(level2.code + "__page");
+                  } else {
+                    level2.enable && checkedLeafCodes.push(level2.code);
+                  }
+                  return level2;
+                }
+              );
+            } else {
+              level1.enable && checkedLeafCodes.push(level1.code);
+            }
+          });
+          this.treeData = res.data;
+          //初始化选中状态,使用叶子节点的enable进行设置
+          this.$refs.authTree.setCheckedKeys(checkedLeafCodes);
+        });
+    },
   },
 };
 </script>
+<style lang="scss" scoped>
+.org-property {
+  .tree-box {
+    :deep(.custom-tree-node) {
+      .is-page,
+      .is-btn {
+        padding: 3px 5px;
+        font-size: 10px;
+        border-radius: 4px;
+        background: #67c23a;
+        color: #fff;
+        margin-left: 8px;
+        vertical-align: middle;
+        position: relative;
+        top: -2px;
+      }
+    }
+  }
+}
+</style>

+ 1 - 1
src/modules/questions/views/SynthesisPaperStorage.vue

@@ -1,7 +1,7 @@
 <template>
   <section class="content">
     <div class="part-box">
-      <h2 class="part-box-title">综合卷列表</h2>
+      <!-- <h2 class="part-box-title">综合卷列表</h2> -->
 
       <el-form class="part-filter-form" :inline="true" :model="formSearch">
         <el-form-item label="课程名称">

+ 18 - 18
src/modules/questions/views/data_previllege.vue

@@ -159,15 +159,15 @@ export default {
   },
   async created() {
     await this.initPrivileges();
-    if (!this.rolePrivileges.user_data_rule_setting) {
-      this.$alert("没有权限访问!", "提示", {
-        confirmButtonText: "确定",
-        callback: () => {
-          this.back();
-        },
-      });
-      return;
-    }
+    // if (!this.rolePrivileges.user_data_rule_setting) {
+    //   this.$alert("没有权限访问!", "提示", {
+    //     confirmButtonText: "确定",
+    //     callback: () => {
+    //       this.back();
+    //     },
+    //   });
+    //   return;
+    // }
 
     this.form.userId = this.$route.params.userId;
     this.form.rootOrgId = this.$route.params.rootOrgId;
@@ -316,15 +316,15 @@ export default {
       this.$refs.addCourseDialog.openDialog();
     },
     async initPrivileges() {
-      let params = new URLSearchParams();
-      params.append(
-        "privilegeCodes",
-        Object.keys(this.rolePrivileges).toString()
-      );
-      var url = QUESTION_API + "/rolePrivilege/checkPrivileges?" + params;
-      await this.$httpWithMsg.post(url).then((response) => {
-        this.rolePrivileges = response.data;
-      });
+      // let params = new URLSearchParams();
+      // params.append(
+      //   "privilegeCodes",
+      //   Object.keys(this.rolePrivileges).toString()
+      // );
+      // var url = QUESTION_API + "/rolePrivilege/checkPrivileges?" + params;
+      // await this.$httpWithMsg.post(url).then((response) => {
+      //   this.rolePrivileges = response.data;
+      // });
     },
   },
 };

+ 78 - 98
src/modules/questions/views/user.vue

@@ -5,7 +5,6 @@
     element-loading-text="请稍后..."
   >
     <div class="part-box">
-      <h2 class="part-box-title">用户管理</h2>
       <!-- 搜索 -->
       <el-form class="part-filter-form" inline :model="searchForm">
         <el-form-item v-if="isSuperAdmin" label="学校">
@@ -25,12 +24,16 @@
           </el-select>
         </el-form-item>
         <el-form-item v-if="!onlySubjectTeacher" label="角色">
-          <el-select v-model="searchForm.roleId" clearable placeholder="请选择">
+          <el-select
+            v-model="searchForm.roleCode"
+            clearable
+            placeholder="请选择"
+          >
             <el-option
               v-for="item in roleList4Search"
-              :key="item.roleId"
-              :label="item.roleName"
-              :value="item.roleId"
+              :key="item.id"
+              :label="item.name"
+              :value="item.code"
             />
           </el-select>
         </el-form-item>
@@ -339,18 +342,18 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="角色" prop="roleId">
+        <el-form-item label="角色" prop="role">
           <el-select
-            v-model="userForm.roleId"
+            v-model="userForm.role"
             class="dialog-input-width"
             placeholder="请选择"
           >
             <el-option
               v-for="item in roleList4InsertOrUpdateWithoutSuperAdmin"
-              :key="item.roleId"
-              :label="item.roleName"
-              :value="item.roleId"
-              :disabled="roleDis(item.roleCode)"
+              :key="item.id"
+              :label="item.name"
+              :value="item.code"
+              :disabled="roleDis(item.code)"
             >
             </el-option>
           </el-select>
@@ -431,19 +434,19 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="角色" prop="roleId">
+        <el-form-item label="角色" prop="role">
           <el-select
-            v-model="userForm.roleId"
+            v-model="userForm.role"
             class="dialog-input-width"
             placeholder="请选择"
             :disabled="rowIsSuperAdmin"
           >
             <el-option
-              v-for="item in roleList4InsertOrUpdate"
-              :key="item.roleId"
-              :label="item.roleName"
-              :disabled="roleDis(item.roleCode)"
-              :value="item.roleId"
+              v-for="item in roleList4InsertOrUpdateWithoutSuperAdmin"
+              :key="item.id"
+              :label="item.name"
+              :value="item.code"
+              :disabled="roleDis(item.code)"
             >
             </el-option>
           </el-select>
@@ -529,7 +532,8 @@ export default {
       loading: false,
       orgLoading4InsertOrUpdate: false,
       roleList4Search: [],
-      roleList4InsertOrUpdate: [],
+      roleList4InsertOrUpdateWithoutSuperAdmin: [],
+      // roleList4InsertOrUpdate: [],
       rootOrgList: [],
       orgList4InsertOrUpdate: [],
       searchForm: {
@@ -538,7 +542,7 @@ export default {
         loginName: "",
         enable: "",
         rootOrgId: "",
-        roleId: "",
+        roleCode: "",
       },
       userForm: {
         id: null,
@@ -549,7 +553,7 @@ export default {
         enable: true,
         rootOrgId: null,
         orgId: null,
-        roleId: null,
+        role: null,
       },
       enableStr: "true",
 
@@ -619,7 +623,7 @@ export default {
           },
         ],
         orgId: [],
-        roleId: [
+        roleCode: [
           {
             required: true,
             validator: validateRoles,
@@ -648,32 +652,26 @@ export default {
     noBatchSelected() {
       return this.selectedUserIds.length === 0;
     },
-    roleList4InsertOrUpdateWithoutSuperAdmin() {
-      return this.roleList4InsertOrUpdate.filter(
-        (item) => item.roleCode != "SUPER_ADMIN"
-      );
-    },
+    // roleList4InsertOrUpdateWithoutSuperAdmin() {
+    //   return this.roleList4InsertOrUpdate.filter(
+    //     (item) => item.roleCode != "SUPER_ADMIN"
+    //   );
+    // },
     isSubjectTeacher() {
-      return this.user.roleList.some(
-        (role) => role.roleCode == "SUBJECT_TEACHER"
-      );
+      return this.user.role === "SUBJECT_TEACHER";
     },
     onlySubjectTeacher() {
       if (this.isAdmin) {
         return false;
       } else {
-        return this.user.roleList.some(
-          (role) => role.roleCode == "SUBJECT_TEACHER"
-        );
+        return this.user.role === "SUBJECT_TEACHER";
       }
     },
     isSuperAdmin() {
-      return this.user.roleList.some((role) => role.roleCode == "SUPER_ADMIN");
+      return this.user.role === "SUPER_ADMIN";
     },
     isAdmin() {
-      return this.user.roleList.some(
-        (role) => role.roleCode == "SUPER_ADMIN" || role.roleCode == "ADMIN"
-      );
+      return this.user.role === "SUPER_ADMIN" || this.user.role === "ADMIN";
     },
     rootSchoolSelect() {
       let rootSchools = [];
@@ -694,11 +692,12 @@ export default {
   },
   methods: {
     roleDis(code) {
-      if (this.onlySubjectTeacher && code != "ASSIGN_TEACHER") {
-        return true;
-      } else {
-        return false;
-      }
+      // if (this.onlySubjectTeacher && code != "ASSIGN_TEACHER") {
+      //   return true;
+      // } else {
+      //   return false;
+      // }
+      return this.onlySubjectTeacher && code != "ASSIGN_TEACHER";
     },
     //导入
     importUser() {
@@ -728,7 +727,7 @@ export default {
     },
     resetEcsFormSearch() {
       this.searchForm = Object.assign(this.searchForm, {
-        roleId: "",
+        roleCode: "",
         courseId: "",
         loginName: "",
         name: "",
@@ -748,26 +747,25 @@ export default {
       }
     },
     rootOrgChanged4Search() {
-      var url =
-        QUESTION_API +
-        "/rolePrivilege/getRoles?includeSuperAdmin=" +
-        true +
-        "&rootOrgId=" +
-        this.searchForm.rootOrgId;
-      this.$httpWithMsg.post(url).then((response) => {
-        this.roleList4Search = response.data;
-      });
+      // var url =
+      //   QUESTION_API +
+      //   "/rolePrivilege/getRoles?includeSuperAdmin=" +
+      //   true +
+      //   "&rootOrgId=" +
+      //   this.searchForm.rootOrgId;
+      // this.$httpWithMsg.post(url).then((response) => {
+      //   this.roleList4Search = response.data;
+      // });
     },
     rootOrgChanged4InsertOrUpdate() {
-      this.orgList4InsertOrUpdate = [];
-
-      var url =
-        QUESTION_API +
-        "/rolePrivilege/getRoles?rootOrgId=" +
-        this.userForm.rootOrgId;
-      this.$httpWithMsg.post(url).then((response) => {
-        this.roleList4InsertOrUpdate = response.data;
-      });
+      // this.orgList4InsertOrUpdate = [];
+      // var url =
+      //   QUESTION_API +
+      //   "/rolePrivilege/getRoles?rootOrgId=" +
+      //   this.userForm.rootOrgId;
+      // this.$httpWithMsg.post(url).then((response) => {
+      //   this.roleList4InsertOrUpdate = response.data;
+      // });
     },
     getOrgList4InsertOrUpdate(query) {
       this.orgLoading4InsertOrUpdate = true;
@@ -860,7 +858,7 @@ export default {
       this.userForm.loginName = "";
       this.userForm.password = "";
       this.userForm.phoneNumber = "";
-      this.userForm.roleId = null;
+      this.userForm.role = null;
       this.userForm.orgId = null;
       this.enableStr = "true";
       this.orgList4InsertOrUpdate = [];
@@ -876,7 +874,7 @@ export default {
 
       this.updateDialog = true;
       this.userForm.id = row.id;
-      this.userForm.roleId = row.roleIds[0];
+      this.userForm.role = row.role;
       this.userForm.name = row.name;
       this.userForm.loginName = row.loginName;
       this.enableStr = row.enable ? "true" : "false";
@@ -1097,18 +1095,18 @@ export default {
       this.userForm.rootOrgId = this.user.rootOrgId;
 
       var url1 = QUESTION_API + "/org/getRootOrgList";
-      var url2 =
-        QUESTION_API +
-        "/rolePrivilege/getRoles?includeSuperAdmin=true&rootOrgId=" +
-        this.user.rootOrgId;
+      var url2 = QUESTION_API + "/rolePrivilege/getRoles?all=true";
+      var url3 = QUESTION_API + "/rolePrivilege/getRoles";
 
       Promise.all([
         this.$httpWithMsg.get(url1),
         this.$httpWithMsg.post(url2),
-      ]).then(([resp1, resp2]) => {
+        this.$httpWithMsg.post(url3),
+      ]).then(([resp1, resp2, resp3]) => {
         this.rootOrgList = resp1.data;
         this.roleList4Search = resp2.data;
-        this.roleList4InsertOrUpdate = resp2.data;
+        // this.roleList4InsertOrUpdate = resp2.data;
+        this.roleList4InsertOrUpdateWithoutSuperAdmin = resp3.data;
 
         const cacheInfo = window.sessionStorage.getItem("userPageCache");
         if (cacheInfo) {
@@ -1124,40 +1122,22 @@ export default {
       });
     },
     initPrivileges() {
-      let params = new URLSearchParams();
-      params.append(
-        "privilegeCodes",
-        Object.keys(this.rolePrivileges).toString()
-      );
-      var url = QUESTION_API + "/rolePrivilege/checkPrivileges?" + params;
-      this.$httpWithMsg.post(url).then((response) => {
-        this.rolePrivileges = response.data;
-      });
+      // let params = new URLSearchParams();
+      // params.append(
+      //   "privilegeCodes",
+      //   Object.keys(this.rolePrivileges).toString()
+      // );
+      // var url = QUESTION_API + "/rolePrivilege/checkPrivileges?" + params;
+      // this.$httpWithMsg.post(url).then((response) => {
+      //   this.rolePrivileges = response.data;
+      // });
       this.getCourses4Search("");
     },
     showUserDataRuleSetting(row) {
-      let roleCodes = row.roleCodes;
-
-      for (let n = 0; n < roleCodes.length; n++) {
-        let roleCode = roleCodes[n];
-        if (roleCode == "SUPER_ADMIN" || roleCode == "ADMIN") {
-          return false;
-        }
-      }
-
-      return true;
+      return !["SUPER_ADMIN", "ADMIN"].includes(row.role);
     },
     showBtn(row) {
-      let roleCodes = row.roleCodes;
-
-      for (let n = 0; n < roleCodes.length; n++) {
-        let roleCode = roleCodes[n];
-        if (roleCode == "SUPER_ADMIN") {
-          return false;
-        }
-      }
-
-      return true;
+      return !["SUPER_ADMIN"].includes(row.role);
     },
   },
 };

+ 2 - 2
src/modules/statistics/views/StatisticsManage.vue

@@ -2,7 +2,7 @@
   <div class="content statistics-manage">
     <!-- 正文信息 -->
     <div class="part-box">
-      <h1 class="part-box-title">统计管理</h1>
+      <!-- <h1 class="part-box-title">统计管理</h1> -->
       <!-- 搜索 -->
       <el-form class="part-filter-form" inline :model="searchForm">
         <el-form-item label="课程">
@@ -43,7 +43,7 @@
           </el-button>
         </el-form-item>
       </el-form>
-      <div class="part-box-action"></div>
+      <!-- <div class="part-box-action"></div> -->
     </div>
     <div class="part-box">
       <el-table ref="table" :data="tableData" resizable>

+ 18 - 17
src/router/index.js

@@ -1,6 +1,6 @@
 import Vue from "vue";
 import Router from "vue-router";
-import { QUESTION_API } from "@/constants/constants.js";
+// import { QUESTION_API } from "@/constants/constants.js";
 import Home from "../modules/portal/views/home/Home.vue";
 import portalRoutes from "../modules/portal/routes/routes";
 import {
@@ -64,22 +64,23 @@ router.beforeEach((to, from, next) => {
     next();
     return;
   }
-  if (!to.meta.privilegeCodes) {
-    next();
-  } else {
-    let params = new URLSearchParams();
-    params.append("privilegeCodes", to.meta.privilegeCodes);
-    Vue.prototype.$httpWithMsg
-      .post(QUESTION_API + "/rolePrivilege/checkPrivileges?" + params)
-      .then((response) => {
-        if (Object.values(response.data).includes(true)) {
-          next();
-        } else {
-          Vue.prototype.$alert("没有权限访问!", "提示");
-          next(false);
-        }
-      });
-  }
+  next();
+  // if (!to.meta.privilegeCodes) {
+  //   next();
+  // } else {
+  //   let params = new URLSearchParams();
+  //   params.append("privilegeCodes", to.meta.privilegeCodes);
+  //   Vue.prototype.$httpWithMsg
+  //     .post(QUESTION_API + "/rolePrivilege/checkPrivileges?" + params)
+  //     .then((response) => {
+  //       if (Object.values(response.data).includes(true)) {
+  //         next();
+  //       } else {
+  //         Vue.prototype.$alert("没有权限访问!", "提示");
+  //         next(false);
+  //       }
+  //     });
+  // }
 });
 
 export default router;