diff --git a/frontend/src/api/modules/setting/organizationAndProject.ts b/frontend/src/api/modules/setting/organizationAndProject.ts index 56e0c3e7b5..130d4c97de 100644 --- a/frontend/src/api/modules/setting/organizationAndProject.ts +++ b/frontend/src/api/modules/setting/organizationAndProject.ts @@ -8,6 +8,14 @@ import { SystemGetUserByOrgOrProjectIdParams, } from '@/models/setting/system/orgAndProject'; +// 组织与项目-公共 +// 系统-组织及项目,获取管理员下拉选项 +export function getAdminByOrgOrProject() { + return MSR.get({ url: orgUrl.getAdminByOrgOrProjectUrl }); +} + +// 系统-组织 + // 获取组织列表 export function postOrgTable(data: TableQueryParams) { return MSR.post({ url: orgUrl.postOrgTableUrl, data }); @@ -43,7 +51,9 @@ export function enableOrDisableOrg(id: string, isEnable = true) { return MSR.get({ url: `${isEnable ? orgUrl.getEnableOrgUrl : orgUrl.getDisableOrgUrl}${id}` }); } -// 获取项目列表 +// 系统-项目 + +// 系统-获取项目列表 export function postProjectTable(data: TableQueryParams) { return MSR.post({ url: orgUrl.postProjectTableUrl, data }); } @@ -96,3 +106,44 @@ export function getAllUser() { export function getOrgAndProjectCount() { return MSR.get({ url: orgUrl.getOrgAndProjectCountUrl }); } + +// 组织-项目 +// 组织-获取项目列表 +export function postProjectTableByOrg(data: TableQueryParams) { + return MSR.post({ url: orgUrl.postProjectTableByOrgIdUrl, data }); +} + +// 组织-启用或禁用项目 +export function enableOrDisableProjectByOrg(id: string, isEnable = true) { + return MSR.get({ url: `${isEnable ? orgUrl.getEnableProjectByOrgUrl : orgUrl.getDisableProjectByOrgUrl}${id}` }); +} + +// 组织-删除项目 +export function deleteProjectByOrg(id: string) { + return MSR.get({ url: `${orgUrl.getDeleteProjectByOrgUrl}${id}` }); +} + +// 组织-撤销删除项目 +export function revokeDeleteProjectByOrg(id: string) { + return MSR.get({ url: `${orgUrl.getRecoverProjectByOrgUrl}${id}` }); +} + +// 组织-创建或更新项目 +export function createOrUpdateProjectByOrg(data: CreateOrUpdateSystemProjectParams) { + return MSR.post({ url: data.id ? orgUrl.postModifyProjectByOrgUrl : orgUrl.postAddProjectByOrgUrl, data }); +} + +// 组织-获取项目下的成员列表 +export function postProjectMemberByProjectId(data: TableQueryParams) { + return MSR.post({ url: orgUrl.postProjectMemberByOrgIdUrl, data }); +} + +// 组织-移除项目成员 +export function deleteProjectMemberByOrg(projectId: string, userId: string) { + return MSR.get({ url: `${orgUrl.getDeleteProjectMemberByOrgUrl}${projectId}/${userId}` }); +} + +// 组织-添加项目成员 +export function addProjectMemberByOrg(data: AddUserToOrgOrProjectParams) { + return MSR.post({ url: orgUrl.postAddProjectMemberByOrgUrl, data }); +} diff --git a/frontend/src/api/modules/setting/usergroup.ts b/frontend/src/api/modules/setting/usergroup.ts index 59ded2fb31..4fc047816b 100644 --- a/frontend/src/api/modules/setting/usergroup.ts +++ b/frontend/src/api/modules/setting/usergroup.ts @@ -72,14 +72,28 @@ export function saveOrgUSetting(data: SaveGlobalUSettingData) { return MSR.post({ url: ugUrl.editOrgUSettingUrl, data }); } +// 系统-获取用户组对应的用户列表 export function postUserByUserGroup(data: TableQueryParams) { return MSR.post>({ url: ugUrl.postUserByUserGroupUrl, data }); } +// 组织-获取用户组对应的用户列表 +export function postOrgUserByUserGroup(data: TableQueryParams) { + return MSR.post>({ url: ugUrl.postOrgUserByUserGroupUrl, data }); +} +// 系统-删除用户组对应的用户 export function deleteUserFromUserGroup(id: string) { return MSR.get({ url: `${ugUrl.deleteUserFromUserGroupUrl}${id}` }); } - +// 组织-删除用户组对应的用户 +export function deleteOrgUserFromUserGroup(id: string) { + return MSR.get({ url: `${ugUrl.deleteOrgUserFromUserGroupUrl}${id}` }); +} +// 系统-添加用户到用户组 export function addUserToUserGroup(data: { roleId: string; userIds: string[] }) { return MSR.post({ url: ugUrl.addUserToUserGroupUrl, data }); } +// 组织-添加用户到用户组 +export function addOrgUserToUserGroup(data: { userRoleId: string; userIds: string[]; organizationId: string }) { + return MSR.post({ url: ugUrl.addOrgUserToUserGroupUrl, data }); +} diff --git a/frontend/src/api/requrls/setting/organizationAndProject.ts b/frontend/src/api/requrls/setting/organizationAndProject.ts index a795c84456..70377447f3 100644 --- a/frontend/src/api/requrls/setting/organizationAndProject.ts +++ b/frontend/src/api/requrls/setting/organizationAndProject.ts @@ -1,3 +1,4 @@ +// 系统-组织 // 修改组织 export const postModifyOrgUrl = '/system/organization/update'; // 获取系统下所有组织-下拉选项 @@ -25,7 +26,7 @@ export const getDeleteOrgUrl = '/system/organization/delete/'; // 获取系统默认组织 export const getOrgDefaultUrl = '/system/organization/default'; -// 项目 +// 系统-项目 // 更新项目信息 export const postModifyProjectUrl = '/system/project/update'; // 获取项目列表 @@ -46,6 +47,8 @@ export const getProjectInfoUrl = '/system/project/get/'; export const getDeleteProjectUrl = '/system/project/delete/'; // 系统-组织及项目,获取用户下拉选项 export const getUserByOrgOrProjectUrl = '/system/organization/get-option/'; +// 系统-组织及项目,获取管理员下拉选项 +export const getAdminByOrgOrProjectUrl = '/system/organization/get-admin-option/'; // 启用项目 export const getEnableProjectUrl = '/system/project/enable/'; // 禁用项目 @@ -55,3 +58,27 @@ export const getOrgOrProjectAdminUrl = '/system/project/user-list'; // 获取项目和组织的总数 export const getOrgAndProjectCountUrl = '/system/organization/total'; + +// 组织-项目 +// 修改项目 +export const postModifyProjectByOrgUrl = '/organization/project/update'; +// 获取项目列表 +export const postProjectTableByOrgIdUrl = '/organization/project/page'; +// 获取项目下的成员列表 +export const postProjectMemberByOrgIdUrl = '/organization/project/member-list'; +// 添加项目 +export const postAddProjectByOrgUrl = '/organization/project/add'; +// 添加项目成员 +export const postAddProjectMemberByOrgUrl = '/organization/project/add-members'; +// 获取用户列表 +export const getUserTableByOrgIdOrProjectIdUrl = '/organization/project/user-list/'; +// 恢复项目 +export const getRecoverProjectByOrgUrl = '/organization/project/revoke/'; +// 移除项目成员 +export const getDeleteProjectMemberByOrgUrl = '/organization/project/remove-member/'; +// 启用项目 +export const getEnableProjectByOrgUrl = '/organization/project/enable/'; +// 禁用项目 +export const getDisableProjectByOrgUrl = '/organization/project/disable/'; +// 删除项目 +export const getDeleteProjectByOrgUrl = '/organization/project/delete/'; diff --git a/frontend/src/api/requrls/setting/usergroup.ts b/frontend/src/api/requrls/setting/usergroup.ts index 8ade9f41f9..78b408e696 100644 --- a/frontend/src/api/requrls/setting/usergroup.ts +++ b/frontend/src/api/requrls/setting/usergroup.ts @@ -1,3 +1,4 @@ +/** 系统 */ /** 修改用户组 */ export const updateUserGroupU = `/user/role/global/update`; /** 编辑用户组对应的权限配置 */ @@ -20,25 +21,24 @@ export const addUserToUserGroupUrl = `/user/role/relation/global/add`; /** 删除用户组用户 */ export const deleteUserFromUserGroupUrl = `/user/role/relation/global/delete/`; -// 组织下的用户组 - +/** 组织 */ +// 组织-修改用户组 export const updateOrgUserGroupU = `/user/role/organization/update`; -/** 编辑用户组对应的权限配置 */ +/** 组织-编辑用户组对应的权限配置 */ export const editOrgUSettingUrl = `/user/role/organization/permission/update`; -/** 添加用户组 */ +/** 组织-创建用户组 */ export const addOrgUserGroupU = `/user/role/organization/add`; -/** 获取用户组对应的权限配置 */ +/** 组织-获取用户组对应的权限配置 */ export const getOrgUSettingUrl = `/user/role/organization/permission/setting/`; -/** 获取用户组 */ +/** 组织-获取用户组 */ export const getOrgUserGroupU = `/user/role/organization/list/`; /** 获取单个用户组信息 */ export const getOrgUsergroupInfoU = `/user/role/organization/get/`; -/** 删除用户组 */ +/** 组织-删除用户组 */ export const deleteOrgUserGroupU = `/user/role/organization/delete/`; - -/** 根据用户组获取用户列表 */ -export const postOrgUserByUserGroupUrl = `/user/role/relation/organization/list`; -/** 创建用户组添加用户 */ -export const addOrgUserToUserGroupUrl = `/user/role/relation/organization/add`; -/** 删除用户组用户 */ -export const deleteOrgUserFromUserGroupUrl = `/user/role/relation/organization/delete/`; +/** 组织-根据用户组获取用户列表 */ +export const postOrgUserByUserGroupUrl = `/user/role/organization/list-member`; +/** 组织-用户组添加用户 */ +export const addOrgUserToUserGroupUrl = `/user/role/organization/add-member`; +/** 组织-删除用户组用户 */ +export const deleteOrgUserFromUserGroupUrl = `/user/role/organization/delete/`; diff --git a/frontend/src/components/pure/ms-table/base-table.vue b/frontend/src/components/pure/ms-table/base-table.vue index 32b7b616ac..407a901be5 100644 --- a/frontend/src/components/pure/ms-table/base-table.vue +++ b/frontend/src/components/pure/ms-table/base-table.vue @@ -76,7 +76,7 @@ @press-enter="handleEditInputEnter(record)" /> - {{ record[item.dataIndex as string] }} + {{ record[item.dataIndex as string] || '-' }} - + !!props.currentProject?.id); const affiliatedOrgOption = ref([]); + const appStore = useAppStore(); + const currentOrgId = computed(() => appStore.currentOrgId); const licenseStore = useLicenseStore(); const moduleOption = [ { label: 'menu.workbench', value: 'workstation' }, @@ -120,7 +118,7 @@ const form = reactive({ name: '', userIds: [], - organizationId: '', + organizationId: currentOrgId.value, description: '', enable: true, moduleIds: [], @@ -147,7 +145,7 @@ } try { loading.value = true; - await createOrUpdateProject({ id: props.currentProject?.id, ...form }); + await createOrUpdateProjectByOrg({ id: props.currentProject?.id, ...form }); Message.success( isEdit.value ? t('system.organization.updateOrganizationSuccess') @@ -184,4 +182,3 @@ } }); -@/api/modules/setting/organizationAndProject diff --git a/frontend/src/views/setting/organization/project/components/addUserModal.vue b/frontend/src/views/setting/organization/project/components/addUserModal.vue index e9d77e9370..9c6244c9aa 100644 --- a/frontend/src/views/setting/organization/project/components/addUserModal.vue +++ b/frontend/src/views/setting/organization/project/components/addUserModal.vue @@ -15,7 +15,7 @@ :label="t('system.organization.member')" :rules="[{ required: true, message: t('system.organization.addMemberRequired') }]" > - + @@ -33,14 +33,13 @@ -@/api/modules/setting/organizationAndProject diff --git a/frontend/src/views/setting/organization/project/orgProject.vue b/frontend/src/views/setting/organization/project/orgProject.vue index 64748526e6..d2a43b27aa 100644 --- a/frontend/src/views/setting/organization/project/orgProject.vue +++ b/frontend/src/views/setting/organization/project/orgProject.vue @@ -15,7 +15,7 @@ {{ record.name }} @@ -52,7 +52,7 @@ @cancel="handleAddProjectModalCancel" /> - + @@ -60,14 +60,14 @@ import { useI18n } from '@/hooks/useI18n'; import useTable from '@/components/pure/ms-table/useTable'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; - import { useTableStore } from '@/store'; - import { ref, reactive } from 'vue'; + import { useTableStore, useAppStore } from '@/store'; + import { ref, reactive, onMounted, computed } from 'vue'; import type { ActionsItem } from '@/components/pure/ms-table-more-action/types'; import { - postProjectTable, - deleteProject, - enableOrDisableProject, - revokeDeleteProject, + postProjectTableByOrg, + deleteProjectByOrg, + enableOrDisableProjectByOrg, + revokeDeleteProjectByOrg, } from '@/api/modules/setting/organizationAndProject'; import { TableKeyEnum } from '@/enums/tableEnum'; import { MsTableColumn } from '@/components/pure/ms-table/type'; @@ -89,6 +89,8 @@ const currentProjectId = ref(''); const currentUpdateProject = ref(); const { openDeleteModal, openModal } = useModal(); + const appStore = useAppStore(); + const currentOrgId = computed(() => appStore.currentOrgId); const keyword = ref(''); @@ -144,7 +146,7 @@ tableStore.initColumn(TableKeyEnum.SYSTEM_PROJECT, organizationColumns, 'drawer'); - const { propsRes, propsEvent, loadList, setKeyword } = useTable(postProjectTable, { + const { propsRes, propsEvent, loadList, setKeyword, setLoadListParams } = useTable(postProjectTableByOrg, { tableKey: TableKeyEnum.SYSTEM_PROJECT, scroll: { y: 'auto', x: '1300px' }, selectable: false, @@ -160,7 +162,7 @@ const currentUserDrawer = reactive({ visible: false, - organizationId: '', + projectId: '', }); const tableActions: ActionsItem[] = [ @@ -181,7 +183,7 @@ content: t('system.organization.deleteTip'), onBeforeOk: async () => { try { - await deleteProject(record.id); + await deleteProjectByOrg(record.id); Message.success(t('common.deleteSuccess')); fetchData(); } catch (error) { @@ -210,7 +212,7 @@ okText, onBeforeOk: async () => { try { - await enableOrDisableProject(record.id, isEnable); + await enableOrDisableProjectByOrg(record.id, isEnable); Message.success(isEnable ? t('common.enableSuccess') : t('common.closeSuccess')); fetchData(); } catch (error) { @@ -243,7 +245,7 @@ const showUserDrawer = (record: TableData) => { currentUserDrawer.visible = true; - currentUserDrawer.organizationId = record.id; + currentUserDrawer.projectId = record.id; }; const handleUserDrawerCancel = () => { @@ -265,11 +267,11 @@ type: 'error', cancelText: t('common.cancel'), title: t('system.project.revokeDeleteTitle', { name: record.name }), - content: t('system.organization.enableContent'), + content: t('system.project.enableContent'), okText: t('common.revokeDelete'), onBeforeOk: async () => { try { - await revokeDeleteProject(record.id); + await revokeDeleteProjectByOrg(record.id); Message.success(t('common.revokeDeleteSuccess')); fetchData(); } catch (error) { @@ -280,6 +282,10 @@ hideCancel: false, }); }; + onMounted(() => { + setLoadListParams({ organizationId: currentOrgId.value }); + fetchData(); + });