From 39fa3a63708345110df87a9b741608e3fb320471 Mon Sep 17 00:00:00 2001 From: JiaoTianBo Date: Sat, 28 Mar 2026 11:46:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(user):=20=E5=90=8C=E6=AD=A5=E9=A3=9E?= =?UTF-8?q?=E4=B9=A6=E7=94=A8=E6=88=B7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 syncFeishuUsers API 用于同步飞书用户数据 - 用户列表页面添加“同步飞书用户”按钮及加载状态 - useUser hook 中实现同步飞书用户逻辑,支持按钮触发同步 - 分页处理逻辑调整,保证切换页码和页面大小均触发查询 - usePermission hook 中替换旧接口 getPermissionTree 为分页查询的 getPermissionList - 权限列表分页数据更新,更准确处理总数、当前页和页面大小 --- src/api/feishu.ts | 9 +++++++ src/views/system/permission/utils/hook.tsx | 20 ++++++++++----- src/views/system/user/index.vue | 13 ++++++---- src/views/system/user/utils/hook.tsx | 30 +++++++++++++++++++--- 4 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/api/feishu.ts b/src/api/feishu.ts index e11c9ea..fd8ca8b 100644 --- a/src/api/feishu.ts +++ b/src/api/feishu.ts @@ -51,3 +51,12 @@ export const getFeishuUserInfo = () => { message: string; }>("get", "/api/v1/auth/feishu/user/info"); }; + +/** 同步飞书用户 */ +export const syncFeishuUsers = () => { + return http.request<{ + code: number; + data: Record; + message: string; + }>("post", "/api/v1/feishu/sync/users"); +}; diff --git a/src/views/system/permission/utils/hook.tsx b/src/views/system/permission/utils/hook.tsx index 17c2c60..d72d419 100644 --- a/src/views/system/permission/utils/hook.tsx +++ b/src/views/system/permission/utils/hook.tsx @@ -4,7 +4,7 @@ import { addDialog } from "@/components/ReDialog"; import type { PaginationProps } from "@pureadmin/table"; import type { FormItemProps } from "./types"; import editForm from "../form/index.vue"; -import { getPermissionTree } from "@/api/system"; +import { getPermissionList } from "@/api/system"; import { type Ref, h, ref, computed, reactive, onMounted } from "vue"; import { getKeyList, deviceDetection } from "@pureadmin/utils"; import { ElMessageBox } from "element-plus"; @@ -161,11 +161,13 @@ export function usePermission(tableRef: Ref) { } function handleSizeChange(val: number) { - console.log(`${val} items per page`); + pagination.pageSize = val; + onSearch(); } function handleCurrentChange(val: number) { - console.log(`current page: ${val}`); + pagination.currentPage = val; + onSearch(); } function handleSelectionChange(val) { @@ -190,10 +192,16 @@ export function usePermission(tableRef: Ref) { async function onSearch() { loading.value = true; try { - const { code, data } = await getPermissionTree(); + const { code, data } = await getPermissionList({ + pageNum: pagination.currentPage, + pageSize: pagination.pageSize, + keyword: form.permissionName || form.permissionCode || undefined + }); if (code === 200) { - dataList.value = data || []; - pagination.total = data?.length || 0; + dataList.value = data?.records || []; + pagination.total = data?.total || 0; + pagination.pageSize = data?.size || 10; + pagination.currentPage = data?.current || 1; } } catch (error) { console.error(error); diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 46a43f6..e43fd21 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -11,7 +11,7 @@ import More from "~icons/ep/more-filled"; import Delete from "~icons/ep/delete"; import EditPen from "~icons/ep/edit-pen"; import Refresh from "~icons/ep/refresh"; -import AddFill from "~icons/ri/add-circle-line"; +import Sync from "~icons/ri/refresh-line"; defineOptions({ name: "SystemUser" @@ -41,7 +41,9 @@ const { handleSizeChange, onSelectionCancel, handleCurrentChange, - handleSelectionChange + handleSelectionChange, + syncLoading, + handleSyncFeishuUsers } = useUser(tableRef); @@ -103,10 +105,11 @@ const {