Michael Wang 3 سال پیش
والد
کامیت
5bad3c760d

+ 4 - 4
src/components/Layout.vue

@@ -6,22 +6,22 @@
         <a-sub-menu key="sub1">
           <template #icon> <span class="basic-icon"></span> </template>
           <template #title>基础管理</template>
-          <a-menu-item key="11">
+          <a-menu-item v-if="store.isSuperAdmin" key="11">
             <router-link active-class="active-route" to="/basic/rootOrg">
               顶级机构管理
             </router-link>
           </a-menu-item>
-          <a-menu-item key="12">
+          <a-menu-item v-if="store.isGreaterThanEqualRootOrgAdmin" key="12">
             <router-link active-class="active-route" to="/basic/subOrg">
               机构管理
             </router-link>
           </a-menu-item>
-          <a-menu-item key="13">
+          <a-menu-item v-if="store.isGreaterThanEqualRootOrgAdmin" key="13">
             <router-link active-class="active-route" to="/basic/role">
               角色管理
             </router-link>
           </a-menu-item>
-          <a-menu-item key="14">
+          <a-menu-item v-if="store.isGreaterThanEqualOrgAdmin" key="14">
             <router-link active-class="active-route" to="/basic/user">
               用户管理
             </router-link>

+ 2 - 2
src/features/courseManagement/CourseManagement.vue

@@ -25,7 +25,7 @@
       <span class="tw-mr-4"></span>
       <a-button @click="search">查询</a-button>
 
-      <div class="tw-mt-4">
+      <div v-if="store.isGreaterThanEqualRootOrgAdmin" class="tw-mt-4">
         <a-button @click="newCourse">新增</a-button>
         <a-button @click="importModalVisible = true">批量导入</a-button>
         <a-button @click="handleExport">批量导出</a-button>
@@ -65,7 +65,7 @@
           <a>{{ $filters.booleanEnableDisableFilter(text) }}</a>
         </template>
         <template #action="{ record }">
-          <span>
+          <span v-if="store.isGreaterThanEqualRootOrgAdmin">
             <a-button @click="showModal(record)">编辑</a-button>
             <a-button @click="handleToggleCourses(!record.enable, [record.id])">
               {{ record.enable ? "禁用" : "启用" }}

+ 22 - 6
src/features/projectManagement/ProjectManagement.vue

@@ -15,7 +15,7 @@
       <span class="tw-mr-4"></span>
       <a-button @click="search">查询</a-button>
 
-      <div class="tw-mt-4">
+      <div v-if="store.isGreaterThanEqualRootOrgAdmin" class="tw-mt-4">
         <a-button @click="newProject">新增</a-button>
         <a-button @click="handleDeleteProjects(selectIds)"> 批量删除 </a-button>
       </div>
@@ -43,18 +43,31 @@
         </template>
         <template #action="{ record }">
           <span>
-            <a-button @click="showModal(record)">编辑</a-button>
-            <a-button @click="handleDeleteProjects([record.id])">
+            <a-button
+              v-if="store.isGreaterThanEqualRootOrgAdmin"
+              @click="showModal(record)"
+              >编辑</a-button
+            >
+            <a-button
+              v-if="store.isGreaterThanEqualRootOrgAdmin"
+              @click="handleDeleteProjects([record.id])"
+            >
               删除
             </a-button>
             <a-button
-              v-if="record.status === 'PROCESSING'"
+              v-if="
+                record.status === 'PROCESSING' &&
+                store.isGreaterThanEqualRootOrgAdmin
+              "
               @click="handleCancelProject(record.id)"
             >
               取消计算
             </a-button>
             <a-button
-              v-if="record.status === 'FINISH'"
+              v-if="
+                record.status === 'FINISH' &&
+                store.isGreaterThanEqualRootOrgAdmin
+              "
               @click="handleRestartProject(record.id)"
             >
               重新计算
@@ -63,7 +76,10 @@
               错误报告
             </a-button>
             <a-button
-              v-if="record.status !== 'PROCESSING'"
+              v-if="
+                record.status !== 'PROCESSING' &&
+                store.isGreaterThanEqualRootOrgAdmin
+              "
               @click="goProjectDataSource(record.id)"
             >
               数据管理

+ 5 - 2
src/features/roleManagement/RoleManagement.vue

@@ -1,7 +1,10 @@
 <template>
   <div>
-    <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
-      <RootOrgSelect v-if="store.isSuperAdmin" v-model:value="rootOrgId" />
+    <div
+      v-if="store.isSuperAdmin"
+      class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5"
+    >
+      <RootOrgSelect v-model:value="rootOrgId" />
       <span class="tw-mr-4"></span>
       <a-button @click="search">查询</a-button>
     </div>

+ 4 - 1
src/features/subOrg/SubOrg.vue

@@ -1,7 +1,10 @@
 <template>
   <div>
     <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
-      <RootOrgSelect v-if="store.isSuperAdmin" v-model:value="rootOrgId" />
+      <template v-if="store.isSuperAdmin">
+        <RootOrgSelect v-model:value="rootOrgId" />
+        <span class="tw-mr-4"></span>
+      </template>
       <a-input
         v-model:value="code"
         style="width: 178px"

+ 8 - 4
src/features/userManagement/UserManagement.vue

@@ -1,9 +1,10 @@
 <template>
   <div>
     <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
-      <RootOrgSelect v-if="store.isSuperAdmin" v-model:value="rootOrgId" />
-
-      <span class="tw-mr-4"></span>
+      <template v-if="store.isSuperAdmin">
+        <RootOrgSelect v-model:value="rootOrgId" />
+        <span class="tw-mr-4"></span>
+      </template>
       <a-input
         v-model:value="name"
         class="tw-mr-4"
@@ -68,7 +69,10 @@
               {{ record.enable ? "禁用" : "启用" }}
             </a-button>
             <a-button @click="handleResetUsers([record.id])">重置密码</a-button>
-            <a-button @click="handleUserPrivilege(record.id)">
+            <a-button
+              v-if="store.isGreaterThanEqualRootOrgAdmin"
+              @click="handleUserPrivilege(record.id)"
+            >
               权限设置
             </a-button>
           </span>

+ 21 - 0
src/store/index.ts

@@ -25,6 +25,27 @@ export const useMainStore = defineStore("main", {
     isSuperAdmin(): boolean {
       return this.userInfo.roleList.some((r) => r.roleCode === "SUPER_ADMIN");
     },
+    isRootOrgAdmin(): boolean {
+      return this.userInfo.roleList.some(
+        (r) => r.roleCode === "ROOT_ORG_ADMIN"
+      );
+    },
+    isOrgAdmin(): boolean {
+      return this.userInfo.roleList.some((r) => r.roleCode === "ORG_ADMIN");
+    },
+    isGreaterThanEqualRootOrgAdmin(): boolean {
+      return (
+        this.userInfo.roleList.some((r) => r.roleCode === "SUPER_ADMIN") ||
+        this.userInfo.roleList.some((r) => r.roleCode === "ROOT_ORG_ADMIN")
+      );
+    },
+    isGreaterThanEqualOrgAdmin(): boolean {
+      return (
+        this.userInfo.roleList.some((r) => r.roleCode === "SUPER_ADMIN") ||
+        this.userInfo.roleList.some((r) => r.roleCode === "ROOT_ORG_ADMIN") ||
+        this.userInfo.roleList.some((r) => r.roleCode === "ORG_ADMIN")
+      );
+    },
   },
   actions: {
     setUserInfo(res: any) {