feat(系统设置): 系统组织移除

This commit is contained in:
RubyLiu 2023-08-14 19:15:04 +08:00 committed by fit2-zhao
parent 1bfa2a611f
commit 2f472293df
11 changed files with 144 additions and 18 deletions

View File

@ -30,3 +30,9 @@ export function addUserToOrgOrProject(data: AddUserToOrgOrProjectParams) {
export function getUserByOrganizationOrProject(sourceId: string) {
return MSR.get({ url: `${orgUrl.getUserByOrgOrProjectUrl}${sourceId}` });
}
// 删除组织或项目成员
export function deleteUserFromOrgOrProject(sourceId: string, userId: string, isOrg = true) {
return MSR.get({
url: `${isOrg ? orgUrl.getDeleteOrgMemberUrl : orgUrl.getDeleteProjectMemberUrl}${sourceId}/${userId}`,
});
}

View File

@ -197,7 +197,7 @@
};
watch(
() => props.treeData,
(newVal, oldVal) => {
(newVal) => {
treeList.value = newVal;
transferData = getTransferData(treeList.value, []);
},

View File

@ -0,0 +1,47 @@
<template>
<MsPopconfirm
v-model:visible="currentVisible"
:ok-text="t('common.remove')"
:cancel-text="t('common.cancel')"
type="error"
:title="props.title"
:sub-title-tip="props.subTitleTip"
@confirm="handleOk"
@cancel="handleCancel"
>
<MsButton @click="showPopconfirm">{{ t('common.remove') }}</MsButton>
</MsPopconfirm>
</template>
<script setup lang="ts">
import { useI18n } from '@/hooks/useI18n';
import { ref } from 'vue';
import MsButton from '@/components/pure/ms-button/index.vue';
import MsPopconfirm from '@/components/pure/ms-popconfirm/index.vue';
const props = defineProps<{
title: string;
subTitleTip: string;
}>();
const emit = defineEmits<{
(e: 'ok'): void;
}>();
const currentVisible = ref(false);
const handleCancel = () => {
currentVisible.value = false;
};
const showPopconfirm = () => {
currentVisible.value = true;
};
const handleOk = () => {
emit('ok');
currentVisible.value = false;
};
const { t } = useI18n();
</script>

View File

@ -32,7 +32,7 @@
placeholder?: string;
type?: 'organization' | 'usergroup';
sourceId?: string;
disabledKey?: 'disabled' | 'memberFlag' | 'adminFlag';
disabledKey?: 'disabled' | 'memberFlag';
}
export interface UserItem {
@ -41,7 +41,6 @@
email: string;
disabled?: boolean;
memberFlag?: boolean;
adminFlag?: boolean;
}
const fieldNames = { value: 'id', label: 'name' };

View File

@ -190,8 +190,11 @@ export default function useTableProps(
setTableErrorStatus('error');
} finally {
setLoading(false);
// eslint-disable-next-line no-console
if (propsRes.value.debug) console.info(propsRes.value);
// debug 模式下打印属性
if (propsRes.value.debug && import.meta.env.DEV) {
// eslint-disable-next-line no-console
console.log('Table propsRes: ', propsRes.value);
}
}
};

View File

@ -1,3 +1,30 @@
export default {
'common.pleaseSelectMember': 'Please select member',
'common.add': 'Add',
'common.edit': 'Edit',
'common.delete': 'Delete',
'common.save': 'Save',
'common.cancel': 'Cancel',
'common.confirm': 'Confirm',
'common.confirmDelete': 'Confirm delete',
'common.search': 'Search',
'common.reset': 'Reset',
'common.retry': 'Retry',
'common.all': 'All',
'common.operation': 'Operation',
'common.remove': 'Remove',
'common.revoked': 'Revoked',
'common.deleteConfirm': 'Confirm delete?',
'common.deleteSuccess': 'Delete success',
'common.deleteFailed': 'Delete failed',
'common.addSuccess': 'Add success',
'common.addFailed': 'Add failed',
'common.editSuccess': 'Edit success',
'common.editFailed': 'Edit failed',
'common.saveSuccess': 'Save success',
'common.saveFailed': 'Save failed',
'common.operationSuccess': 'Operation success',
'common.operationFailed': 'Operation failed',
'common.removeSuccess': 'Remove success',
'common.removeFailed': 'Remove failed',
};

View File

