feat(系统设置): 系统用户组管理新增用户接口对接
This commit is contained in:
parent
d1326f9c8f
commit
2dfd4588d9
|
@ -8,6 +8,8 @@ import {
|
||||||
editGlobalUSettingUrl,
|
editGlobalUSettingUrl,
|
||||||
postUserByUserGroupUrl,
|
postUserByUserGroupUrl,
|
||||||
deleteUserFromUserGroupUrl,
|
deleteUserFromUserGroupUrl,
|
||||||
|
getUserListUrl,
|
||||||
|
addUserToUserGroupUrl,
|
||||||
} from '@/api/requrls/setting/usergroup';
|
} from '@/api/requrls/setting/usergroup';
|
||||||
import { TableQueryParams, CommonList } from '@/models/common';
|
import { TableQueryParams, CommonList } from '@/models/common';
|
||||||
import { UserGroupItem, UserGroupAuthSeting, SaveGlobalUSettingData, UserTableItem } from '@/models/setting/usergroup';
|
import { UserGroupItem, UserGroupAuthSeting, SaveGlobalUSettingData, UserTableItem } from '@/models/setting/usergroup';
|
||||||
|
@ -53,3 +55,11 @@ export function postUserByUserGroup(data: TableQueryParams) {
|
||||||
export function deleteUserFromUserGroup(id: string) {
|
export function deleteUserFromUserGroup(id: string) {
|
||||||
return MSR.get<string>({ url: `${deleteUserFromUserGroupUrl}${id}` });
|
return MSR.get<string>({ url: `${deleteUserFromUserGroupUrl}${id}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getUserList() {
|
||||||
|
return MSR.get<UserTableItem[]>({ url: getUserListUrl });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addUserToUserGroup(data: { roleId: string; userIds: string[] }) {
|
||||||
|
return MSR.post<string>({ url: addUserToUserGroupUrl, data });
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ export const deleteUserGroupU = `/user/role/global/delete/`;
|
||||||
/** 根据用户组获取用户列表 */
|
/** 根据用户组获取用户列表 */
|
||||||
export const postUserByUserGroupUrl = `/user/role/relation/global/list`;
|
export const postUserByUserGroupUrl = `/user/role/relation/global/list`;
|
||||||
/** 创建用户组添加用户 */
|
/** 创建用户组添加用户 */
|
||||||
export const addUserToUserGroupU = `/user/role/relation/global/add/`;
|
export const addUserToUserGroupUrl = `/user/role/relation/global/add`;
|
||||||
/** 删除用户组用户 */
|
/** 删除用户组用户 */
|
||||||
export const deleteUserFromUserGroupUrl = `/user/role/relation/global/delete/`;
|
export const deleteUserFromUserGroupUrl = `/user/role/relation/global/delete/`;
|
||||||
|
/** 获取所有用户 */
|
||||||
|
export const getUserListUrl = '/system/user/list';
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
/** 表格样式 **/
|
/** 表格样式 **/
|
||||||
|
.arco-table-container {
|
||||||
|
border-top: none !important;
|
||||||
|
border-right: none !important;
|
||||||
|
border-left: none !important;
|
||||||
|
}
|
||||||
.arco-table-cell {
|
.arco-table-cell {
|
||||||
.circle {
|
.circle {
|
||||||
@apply inline-block rounded-full;
|
@apply inline-block rounded-full;
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
}
|
}
|
||||||
switch (attrs.size) {
|
switch (attrs.size) {
|
||||||
case 'small':
|
case 'small':
|
||||||
return '10px';
|
return '15px';
|
||||||
case 'mini':
|
case 'mini':
|
||||||
return '10px';
|
return '10px';
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -51,6 +51,7 @@ export default function useTableProps(
|
||||||
enableDrag: false,
|
enableDrag: false,
|
||||||
showSelectAll: true,
|
showSelectAll: true,
|
||||||
showSetting: true,
|
showSetting: true,
|
||||||
|
columnResizable: true,
|
||||||
...props,
|
...props,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,18 @@ export interface SaveGlobalUSettingData {
|
||||||
|
|
||||||
export interface UserTableItem {
|
export interface UserTableItem {
|
||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
|
||||||
name: string;
|
name: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
password: string;
|
||||||
|
enable: boolean;
|
||||||
|
createTime: number;
|
||||||
|
updateTime: number;
|
||||||
|
language: string;
|
||||||
|
lastOrganizationId: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
|
source: string;
|
||||||
|
lastProjectId: string;
|
||||||
|
createUser: string;
|
||||||
|
updateUser: string;
|
||||||
|
deleted: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,4 +92,3 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@/models/setting/usergroup
|
|
||||||
|
|
|
@ -3,12 +3,14 @@
|
||||||
v-model:visible="currentVisible"
|
v-model:visible="currentVisible"
|
||||||
width="680px"
|
width="680px"
|
||||||
:ok-text="t('system.userGroup.add')"
|
:ok-text="t('system.userGroup.add')"
|
||||||
@ok="handelOk"
|
unmount-on-close
|
||||||
|
:ok-loading="loading"
|
||||||
|
:on-before-ok="handleBeforeOk"
|
||||||
@cancel="handleCancel"
|
@cancel="handleCancel"
|
||||||
>
|
>
|
||||||
<template #title> {{ t('system.userGroup.addUser') }} </template>
|
<template #title> {{ t('system.userGroup.addUser') }} </template>
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<a-form :model="form" size="large" :style="{ width: '600px' }" layout="vertical">
|
<a-form ref="formRef" :model="form" size="large" :style="{ width: '600px' }" layout="vertical">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
field="name"
|
field="name"
|
||||||
:label="t('system.userGroup.user')"
|
:label="t('system.userGroup.user')"
|
||||||
|
@ -39,14 +41,24 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
import { reactive, ref, watchEffect, onUnmounted } from 'vue';
|
import { reactive, ref, watchEffect, onUnmounted, onMounted } from 'vue';
|
||||||
import { UserOption } from '@/models/setting/usergroup';
|
import { UserTableItem } from '@/models/setting/usergroup';
|
||||||
|
import { useUserGroupStore } from '@/store';
|
||||||
|
import { getUserList, addUserToUserGroup } from '@/api/modules/setting/usergroup';
|
||||||
|
import type { FormInstance, ValidatedError } from '@arco-design/web-vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const store = useUserGroupStore();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'cancel'): void;
|
||||||
|
(e: 'submit', value: string[]): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const fieldNames = { value: 'id', label: 'name' };
|
const fieldNames = { value: 'id', label: 'name' };
|
||||||
|
|
||||||
const currentVisible = ref(props.visible);
|
const currentVisible = ref(props.visible);
|
||||||
|
@ -58,38 +70,38 @@
|
||||||
|
|
||||||
const labelCache = new Map();
|
const labelCache = new Map();
|
||||||
|
|
||||||
const allOption: UserOption[] = [
|
const allOption = ref<UserTableItem[]>([]);
|
||||||
{ id: 1, name: 'llb', email: 'name@163.com' },
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: 'rubyliu',
|
|
||||||
email: 'rubyliu@163.com',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
name: 'jack',
|
|
||||||
email: 'jack@163.com',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const userOptions = ref<UserOption[]>(allOption);
|
const userOptions = ref<UserTableItem[]>([]);
|
||||||
|
|
||||||
|
const formRef = ref<FormInstance>();
|
||||||
|
|
||||||
|
const initUserList = async () => {
|
||||||
|
const res = await getUserList();
|
||||||
|
allOption.value = res;
|
||||||
|
userOptions.value = res;
|
||||||
|
};
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
currentVisible.value = props.visible;
|
currentVisible.value = props.visible;
|
||||||
});
|
});
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: 'cancel'): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handelOk = () => {
|
const handleBeforeOk = () => {
|
||||||
// eslint-disable-next-line no-console
|
loading.value = true;
|
||||||
console.log('ok');
|
formRef.value?.validate(async (errors: undefined | Record<string, ValidatedError>) => {
|
||||||
handleCancel();
|
if (errors) {
|
||||||
|
loading.value = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
await addUserToUserGroup({ roleId: store.currentId, userIds: form.name });
|
||||||
|
return true;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearch = (value: string) => {
|
const handleSearch = (value: string) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
@ -98,11 +110,18 @@
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}, 60);
|
}, 60);
|
||||||
} else {
|
} else {
|
||||||
userOptions.value = allOption;
|
userOptions.value = allOption.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initUserList();
|
||||||
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
labelCache.clear();
|
labelCache.clear();
|
||||||
|
form.name = [];
|
||||||
|
loading.value = false;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -114,4 +133,3 @@
|
||||||
color: var(--color-text-4);
|
color: var(--color-text-4);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@/models/setting/usergroup
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="relative">
|
<div class="usergroup-auth-table">
|
||||||
<a-table
|
<a-table
|
||||||
:span-method="dataSpanMethod"
|
:span-method="dataSpanMethod"
|
||||||
:scroll="{ y: '860px', x: '800px' }"
|
:scroll="{ y: '860px', x: '800px' }"
|
||||||
|
@ -284,15 +284,23 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.action {
|
.usergroup-auth-table {
|
||||||
position: absolute;
|
position: relative;
|
||||||
right: 24px;
|
height: 100vh;
|
||||||
bottom: 0;
|
:deep(.arco-table-container) {
|
||||||
left: 24px;
|
border-top: 1px solid var(--color-text-n8) !important;
|
||||||
display: flex;
|
border-right: 1px solid var(--color-text-n8) !important;
|
||||||
justify-content: space-between;
|
border-left: 1px solid var(--color-text-n8) !important;
|
||||||
align-items: center;
|
}
|
||||||
width: calc(100% - 24px);
|
.action {
|
||||||
|
position: absolute;
|
||||||
|
right: 24px;
|
||||||
|
bottom: 0;
|
||||||
|
left: 24px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
width: calc(100% - 24px);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@/models/setting/usergroup @/api/modules/setting/usergroup
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
<a-button type="primary" @click="handleAddUser">{{ t('system.userGroup.quickAddUser') }}</a-button>
|
||||||
|
<MsBaseTable class="mt-[16px]" v-bind="propsRes" v-on="propsEvent">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<ms-button @click="handleRemove(record)">{{ t('system.userGroup.remove') }}</ms-button>
|
<ms-button @click="handleRemove(record)">{{ t('system.userGroup.remove') }}</ms-button>
|
||||||
</template>
|
</template>
|
||||||
</MsBaseTable>
|
</MsBaseTable>
|
||||||
|
<AddUserModal :visible="userVisible" @cancel="handleAddUserModalCancel" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -11,16 +13,18 @@
|
||||||
import useTable from '@/components/pure/ms-table/useTable';
|
import useTable from '@/components/pure/ms-table/useTable';
|
||||||
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
|
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
|
||||||
import { useUserGroupStore, useTableStore } from '@/store';
|
import { useUserGroupStore, useTableStore } from '@/store';
|
||||||
import { watchEffect } from 'vue';
|
import { watchEffect, ref } from 'vue';
|
||||||
import { postUserByUserGroup, deleteUserFromUserGroup } from '@/api/modules/setting/usergroup';
|
import { postUserByUserGroup, deleteUserFromUserGroup } from '@/api/modules/setting/usergroup';
|
||||||
import { UserTableItem } from '@/models/setting/usergroup';
|
import { UserTableItem } from '@/models/setting/usergroup';
|
||||||
import { TableKeyEnum } from '@/enums/tableEnum';
|
import { TableKeyEnum } from '@/enums/tableEnum';
|
||||||
import MsButton from '@/components/pure/ms-button/index.vue';
|
import MsButton from '@/components/pure/ms-button/index.vue';
|
||||||
import { MsTableColumn } from '@/components/pure/ms-table/type';
|
import { MsTableColumn } from '@/components/pure/ms-table/type';
|
||||||
|
import AddUserModal from './addUserModal.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const store = useUserGroupStore();
|
const store = useUserGroupStore();
|
||||||
const tableStore = useTableStore();
|
const tableStore = useTableStore();
|
||||||
|
const userVisible = ref(false);
|
||||||
|
|
||||||
const userGroupUsercolumns: MsTableColumn = [
|
const userGroupUsercolumns: MsTableColumn = [
|
||||||
{
|
{
|
||||||
|
@ -63,8 +67,19 @@
|
||||||
await loadList();
|
await loadList();
|
||||||
};
|
};
|
||||||
const handleRemove = async (record: UserTableItem) => {
|
const handleRemove = async (record: UserTableItem) => {
|
||||||
await deleteUserFromUserGroup(record.id);
|
try {
|
||||||
await fetchData();
|
await deleteUserFromUserGroup(record.id);
|
||||||
|
await fetchData();
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleAddUser = () => {
|
||||||
|
userVisible.value = true;
|
||||||
|
};
|
||||||
|
const handleAddUserModalCancel = () => {
|
||||||
|
userVisible.value = false;
|
||||||
};
|
};
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (store.currentId) {
|
if (store.currentId) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ export default {
|
||||||
operation: 'Operation',
|
operation: 'Operation',
|
||||||
phone: 'Phone',
|
phone: 'Phone',
|
||||||
remove: 'Remove',
|
remove: 'Remove',
|
||||||
|
quickAddUser: 'Quick add user',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
permission: {
|
permission: {
|
||||||
|
|
|
@ -52,6 +52,7 @@ export default {
|
||||||
operation: '操作',
|
operation: '操作',
|
||||||
phone: '手机',
|
phone: '手机',
|
||||||
remove: '移除',
|
remove: '移除',
|
||||||
|
quickAddUser: '快速添加用户',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
permission: {
|
permission: {
|
||||||
|
|
Loading…
Reference in New Issue