diff --git a/frontend/src/api/modules/setting/system/organizationAndProject.ts b/frontend/src/api/modules/setting/system/organizationAndProject.ts index c54855c87f..6926134471 100644 --- a/frontend/src/api/modules/setting/system/organizationAndProject.ts +++ b/frontend/src/api/modules/setting/system/organizationAndProject.ts @@ -2,17 +2,28 @@ import MSR from '@/api/http/index'; import * as orgUrl from '@/api/requrls/setting/system/organizationAndProject'; import { TableQueryParams } from '@/models/common'; import { AddUserToOrgOrProjectParams } from '@/models/setting/systemOrg'; +import { CreateOrUpdateSystemOrgParams } from '@/models/setting/system/orgAndProject'; // 获取组织列表 export function postOrgTable(data: TableQueryParams) { return MSR.post({ url: orgUrl.postOrgTableUrl, data }); } +// 创建或修改组织 +export function createOrUpdateOrg(data: CreateOrUpdateSystemOrgParams) { + return MSR.post({ url: data.id ? orgUrl.postModifyOrgUrl : orgUrl.postAddOrgUrl, data }); +} + // 删除组织 export function deleteOrg(id: string) { return MSR.get({ url: `${orgUrl.getDeleteOrgUrl}${id}` }); } +// 撤销删除组织 +export function revokeDeleteOrg(id: string) { + return MSR.get({ url: `${orgUrl.getRecoverOrgUrl}${id}` }); +} + // 启用或禁用组织 export function enableOrDisableOrg(id: string, isEnable = true) { return MSR.get({ url: `${isEnable ? orgUrl.getEnableOrgUrl : orgUrl.getDisableOrgUrl}${id}` }); diff --git a/frontend/src/locale/en-US/common.ts b/frontend/src/locale/en-US/common.ts index a501d6e5a2..11fb6a71c5 100644 --- a/frontend/src/locale/en-US/common.ts +++ b/frontend/src/locale/en-US/common.ts @@ -12,6 +12,13 @@ export default { 'common.retry': 'Retry', 'common.end': 'End', 'common.enable': 'Enable', + 'common.close': 'Close', + 'common.confirmEnable': 'Confirm enable', + 'common.confirmClose': 'Confirm close', + 'common.enableSuccess': 'Enable success', + 'common.enableFailed': 'Enable failed', + 'common.closeSuccess': 'Close success', + 'common.closeFailed': 'Close failed', 'common.all': 'All', 'common.operation': 'Operation', 'common.remove': 'Remove', @@ -30,4 +37,6 @@ export default { 'common.removeSuccess': 'Remove success', 'common.removeFailed': 'Remove failed', 'common.admin': 'Admin', + 'common.revokeDelete': 'Revoke delete', + 'common.revokeDeleteSuccess': 'Revoke delete success', }; diff --git a/frontend/src/locale/zh-CN/common.ts b/frontend/src/locale/zh-CN/common.ts index 4d9fdbc393..e53ec3ab77 100644 --- a/frontend/src/locale/zh-CN/common.ts +++ b/frontend/src/locale/zh-CN/common.ts @@ -12,6 +12,13 @@ export default { 'common.retry': '重试', 'common.end': '结束', 'common.enable': '启用', + 'common.close': '关闭', + 'common.confirmEnable': '确认启用', + 'common.confirmClose': '确认关闭', + 'common.enableSuccess': '启用成功', + 'common.enableFailed': '启用失败', + 'common.closeSuccess': '关闭成功', + 'common.closeFailed': '关闭失败', 'common.all': '全部', 'common.operation': '操作', 'common.remove': '移除', @@ -30,4 +37,6 @@ export default { 'common.removeSuccess': '移除成功', 'common.removeFailed': '移除失败', 'common.admin': '管理员', + 'common.revokeDelete': '撤销删除', + 'common.revokeDeleteSuccess': '已撤销删除', }; diff --git a/frontend/src/models/setting/system/orgAndProject.ts b/frontend/src/models/setting/system/orgAndProject.ts new file mode 100644 index 0000000000..5151003257 --- /dev/null +++ b/frontend/src/models/setting/system/orgAndProject.ts @@ -0,0 +1,6 @@ +export interface CreateOrUpdateSystemOrgParams { + id?: string; + name: string; + description: string; + memberIds: string[]; +} diff --git a/frontend/src/views/setting/system/organizationAndProject/components/addOrganizationModal.vue b/frontend/src/views/setting/system/organizationAndProject/components/addOrganizationModal.vue index 0a2a292d2d..7c2ab894d3 100644 --- a/frontend/src/views/setting/system/organizationAndProject/components/addOrganizationModal.vue +++ b/frontend/src/views/setting/system/organizationAndProject/components/addOrganizationModal.vue @@ -19,7 +19,10 @@ - + @@ -34,11 +37,14 @@ import { reactive, ref, watchEffect } from 'vue'; import type { FormInstance, ValidatedError } from '@arco-design/web-vue'; import MsUserSelector from '@/components/bussiness/ms-user-selector/index.vue'; + import { createOrUpdateOrg } from '@/api/modules/setting/system/organizationAndProject'; + import { Message } from '@arco-design/web-vue'; + import { CreateOrUpdateSystemOrgParams } from '@/models/setting/system/orgAndProject'; const { t } = useI18n(); const props = defineProps<{ visible: boolean; - organizationId?: string; + currentOrganization?: CreateOrUpdateSystemOrgParams; }>(); const formRef = ref(); @@ -47,9 +53,9 @@ (e: 'cancel'): void; }>(); - const form = reactive({ + const form = reactive<{ name: string; memberIds: string[]; description: string }>({ name: '', - admin: [], + memberIds: [], description: '', }); @@ -63,11 +69,31 @@ }; const handleBeforeOk = () => { - formRef.value?.validate((errors: undefined | Record) => { + formRef.value?.validate(async (errors: undefined | Record) => { if (errors) { return false; } - return true; + try { + await createOrUpdateOrg({ id: props.currentOrganization?.id, ...form }); + Message.success( + props.currentOrganization?.id + ? t('system.organization.updateOrganizationSuccess') + : t('system.organization.createOrganizationSuccess') + ); + handleCancel(); + return true; + } catch (error) { + // eslint-disable-next-line no-console + console.error(error); + return false; + } }); }; + watchEffect(() => { + if (props.currentOrganization) { + form.name = props.currentOrganization.name; + form.memberIds = props.currentOrganization.memberIds; + form.description = props.currentOrganization.description; + } + }); diff --git a/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue b/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue index e298571220..4165d400f1 100644 --- a/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue +++ b/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue @@ -1,5 +1,15 @@