Michael Wang 3 anni fa
parent
commit
dd2bfe96fe

+ 9 - 1
src/api/loginPage.ts

@@ -1,3 +1,4 @@
+import { getToken } from "@/auth/auth";
 import { httpApp } from "@/plugins/axiosApp";
 
 /** 登录 */
@@ -13,5 +14,12 @@ export function loginByUsername(loginInfo: {
 
 /** 登出 */
 export function logout() {
-  return httpApp.post("/api/ess/auth/logout").catch(() => {});
+  return new Promise((resolve) => {
+    const token = getToken();
+    if (token) {
+      return httpApp.post("/api/ess/auth/logout").catch(() => {});
+    } else {
+      resolve(0);
+    }
+  });
 }

+ 11 - 5
src/api/userManagementPage.ts

@@ -1,5 +1,5 @@
 import { httpApp } from "@/plugins/axiosApp";
-import { Privilege_Type } from "@/types";
+import { Course_Type, Privilege_Type } from "@/types";
 import { responseToFile } from "@/utils/utils";
 import QueryString from "qs";
 
@@ -17,6 +17,11 @@ export function getUserList(params: {
   return httpApp.post("/api/ess/user/page", params);
 }
 
+/** 用户id查询 */
+export function getUser(id: number) {
+  return httpApp.post("/api/ess/user/info?id=" + id);
+}
+
 /** 更新用户 */
 export function updateUser(params: {
   loginName?: string;
@@ -73,13 +78,14 @@ export function exportUsers(params: {
 
 /** 用户科目/机构数据权限分页查询 */
 export function getUserPrivilegegList(params: {
-  type: Privilege_Type;
+  ptype: Privilege_Type;
+  type?: Course_Type;
   userId?: number;
   pageNo?: number;
   pageSize?: number;
 }) {
   return httpApp.post(
-    `/api/ess/user/data/rule/list/for/${params.type.toLowerCase()}`,
+    `/api/ess/user/data/rule/list/for/${params.ptype.toLowerCase()}`,
     params
   );
 }
@@ -110,7 +116,7 @@ export function modifyUserPrivilegegDefaultAll(params: {
 
 /** 添加科目权限-分页查询科目 添加机构权限-分页查询机构 */
 export function getToAddListForUserPrivilege(params: {
-  type: Privilege_Type;
+  ptype: Privilege_Type;
   rootOrgId: number;
   userId?: number;
   enable?: boolean;
@@ -119,7 +125,7 @@ export function getToAddListForUserPrivilege(params: {
   pageSize?: number;
 }) {
   return httpApp.post(
-    `/api/ess/${params.type.toLowerCase()}/page/data/rule`,
+    `/api/ess/${params.ptype.toLowerCase()}/page/data/rule`,
     params
   );
 }

+ 4 - 1
src/components/Layout.vue

@@ -46,7 +46,10 @@
         </a-sub-menu>
       </a-menu>
     </div>
-    <div class="tw-h-screen" style="width: calc(100% - 240px)">
+    <div
+      class="tw-h-screen"
+      style="width: calc(100% - 240px); overflow: scroll"
+    >
       <div
         class="tw-bg-white tw-flex tw-justify-between tw-items-center"
         style="border-left: 1px solid var(--app-main-bg-color); height: 56px"

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

@@ -86,7 +86,7 @@
       ok-text="确定"
       cancel-text="取消"
     >
-      <a-form>
+      <a-form :labelCol="{ span: 4 }">
         <a-form-item v-show="store.isSuperAdmin" label="顶级机构">
           <RootOrgSelect
             :disabled="!!courseObj.id"

+ 2 - 1
src/features/userManagement/UserManagement.vue

@@ -88,7 +88,7 @@
       ok-text="确定"
       cancel-text="取消"
     >
-      <a-form>
+      <a-form :labelCol="{ span: 4 }">
         <a-form-item v-show="store.isSuperAdmin" label="顶级机构">
           <RootOrgSelect
             :disabled="!!userObj.id"
@@ -313,6 +313,7 @@ async function handleResetUsers(ids: number[]) {
     onOk: async () => {
       await resetPasswords(ids);
       await search();
+      message.success({ content: "操作成功" });
     },
   });
 }

+ 9 - 9
src/features/userManagement/UserPrivilege.vue

@@ -1,12 +1,14 @@
 <template>
   <div>
     <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
-      <span>{{ theUser.name }}</span> <span> {{ theUser.roleName }}</span>
-      <span class="tw-mr-4"></span>
-      <a-button @click="goBack">返回</a-button>
+      <span class="tw-text-xl">
+        <span>{{ theUser.name }}</span>
+        <span>({{ theUser.roleName }})</span>
+      </span>
+      <a-button class="tw-float-right" @click="goBack">返回</a-button>
     </div>
 
-    <a-tabs>
+    <a-tabs class="tw-bg-white tw-rounded-xl">
       <a-tab-pane key="1" tab="科目范围"><UserPrivilegeCourse /> </a-tab-pane>
       <a-tab-pane key="2" tab="机构范围"><UserPrivilegeOrg /></a-tab-pane>
     </a-tabs>
@@ -14,7 +16,7 @@
 </template>
 
 <script setup lang="ts">
-import { getUserList } from "@/api/userManagementPage";
+import { getUser } from "@/api/userManagementPage";
 import { useMainStore } from "@/store";
 import { goBack } from "@/utils/utils";
 import { onMounted, reactive } from "vue-demi";
@@ -38,10 +40,8 @@ async function search() {
 }
 
 async function fetchData() {
-  const user = await getUserList({
-    id: +userId,
-  });
-  theUser = user.data && user.data[0];
+  const user = await getUser(+userId);
+  Object.assign(theUser, user.data);
 }
 
 onMounted(async () => {

+ 9 - 10
src/features/userManagement/UserPrivilegeCourse.vue

@@ -2,15 +2,15 @@
   <div>
     <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
       <a-switch v-model:checked="checked" @click="toggleAll" /> 全部课程
-      <span class="tw-mr-4"></span>
-      <a-button @click="handleDeletePrivilege" :danger="true">删除</a-button>
-      <span class="tw-mr-4"></span>
-      <a-button @click="showModal">添加</a-button>
+      <div class="tw-float-right tw-flex tw-gap-2">
+        <a-button @click="handleDeletePrivilege" :danger="true">删除</a-button>
+        <a-button @click="showModal">添加</a-button>
+      </div>
     </div>
 
     <div class="tw-bg-white tw-p-5 tw-rounded-xl">
       <a-table
-        row-key="id"
+        row-key="courseId"
         :columns="columns"
         :data-source="data"
         :row-selection="rowSelection"
@@ -35,7 +35,7 @@
       ok-text="确定"
       cancel-text="取消"
     >
-      <a-form>
+      <a-form layout="inline">
         <a-form-item label="科目名称">
           <a-input v-model:value="userObj.name"></a-input>
         </a-form-item>
@@ -48,7 +48,7 @@
 
         <a-button @click="fetchData2" class="query-btn">查询</a-button>
       </a-form>
-      <div class="tw-bg-white tw-p-5 tw-rounded-xl">
+      <div class="tw-bg-white tw-py-5 tw-rounded-xl">
         <a-table
           row-key="id"
           :columns="columns2"
@@ -124,7 +124,7 @@ async function fetchData() {
   checked = res0.data;
 
   const res = await getUserPrivilegegList({
-    type: PRIVI_TYPE,
+    ptype: PRIVI_TYPE,
     userId,
     pageSize,
     pageNo,
@@ -145,7 +145,6 @@ const columns = [
   {
     title: "科目编码",
     dataIndex: "courseCode",
-    width: 150,
   },
   {
     title: "科目名称",
@@ -226,7 +225,7 @@ watch(() => [pageNo2, pageSize2], fetchData2);
 
 async function fetchData2() {
   const res = await getToAddListForUserPrivilege({
-    type: PRIVI_TYPE,
+    ptype: PRIVI_TYPE,
     rootOrgId: store.userInfo.rootOrgId,
     userId,
     name: userObj.name,

+ 9 - 10
src/features/userManagement/UserPrivilegeOrg.vue

@@ -2,15 +2,15 @@
   <div>
     <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
       <a-switch v-model:checked="checked" @click="toggleAll" /> 全部课程
-      <span class="tw-mr-4"></span>
-      <a-button @click="handleDeletePrivilege" :danger="true">删除</a-button>
-      <span class="tw-mr-4"></span>
-      <a-button @click="showModal">添加</a-button>
+      <div class="tw-float-right tw-flex tw-gap-2">
+        <a-button @click="handleDeletePrivilege" :danger="true">删除</a-button>
+        <a-button @click="showModal">添加</a-button>
+      </div>
     </div>
 
     <div class="tw-bg-white tw-p-5 tw-rounded-xl">
       <a-table
-        row-key="id"
+        row-key="orgId"
         :columns="columns"
         :data-source="data"
         :row-selection="rowSelection"
@@ -35,7 +35,7 @@
       ok-text="确定"
       cancel-text="取消"
     >
-      <a-form>
+      <a-form layout="inline">
         <a-form-item label="机构名称">
           <a-input v-model:value="userObj.name"></a-input>
         </a-form-item>
@@ -48,7 +48,7 @@
 
         <a-button @click="fetchData2" class="query-btn">查询</a-button>
       </a-form>
-      <div class="tw-bg-white tw-p-5 tw-rounded-xl">
+      <div class="tw-bg-white tw-py-5 tw-rounded-xl">
         <a-table
           row-key="id"
           :columns="columns2"
@@ -124,7 +124,7 @@ async function fetchData() {
   checked = res0.data;
 
   const res = await getUserPrivilegegList({
-    type: PRIVI_TYPE,
+    ptype: PRIVI_TYPE,
     userId,
     pageSize,
     pageNo,
@@ -145,7 +145,6 @@ const columns = [
   {
     title: "机构编码",
     dataIndex: "orgCode",
-    width: 150,
   },
   {
     title: "机构名称",
@@ -226,7 +225,7 @@ watch(() => [pageNo2, pageSize2], fetchData2);
 
 async function fetchData2() {
   const res = await getToAddListForUserPrivilege({
-    type: PRIVI_TYPE,
+    ptype: PRIVI_TYPE,
     rootOrgId: store.userInfo.rootOrgId,
     userId,
     name: userObj.name,