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({