From 09538b03cbee85181644958a0db9230a3141b397 Mon Sep 17 00:00:00 2001 From: lzh Date: Thu, 23 Apr 2026 15:48:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(@vben/web-antd):=20=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=88=90=E5=91=98=E7=AE=A1=E7=90=86=E6=94=B9=20Drawer=20+=20?= =?UTF-8?q?=E5=88=86=E9=A1=B5=20+=20=E5=A2=9E=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从 Modal 多选改为 Drawer 分页表,更接近"成员管理"语义: - 原 assign-user-form.vue 重写为 Drawer + Vxe 分页表 - 新增 add-user-modal.vue 子弹窗用于添加用户(过滤已是成员) - 每行一个"移除"popConfirm 按钮,调 removeProjectUser 单删 - 顶部 keyword 搜索,按 username/nickname/mobile 模糊 - 底部提示:超管不在此列表(后端已过滤) - data.ts 新增 useProjectMemberGridColumns - api 新增 getProjectUserPage / addProjectUsers / removeProjectUser - project/index.vue 接入点改 useVbenDrawer Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/api/system/user-project/index.ts | 35 +++ .../web-antd/src/views/system/project/data.ts | 48 +++- .../src/views/system/project/index.vue | 12 +- .../system/project/modules/add-user-modal.vue | 106 +++++++++ .../project/modules/assign-user-form.vue | 219 ++++++++++++------ 5 files changed, 342 insertions(+), 78 deletions(-) create mode 100644 apps/web-antd/src/views/system/project/modules/add-user-modal.vue diff --git a/apps/web-antd/src/api/system/user-project/index.ts b/apps/web-antd/src/api/system/user-project/index.ts index 795a6f2e1..f965e6dcb 100644 --- a/apps/web-antd/src/api/system/user-project/index.ts +++ b/apps/web-antd/src/api/system/user-project/index.ts @@ -1,3 +1,7 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import type { SystemUserApi } from '#/api/system/user'; + import { requestClient } from '#/api/request'; export namespace SystemUserProjectApi { @@ -9,6 +13,14 @@ export namespace SystemUserProjectApi { projectId: number; userIds: number[]; } + export interface AddProjectUsersReq { + projectId: number; + userIds: number[]; + } + export interface ProjectUserPageReq extends PageParam { + projectId: number; + keyword?: string; + } } /** 给用户覆盖式分配项目 */ @@ -44,3 +56,26 @@ export function getUserIdsByProjectId(projectId: number) { `/system/user-project/list-user-ids-by-project?projectId=${projectId}`, ); } + +/** 分页查询项目成员(已自动过滤超级管理员) */ +export function getProjectUserPage(params: SystemUserProjectApi.ProjectUserPageReq) { + return requestClient.get>( + '/system/user-project/project-user-page', + { params }, + ); +} + +/** 增量给项目添加成员 */ +export function addProjectUsers(data: SystemUserProjectApi.AddProjectUsersReq) { + return requestClient.post( + '/system/user-project/add-project-users', + data, + ); +} + +/** 从项目中移除单个成员 */ +export function removeProjectUser(projectId: number, userId: number) { + return requestClient.delete( + `/system/user-project/remove-project-user?projectId=${projectId}&userId=${userId}`, + ); +} diff --git a/apps/web-antd/src/views/system/project/data.ts b/apps/web-antd/src/views/system/project/data.ts index 8bd1bf701..48b7a431d 100644 --- a/apps/web-antd/src/views/system/project/data.ts +++ b/apps/web-antd/src/views/system/project/data.ts @@ -84,7 +84,53 @@ export function useFormSchema(): VbenFormSchema[] { ]; } -/** 管理成员的表单(项目 → 多用户) */ +/** 项目成员管理抽屉的表格列 */ +export function useProjectMemberGridColumns(): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '用户编号', + minWidth: 90, + }, + { + field: 'username', + title: '用户名', + minWidth: 120, + }, + { + field: 'nickname', + title: '昵称', + minWidth: 120, + }, + { + field: 'mobile', + title: '手机号', + minWidth: 120, + }, + { + field: 'deptId', + title: '部门编号', + minWidth: 90, + }, + { + field: 'status', + title: '状态', + minWidth: 90, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + title: '操作', + width: 100, + fixed: 'right', + slots: { default: 'actions' }, + }, + ]; +} + +/** 管理成员的表单(项目 → 多用户)— 保留给未来"覆盖写入"场景,当前 UI 已改抽屉 */ export function useAssignUserFormSchema(): VbenFormSchema[] { return [ { diff --git a/apps/web-antd/src/views/system/project/index.vue b/apps/web-antd/src/views/system/project/index.vue index 708a59ede..6a086b032 100644 --- a/apps/web-antd/src/views/system/project/index.vue +++ b/apps/web-antd/src/views/system/project/index.vue @@ -4,7 +4,7 @@ import type { SystemProjectApi } from '#/api/system/project'; import { ref } from 'vue'; -import { confirm, Page, useVbenModal } from '@vben/common-ui'; +import { confirm, Page, useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -14,7 +14,7 @@ import { deleteProject, getProjectPage } from '#/api/system/project'; import { $t } from '#/locales'; import { useGridColumns, useGridFormSchema } from './data'; -import AssignUserForm from './modules/assign-user-form.vue'; +import AssignUserDrawer from './modules/assign-user-form.vue'; import Form from './modules/form.vue'; const [FormModal, formModalApi] = useVbenModal({ @@ -22,8 +22,8 @@ const [FormModal, formModalApi] = useVbenModal({ destroyOnClose: true, }); -const [AssignUserModal, assignUserModalApi] = useVbenModal({ - connectedComponent: AssignUserForm, +const [MemberDrawer, memberDrawerApi] = useVbenDrawer({ + connectedComponent: AssignUserDrawer, destroyOnClose: true, }); @@ -44,7 +44,7 @@ function handleEdit(row: SystemProjectApi.Project) { /** 管理成员 */ function handleAssignUser(row: SystemProjectApi.Project) { - assignUserModalApi.setData(row).open(); + memberDrawerApi.setData(row).open(); } /** 删除项目 */ @@ -125,7 +125,7 @@ const [Grid, gridApi] = useVbenVxeGrid({