瀏覽代碼

用户管理相关

zhangjie 2 年之前
父節點
當前提交
4604d679b1

+ 36 - 10
src/components/RoleSelect.vue

@@ -18,15 +18,29 @@
 
 <script setup lang="ts">
 import { getRoleList } from "@/api/roleManagementPage";
+import { ROLE_MANAGE_SET } from "@/constants/constants";
+import { useMainStore } from "@/store";
 import { onMounted, computed, watch } from "vue";
+import { RoleOption } from "@/types";
 
-const props = defineProps<{
-  value?: null | number;
-  rootOrgId?: null | number;
+const props = withDefaults(
+  defineProps<{
+    value?: null | number;
+    rootOrgId?: null | number;
+    isManage: boolean;
+  }>(),
+  {
+    value: null,
+    rootOrgId: null,
+    isManage: false,
+  }
+);
+const emit = defineEmits<{
+  (e: "update:value", id: number): void;
+  (e: "change", role: RoleOption | null): void;
 }>();
-const emit = defineEmits(["update:value"]);
 
-let optionList = $ref<{ id: number; name: string }[]>([]);
+let optionList = $ref<RoleOption[]>([]);
 
 onMounted(async () => {
   await fetchData();
@@ -34,20 +48,32 @@ onMounted(async () => {
 
 watch(() => [props.rootOrgId], fetchData);
 
+const store = useMainStore();
 async function fetchData() {
-  if (typeof props.rootOrgId === "number") {
-    const res = await getRoleList(props.rootOrgId);
-    optionList = res.data;
+  if (typeof props.rootOrgId !== "number") return;
+
+  const res = await getRoleList(props.rootOrgId);
+  optionList = res.data;
+
+  if (props.isManage) {
+    let userRoleSet: string[] = [];
+    store.userInfo.roleList.forEach((r) => {
+      const info = ROLE_MANAGE_SET[r.roleCode];
+      userRoleSet.push(...info);
+    });
+    optionList = optionList.filter((item) => userRoleSet.includes(item.code));
   }
 }
 const valueStr = computed(() => {
   let res: undefined | number = props.value ?? undefined;
   // if (typeof res === "number") res = props.value;
-  return res ;
+  return res;
 });
 
-function handleChange(v: string) {
+function handleChange(v: number) {
   // console.log(typeof v);
   emit("update:value", v);
+  const role = optionList.find((item) => item.id === v);
+  emit("change", role || null);
 }
 </script>

+ 7 - 0
src/constants/constants.ts

@@ -70,3 +70,10 @@ export const RANGE_POINT_TYPE = {
   RETEST_TOTAL_SCORE: "复试总分线",
   TOTAL_SCORE_LINE: "国家满分线",
 } as const;
+
+export const ROLE_MANAGE_SET= {
+  SUPER_ADMIN:[
+    'SUPER_ADMIN','ROOT_ORG_ADMIN','ORG_ADMIN','COURSE_ADMIN'
+  ],
+  ROOT_ORG_ADMIN:['COURSE_ADMIN'],ORG_ADMIN:[''],COURSE_ADMIN:['']
+} as const

+ 1 - 1
src/features/paperAnalysis/PaperAnalysis.vue

@@ -87,7 +87,7 @@ store.currentLocation = "项目管理 / 项目列表 / 试卷分析";
 let activeTab = $ref("1");
 
 let rootOrgId = $ref(undefined as unknown as number);
-let courseId = $ref(undefined as undefined | number);
+let courseId = $ref(undefined as unknown as number);
 let paperType = $ref(undefined as undefined | string);
 let paperName = $ref(undefined as undefined | string);
 const route = useRoute();

+ 14 - 1
src/features/paperAnalysis/QuestionBianPai.vue

@@ -1,5 +1,8 @@
 <template>
-  <div class="tw-flex tw-gap-4" style="background-color: #e1e6f1">
+  <div
+    class="question-bianpai tw-flex tw-gap-4"
+    style="background-color: #e1e6f1"
+  >
     <a-table
       rowKey="id"
       :columns="columns"
@@ -79,3 +82,13 @@ function chartOption(questions: SASQuestion[]) {
   } as EChartsOption;
 }
 </script>
+
+<style>
+.question-bianpai {
+  height: 600px;
+}
+.question-bianpai .ant-table-wrapper {
+  height: 100%;
+  overflow: auto;
+}
+</style>

+ 4 - 1
src/features/projectManagement/ProjectManagement.vue

@@ -93,6 +93,7 @@
               <template #content>
                 <div class="tw-flex tw-flex-col">
                   <a-button
+                    v-if="!store.isCourseAdmin"
                     type="text"
                     style="color: white"
                     @click="handleLogsOfProject(record.id)"
@@ -111,7 +112,9 @@
                     数据管理
                   </a-button>
                   <a-button
-                    v-if="record.status !== 'PROCESSING'"
+                    v-if="
+                      record.status !== 'PROCESSING' && !store.isCourseAdmin
+                    "
                     type="text"
                     style="color: white"
                     @click="goProjectParams(record.id)"

+ 11 - 0
src/features/userManagement/UserManagement.vue

@@ -142,6 +142,12 @@
             :rootOrgId="userObj.rootOrgId"
           />
         </a-form-item>
+        <!-- <a-form-item v-if="curRoleCode === 'COURSE_ADMIN'" label="负责科目">
+          <a-input
+            v-model:value="userObj.course"
+            placeholder="多个科目用中文逗号隔开"
+          ></a-input>
+        </a-form-item> -->
         <a-form-item label="状态">
           <a-radio-group v-model:value="userObj.enable">
             <a-radio :value="true">启用</a-radio>
@@ -330,6 +336,11 @@ const newUser = () => {
   showModal(userObj);
 };
 
+// let curRoleCode = $ref("");
+// function roleChange(data: RoleOption | null) {
+//   curRoleCode = data ? data.code : "";
+// }
+
 function checkEmpty(selectIds: number[]): boolean {
   if (selectIds && selectIds.length > 0) {
     return false;

+ 4 - 0
src/store/index.ts

@@ -46,6 +46,10 @@ export const useMainStore = defineStore("main", {
         this.userInfo.roleList.some((r) => r.roleCode === "ORG_ADMIN")
       );
     },
+    isCourseAdmin():boolean {
+      return this.userInfo.roleList.some((r) => r.roleCode === "COURSE_ADMIN");
+ 
+    }
   },
   actions: {
     setUserInfo(res: any) {

+ 4 - 0
src/types/index.ts

@@ -4,6 +4,10 @@ export interface Role {
   roleName: string;
 }
 
+export interface RoleOption {
+  id: number; name: string; code: string
+}
+
 export type Course_Type = "PUBLIC" | "MAJOR";
 
 export type Privilege_Type = "COURSE" | "ORG";