From 2dfd4588d9103fbd3436ca306b7493f0817a41cd Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Mon, 24 Jul 2023 18:42:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7=E7=BB=84=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/modules/setting/usergroup.ts | 10 +++ frontend/src/api/requrls/setting/usergroup.ts | 4 +- frontend/src/assets/style/arco-reset.less | 5 ++ .../components/pure/ms-table/base-table.vue | 2 +- .../src/components/pure/ms-table/useTable.ts | 1 + frontend/src/models/setting/usergroup.ts | 12 +++- .../components/addUserGroupModal.vue | 1 - .../usergroup/components/addUserModal.vue | 72 ++++++++++++------- .../system/usergroup/components/authTable.vue | 30 +++++--- .../system/usergroup/components/userTable.vue | 23 ++++-- .../setting/system/usergroup/locale/en-US.ts | 1 + .../setting/system/usergroup/locale/zh-CN.ts | 1 + 12 files changed, 116 insertions(+), 46 deletions(-) diff --git a/frontend/src/api/modules/setting/usergroup.ts b/frontend/src/api/modules/setting/usergroup.ts index 18649ba49d..6c2c9026a9 100644 --- a/frontend/src/api/modules/setting/usergroup.ts +++ b/frontend/src/api/modules/setting/usergroup.ts @@ -8,6 +8,8 @@ import { editGlobalUSettingUrl, postUserByUserGroupUrl, deleteUserFromUserGroupUrl, + getUserListUrl, + addUserToUserGroupUrl, } from '@/api/requrls/setting/usergroup'; import { TableQueryParams, CommonList } from '@/models/common'; import { UserGroupItem, UserGroupAuthSeting, SaveGlobalUSettingData, UserTableItem } from '@/models/setting/usergroup'; @@ -53,3 +55,11 @@ export function postUserByUserGroup(data: TableQueryParams) { export function deleteUserFromUserGroup(id: string) { return MSR.get({ url: `${deleteUserFromUserGroupUrl}${id}` }); } + +export function getUserList() { + return MSR.get({ url: getUserListUrl }); +} + +export function addUserToUserGroup(data: { roleId: string; userIds: string[] }) { + return MSR.post({ url: addUserToUserGroupUrl, data }); +} diff --git a/frontend/src/api/requrls/setting/usergroup.ts b/frontend/src/api/requrls/setting/usergroup.ts index 33ef01db69..a54df0ab51 100644 --- a/frontend/src/api/requrls/setting/usergroup.ts +++ b/frontend/src/api/requrls/setting/usergroup.ts @@ -16,6 +16,8 @@ export const deleteUserGroupU = `/user/role/global/delete/`; /** 根据用户组获取用户列表 */ 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 getUserListUrl = '/system/user/list'; diff --git a/frontend/src/assets/style/arco-reset.less b/frontend/src/assets/style/arco-reset.less index ffeac6778b..39a8abfa16 100644 --- a/frontend/src/assets/style/arco-reset.less +++ b/frontend/src/assets/style/arco-reset.less @@ -1,4 +1,9 @@ /** 表格样式 **/ +.arco-table-container { + border-top: none !important; + border-right: none !important; + border-left: none !important; +} .arco-table-cell { .circle { @apply inline-block rounded-full; diff --git a/frontend/src/components/pure/ms-table/base-table.vue b/frontend/src/components/pure/ms-table/base-table.vue index a4238edc14..8bb449e7cf 100644 --- a/frontend/src/components/pure/ms-table/base-table.vue +++ b/frontend/src/components/pure/ms-table/base-table.vue @@ -152,7 +152,7 @@ } switch (attrs.size) { case 'small': - return '10px'; + return '15px'; case 'mini': return '10px'; default: diff --git a/frontend/src/components/pure/ms-table/useTable.ts b/frontend/src/components/pure/ms-table/useTable.ts index c1924ce38a..bb9430fd29 100644 --- a/frontend/src/components/pure/ms-table/useTable.ts +++ b/frontend/src/components/pure/ms-table/useTable.ts @@ -51,6 +51,7 @@ export default function useTableProps( enableDrag: false, showSelectAll: true, showSetting: true, + columnResizable: true, ...props, }; diff --git a/frontend/src/models/setting/usergroup.ts b/frontend/src/models/setting/usergroup.ts index 11418dbefe..7c25a6ef88 100644 --- a/frontend/src/models/setting/usergroup.ts +++ b/frontend/src/models/setting/usergroup.ts @@ -94,8 +94,18 @@ export interface SaveGlobalUSettingData { export interface UserTableItem { id: string; - userId: string; name: string; email: string; + password: string; + enable: boolean; + createTime: number; + updateTime: number; + language: string; + lastOrganizationId: string; phone: string; + source: string; + lastProjectId: string; + createUser: string; + updateUser: string; + deleted: boolean; } diff --git a/frontend/src/views/setting/system/usergroup/components/addUserGroupModal.vue b/frontend/src/views/setting/system/usergroup/components/addUserGroupModal.vue index 780049b53e..53b0319cf9 100644 --- a/frontend/src/views/setting/system/usergroup/components/addUserGroupModal.vue +++ b/frontend/src/views/setting/system/usergroup/components/addUserGroupModal.vue @@ -92,4 +92,3 @@ }); }; -@/models/setting/usergroup diff --git a/frontend/src/views/setting/system/usergroup/components/addUserModal.vue b/frontend/src/views/setting/system/usergroup/components/addUserModal.vue index e01730be90..23bb4cd0d1 100644 --- a/frontend/src/views/setting/system/usergroup/components/addUserModal.vue +++ b/frontend/src/views/setting/system/usergroup/components/addUserModal.vue @@ -3,12 +3,14 @@ v-model:visible="currentVisible" width="680px" :ok-text="t('system.userGroup.add')" - @ok="handelOk" + unmount-on-close + :ok-loading="loading" + :on-before-ok="handleBeforeOk" @cancel="handleCancel" >
- + import { useI18n } from '@/hooks/useI18n'; - import { reactive, ref, watchEffect, onUnmounted } from 'vue'; - import { UserOption } from '@/models/setting/usergroup'; + import { reactive, ref, watchEffect, onUnmounted, onMounted } from 'vue'; + 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 props = defineProps<{ visible: boolean; }>(); + const store = useUserGroupStore(); + + const emit = defineEmits<{ + (e: 'cancel'): void; + (e: 'submit', value: string[]): void; + }>(); + const fieldNames = { value: 'id', label: 'name' }; const currentVisible = ref(props.visible); @@ -58,38 +70,38 @@ const labelCache = new Map(); - const allOption: UserOption[] = [ - { 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 allOption = ref([]); - const userOptions = ref(allOption); + const userOptions = ref([]); + + const formRef = ref(); + + const initUserList = async () => { + const res = await getUserList(); + allOption.value = res; + userOptions.value = res; + }; watchEffect(() => { currentVisible.value = props.visible; }); - const emit = defineEmits<{ - (e: 'cancel'): void; - }>(); const handleCancel = () => { emit('cancel'); }; - const handelOk = () => { - // eslint-disable-next-line no-console - console.log('ok'); - handleCancel(); + const handleBeforeOk = () => { + loading.value = true; + formRef.value?.validate(async (errors: undefined | Record) => { + if (errors) { + loading.value = false; + return false; + } + await addUserToUserGroup({ roleId: store.currentId, userIds: form.name }); + return true; + }); }; + const handleSearch = (value: string) => { if (value) { loading.value = true; @@ -98,11 +110,18 @@ loading.value = false; }, 60); } else { - userOptions.value = allOption; + userOptions.value = allOption.value; } }; + + onMounted(() => { + initUserList(); + }); + onUnmounted(() => { labelCache.clear(); + form.name = []; + loading.value = false; }); @@ -114,4 +133,3 @@ color: var(--color-text-4); } -@/models/setting/usergroup diff --git a/frontend/src/views/setting/system/usergroup/components/authTable.vue b/frontend/src/views/setting/system/usergroup/components/authTable.vue index 363aefe436..956751e142 100644 --- a/frontend/src/views/setting/system/usergroup/components/authTable.vue +++ b/frontend/src/views/setting/system/usergroup/components/authTable.vue @@ -1,5 +1,5 @@