@ -1,3 +1,30 @@
export default {
'common.pleaseSelectMember': '请选择成员',
'common.add': '添加',
'common.edit': '编辑',
'common.delete': '删除',
'common.save': '保存',
'common.cancel': '取消',
'common.confirm': '确认',
'common.confirmDelete': '确认删除',
'common.search': '搜索',
'common.reset': '重置',
'common.retry': '重试',
'common.all': '全部',
'common.operation': '操作',
'common.remove': '移除',
'common.revoked': '已撤销',
'common.deleteConfirm': '确认删除?',
'common.deleteSuccess': '删除成功',
'common.deleteFailed': '删除失败',
'common.addSuccess': '添加成功',
'common.addFailed': '添加失败',
'common.editSuccess': '编辑成功',
'common.editFailed': '编辑失败',
'common.saveSuccess': '保存成功',
'common.saveFailed': '保存失败',
'common.operationSuccess': '操作成功',
'common.operationFailed': '操作失败',
'common.removeSuccess': '移除成功',
'common.removeFailed': '移除失败',
};

View File

@ -189,7 +189,8 @@
() => props.keyword,
() => {
fetchData();
}
},
{ immediate: true }
);
</script>

View File

@ -22,7 +22,11 @@
</div>
<ms-base-table class="mt-[16px]" v-bind="propsRes" v-on="propsEvent">
<template #operation="{ record }">
<ms-button @click="handleRemove(record)">{{ t('system.organization.remove') }}</ms-button>
<MsRemoveButton
:title="t('system.organization.removeName', { name: record.name })"
:sub-title-tip="t('system.organization.removeTip')"
@ok="handleRemove(record)"
/>
</template>
</ms-base-table>
</div>
@ -31,7 +35,10 @@
</template>
<script lang="ts" setup>
import { postUserTableByOrgId } from '@/api/modules/setting/system/organizationAndProject';
import {
postUserTableByOrgId,
deleteUserFromOrgOrProject,
} from '@/api/modules/setting/system/organizationAndProject';
import { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable';
import { useI18n } from '@/hooks/useI18n';
@ -39,8 +46,8 @@
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import AddUserModal from './addUserModal.vue';
import { TableData } from '@arco-design/web-vue';
import MsButton from '@/components/pure/ms-button/index.vue';
import { TableData, Message } from '@arco-design/web-vue';
import MsRemoveButton from '@/components/bussiness/ms-remove-button/MsRemoveButton.vue';
export interface projectDrawerProps {
visible: boolean;
@ -71,7 +78,7 @@
title: 'system.organization.phone',
dataIndex: 'phone',
},
{ title: 'system.organization.operation', dataIndex: 'operation' },
{ title: 'system.organization.operation', slotName: 'operation' },
];
const { propsRes, propsEvent, loadList, setLoadListParams, setKeyword } = useTable(postUserTableByOrgId, {
@ -93,6 +100,7 @@
};
const fetchData = async () => {
setLoadListParams({ organizationId: props.organizationId });
await loadList();
};
@ -104,16 +112,21 @@
userVisible.value = false;
};
const handleRemove = (record: TableData) => {
// TODO: remove user
// eslint-disable-next-line no-console
console.log(record);
const handleRemove = async (record: TableData) => {
deleteUserFromOrgOrProject(props.organizationId, record.id)
.then(() => {
Message.success(t('common.removeSuccess'));
fetchData();
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error(error);
});
};
watch(
() => props.organizationId,
(organizationId) => {
setLoadListParams({ organizationId });
() => {
fetchData();
}
);

View File

@ -6,6 +6,8 @@ export default {
'system.organization.edit': 'Edit',
'system.organization.save': 'Save',
'system.organization.end': 'End',
'system.organization.removeName': 'Confirm to remove {name} this user',
'system.organization.removeTip': 'After removal, the organization permission will be lost',
'system.organization.addMember': 'Add Member',
'system.organization.addMemberPlaceholder': 'Please select member',
'system.organization.addMemberRequired': 'Please select member',

View File

@ -6,7 +6,8 @@ export default {
'system.organization.edit': '编辑',
'system.organization.save': '保存',
'system.organization.end': '结束',
'system.organization.remove': '移除',
'system.organization.removeName': '确认移除 {name} 这个用户吗',
'system.organization.removeTip': '移除后,将失去组织权限',
'system.organization.addMember': '添加成员',
'system.organization.addMemberPlaceholder': '请选择成员',
'system.organization.addMemberRequired': '请选择成员',