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 @@
+
+ {{ record.name }}
+
+
+ {{ t('system.organization.revokeDeleteToolTip') }}
+ {{ t('common.revokeDelete') }}
+
+
+
+
{{ record.createUser }}
{{
@@ -13,7 +23,10 @@
{{ record.projectCount }}
-
+
+ {{ t('common.revokeDelete') }}
+
+
{{ t('common.enable') }}
{{ t('common.delete') }}
@@ -25,7 +38,12 @@
-
+
@@ -38,7 +56,12 @@
import { useTableStore } from '@/store';
import { ref, reactive, watch } from 'vue';
import type { ActionsItem } from '@/components/pure/ms-table-more-action/types';
- import { postOrgTable, deleteOrg, enableOrDisableOrg } from '@/api/modules/setting/system/organizationAndProject';
+ import {
+ postOrgTable,
+ deleteOrg,
+ enableOrDisableOrg,
+ revokeDeleteOrg,
+ } from '@/api/modules/setting/system/organizationAndProject';
import { TableKeyEnum } from '@/enums/tableEnum';
import { MsTableColumn } from '@/components/pure/ms-table/type';
import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue';
@@ -49,6 +72,7 @@
import UserDrawer from './userDrawer.vue';
import AddUserModal from './addUserModal.vue';
import useModal from '@/hooks/useModal';
+ import { CreateOrUpdateSystemOrgParams } from '@/models/setting/system/orgAndProject';
export interface SystemOrganizationProps {
keyword: string;
@@ -61,18 +85,19 @@
const userVisible = ref(false);
const orgVisible = ref(false);
const currentOrganizationId = ref('');
- const { deleteModal } = useModal();
+ const currentUpdateOrganization = ref();
+ const { deleteModal, openModal } = useModal();
const organizationColumns: MsTableColumn = [
{
title: 'system.organization.ID',
dataIndex: 'num',
width: 100,
- ellipsis: true,
},
{
title: 'system.organization.name',
- dataIndex: 'name',
+ slotName: 'name',
+ editable: true,
},
{
title: 'system.organization.member',
@@ -168,19 +193,38 @@
};
const handleEnableOrDisableOrg = async (record: any, isEnable = true) => {
- try {
- await enableOrDisableOrg(record.id, isEnable);
- Message.success(t('common.updateSuccess'));
- fetchData();
- } catch (error) {
- // eslint-disable-next-line no-console
- console.error(error);
- }
+ const title = isEnable ? t('system.organization.enableTitle') : t('system.organization.enableTitle');
+ const content = isEnable ? t('system.organization.enableContent') : t('system.organization.endContent');
+ const okText = isEnable ? t('common.confirmEnable') : t('common.confirmClose');
+ openModal({
+ type: 'warning',
+ cancelText: t('common.cancel'),
+ title,
+ content,
+ okText,
+ onBeforeOk: async () => {
+ try {
+ await enableOrDisableOrg(record.id, isEnable);
+ Message.success(isEnable ? t('common.enableSuccess') : t('common.closeSuccess'));
+ fetchData();
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.error(error);
+ }
+ },
+ hideCancel: false,
+ });
};
const showOrganizationModal = (record: any) => {
currentOrganizationId.value = record.id;
orgVisible.value = true;
+ currentUpdateOrganization.value = {
+ id: record.id,
+ name: record.name,
+ description: record.description,
+ memberIds: record.orgAdmins.map((item: any) => item.id) || [],
+ };
};
const showAddUserModal = (record: any) => {
@@ -190,6 +234,7 @@
const handleProjectDrawerCancel = () => {
currentProjectDrawer.visible = false;
+ fetchData();
};
const showProjectDrawer = (record: TableData) => {
@@ -205,13 +250,27 @@
const handleUserDrawerCancel = () => {
currentUserDrawer.visible = false;
+ fetchData();
};
const handleAddUserModalCancel = () => {
userVisible.value = false;
+ fetchData();
};
const handleAddOrgModalCancel = () => {
orgVisible.value = false;
+ fetchData();
+ };
+
+ const handleRevokeDelete = async (record: TableData) => {
+ try {
+ await revokeDeleteOrg(record.id);
+ Message.success(t('common.revokeDeleteSuccess'));
+ fetchData();
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.error(error);
+ }
};
watch(
diff --git a/frontend/src/views/setting/system/organizationAndProject/components/userDrawer.vue b/frontend/src/views/setting/system/organizationAndProject/components/userDrawer.vue
index f546183ab9..ecb52caccd 100644
--- a/frontend/src/views/setting/system/organizationAndProject/components/userDrawer.vue
+++ b/frontend/src/views/setting/system/organizationAndProject/components/userDrawer.vue
@@ -21,6 +21,12 @@
>
+
+ {{ record.name }}
+ {{
+ `(${t('common.admin')})`
+ }}
+