From 99fd8437c72837c1177b37379af86f01ebe65bfe Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Tue, 12 Sep 2023 10:51:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=92=8C=E9=A1=B9=E7=9B=AE=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project-management/projectMember.ts | 4 +- frontend/src/api/modules/setting/member.ts | 8 +-- .../business/ms-user-selector/utils.ts | 17 ++++++ .../components/pure/ms-table/base-table.vue | 12 +++++ .../member/components/addMemberModal.vue | 24 ++++++--- .../projectAndPermission/member/index.vue | 9 +++- .../member/components/addMemberModal.vue | 54 ++++++++++--------- .../setting/organization/member/index.vue | 10 +++- 8 files changed, 97 insertions(+), 41 deletions(-) diff --git a/frontend/src/api/modules/project-management/projectMember.ts b/frontend/src/api/modules/project-management/projectMember.ts index 075c7fc794..63ba167059 100644 --- a/frontend/src/api/modules/project-management/projectMember.ts +++ b/frontend/src/api/modules/project-management/projectMember.ts @@ -46,6 +46,6 @@ export function getProjectUserGroup(projectId: string) { } // 项目成员下拉选项 -export function getProjectMemberOptions(projectId: string) { - return MSR.get({ url: ProjectMemberOptions, params: projectId }); +export function getProjectMemberOptions(projectId: string, keyword?: string) { + return MSR.get({ url: `${ProjectMemberOptions}/${projectId}`, params: { keyword } }); } diff --git a/frontend/src/api/modules/setting/member.ts b/frontend/src/api/modules/setting/member.ts index 5a4b4df963..d57e88ca18 100644 --- a/frontend/src/api/modules/setting/member.ts +++ b/frontend/src/api/modules/setting/member.ts @@ -40,10 +40,10 @@ export function getGlobalUserGroup(organizationId: string) { return MSR.get({ url: getUserGroupList, params: organizationId }); } // 获取系统用户下拉 -export function getUser(organizationId: string) { - return MSR.get({ url: getUserList, params: organizationId }); +export function getUser(organizationId: string, keyword: string) { + return MSR.get({ url: `${getUserList}/${organizationId}`, params: { keyword } }); } // 获取组织下边的项目 -export function getProjectList(organizationId: string) { - return MSR.get({ url: getProjectListUrl, params: organizationId }); +export function getProjectList(organizationId: string, keyword?: string) { + return MSR.get({ url: `${getProjectListUrl}/${organizationId}`, params: { keyword } }); } diff --git a/frontend/src/components/business/ms-user-selector/utils.ts b/frontend/src/components/business/ms-user-selector/utils.ts index a83716aab9..8a60c6f7ed 100644 --- a/frontend/src/components/business/ms-user-selector/utils.ts +++ b/frontend/src/components/business/ms-user-selector/utils.ts @@ -5,6 +5,8 @@ import { getUserByProjectByOrg, } from '@/api/modules/setting/organizationAndProject'; import { getOrgUserGroupOption, getSystemUserGroupOption } from '@/api/modules/setting/usergroup'; +import { getUser, getProjectList } from '@/api/modules/setting/member'; +import { getProjectMemberOptions } from '@/api/modules/project-management/projectMember'; // eslint-disable-next-line no-shadow export enum UserRequesetTypeEnum { @@ -17,6 +19,9 @@ export enum UserRequesetTypeEnum { ORGANIZATION_USER_GROUP_ADMIN = 'ORGANIZATION_USER_GROUP_ADMIN', ORGANIZATION_PROJECT = 'ORGANIZATION_PROJECT', ORGANIZATION_PROJECT_ADMIN = 'ORGANIZATION_PROJECT_ADMIN', + SYSTEM_ORGANIZATION_PROJECT = 'SYSTEM_ORGANIZATION_PROJECT', + SYSTEM_ORGANIZATION_MEMBER = 'SYSTEM_ORGANIZATION_MEMBER', + PROJECT_PERMISSION_MEMBER = 'PROJECT_PERMISSION_MEMBER', } export default function initOptionsFunc(type: string, params: Record) { if (type === UserRequesetTypeEnum.SYSTEM_USER_GROUP) { @@ -43,4 +48,16 @@ export default function initOptionsFunc(type: string, params: Record diff --git a/frontend/src/views/project-management/projectAndPermission/member/components/addMemberModal.vue b/frontend/src/views/project-management/projectAndPermission/member/components/addMemberModal.vue index 85ae133287..8f9e41c5f1 100644 --- a/frontend/src/views/project-management/projectAndPermission/member/components/addMemberModal.vue +++ b/frontend/src/views/project-management/projectAndPermission/member/components/addMemberModal.vue @@ -15,9 +15,13 @@ asterisk-position="end" :rules="[{ required: true, message: t('project.member.selectMemberEmptyTip') }]" > - - {{ item.name }} - + (false); - const initFormValue: ActionProjectMember = { + const initFormValue: AddProjectMember = { roleIds: ['project_member'], userIds: [], - projectId: lastProjectId, + projectId: lastProjectId as string, }; - const form = ref({ ...initFormValue }); + const form = ref({ ...initFormValue }); const memberFormRef = ref(null); diff --git a/frontend/src/views/project-management/projectAndPermission/member/index.vue b/frontend/src/views/project-management/projectAndPermission/member/index.vue index 43816109db..3bdb7e3dca 100644 --- a/frontend/src/views/project-management/projectAndPermission/member/index.vue +++ b/frontend/src/views/project-management/projectAndPermission/member/index.vue @@ -41,6 +41,7 @@ v-else v-model="record.selectUserList" multiple + class="w-[260px]" :max-tag-count="2" @popup-visible-change="(value) => userGroupChange(value, record)" > @@ -62,6 +63,7 @@ position="br" :title="t('project.member.deleteMemberTip', { name: characterLimit(record.name) })" :sub-title-tip="t('project.member.subTitle')" + :loading="deleteLoading" @ok="removeMember(record)" /> @@ -157,7 +159,7 @@ title: 'project.member.tableColumnActions', slotName: 'action', fixed: 'right', - width: 80, + width: 100, showInTable: true, }, ]; @@ -244,7 +246,10 @@ }; // 移除项目成员 + const deleteLoading = ref(false); + const removeMember = async (record: ProjectMemberItem) => { + deleteLoading.value = true; try { if (lastProjectId && record.id) { await removeProjectMember(lastProjectId, record.id); @@ -253,6 +258,8 @@ } } catch (error) { console.log(error); + } finally { + deleteLoading.value = false; } }; diff --git a/frontend/src/views/setting/organization/member/components/addMemberModal.vue b/frontend/src/views/setting/organization/member/components/addMemberModal.vue index 07a0c70d37..607e9ac4d2 100644 --- a/frontend/src/views/setting/organization/member/components/addMemberModal.vue +++ b/frontend/src/views/setting/organization/member/components/addMemberModal.vue @@ -16,16 +16,16 @@
+ - - {{ item.name }} - + + - - {{ item.name }} - + (); const dialogVisible = ref(false); - const memberList = ref([]); const title = ref(''); const type = ref(''); const emits = defineEmits<{ @@ -95,13 +93,20 @@ const confirmLoading = ref(false); const memberFormRef = ref(null); - const initFormValue = { + export interface InitFromType { + organizationId?: string; + userRoleIds: string[]; + memberIds: string[]; + projectIds: string[]; + } + + const initFormValue: InitFromType = { organizationId: userStore.$state?.lastOrganizationId, userRoleIds: ['org_member'], memberIds: [], projectIds: [], }; - const form = ref({ ...initFormValue }); + const form = ref({ ...initFormValue }); const handleCancel = () => { memberFormRef.value?.resetFields(); form.value = { ...initFormValue }; @@ -157,12 +162,9 @@ } }); }; - const getUserOptions = async () => { - memberList.value = await getUser(lastOrganizationId); - }; + watchEffect(() => { dialogVisible.value = props.visible; - if (props.visible) getUserOptions(); }); watch( () => dialogVisible.value, diff --git a/frontend/src/views/setting/organization/member/index.vue b/frontend/src/views/setting/organization/member/index.vue index fd842009fa..db2b1040b7 100644 --- a/frontend/src/views/setting/organization/member/index.vue +++ b/frontend/src/views/setting/organization/member/index.vue @@ -37,6 +37,7 @@ multiple :max-tag-count="2" size="small" + class="w-[260px]" @change="(value) => selectUserOrProject(value, record, 'project')" @popup-visible-change="visibleChange($event, record, 'project')" > @@ -57,6 +58,7 @@ v-model="record.selectUserList" multiple :max-tag-count="2" + class="w-[260px]" @change="(value) => selectUserOrProject(value, record, 'user')" @popup-visible-change="(value) => visibleChange(value, record, 'user')" > @@ -79,6 +81,7 @@ position="br" :title="t('organization.member.deleteMemberTip', { name: characterLimit(record.name) })" :sub-title-tip="t('organization.member.subTitle')" + :loading="deleteLoading" @ok="deleteMember(record)" /> @@ -126,7 +129,7 @@ import { useTableStore, useUserStore } from '@/store'; import type { MsTableColumn } from '@/components/pure/ms-table/type'; import type { MemberItem, AddorUpdateMemberModel, LinkList, BatchAddProjectModel } from '@/models/setting/member'; - import { characterLimit } from '@/utils'; + import { characterLimit, findNodeByKey } from '@/utils'; import MsTagGroup from '@/components/pure/ms-tag/ms-tag-group.vue'; const tableStore = useTableStore(); @@ -230,13 +233,18 @@ AddMemberRef.value.edit(record); } }; + + const deleteLoading = ref(false); const deleteMember = async (record: MemberItem) => { + deleteLoading.value = true; try { if (lastOrganizationId) await deleteMemberReq(lastOrganizationId, record.id); Message.success(t('organization.member.deleteMemberSuccess')); initData(); } catch (error) { console.log(error); + } finally { + deleteLoading.value = false; } }; const handleTableSelect = (selectArr: (string | number)[]) => {