From 3c30089dfab920c2869ba20ac3e5f3774c12b19e Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 8 Nov 2021 16:14:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E5=B7=A5=E4=BD=9C=E7=A9=BA=E9=97=B4=E6=88=90=E5=91=98?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0=E5=88=B0=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1003797 --user=lyh 5.系统-用户列表增加批量添加到工作空间,工作空间成员列表增加批量操作,支持批量添加到项目,批量添加用户组 https://www.tapd.cn/55049933/s/1065444 --- .../components/settings/system/User.vue | 7 ++- ...er.vue => BatchToProjectGroupCascader.vue} | 57 ++++++++++++++----- .../settings/workspace/WorkspaceMember.vue | 29 +++++++++- 3 files changed, 74 insertions(+), 19 deletions(-) rename frontend/src/business/components/settings/system/components/{ProjectCascader.vue => BatchToProjectGroupCascader.vue} (74%) diff --git a/frontend/src/business/components/settings/system/User.vue b/frontend/src/business/components/settings/system/User.vue index 3197f3c4c8..b30d03d8ec 100644 --- a/frontend/src/business/components/settings/system/User.vue +++ b/frontend/src/business/components/settings/system/User.vue @@ -98,7 +98,8 @@ - + @@ -128,14 +129,15 @@ import { import UserCascader from "@/business/components/settings/system/components/UserCascader"; import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn"; import EditUser from "@/business/components/settings/system/EditUser"; -import ProjectCascader from "@/business/components/settings/system/components/ProjectCascader"; import GroupCascader from "@/business/components/settings/system/components/GroupCascader"; import {logout} from "@/network/user"; import WorkspaceCascader from "@/business/components/settings/system/components/WorkspaceCascader"; +import BatchToProjectGroupCascader from "@/business/components/settings/system/components/BatchToProjectGroupCascader"; export default { name: "MsUser", components: { + BatchToProjectGroupCascader, WorkspaceCascader, GroupCascader, EditUser, @@ -149,7 +151,6 @@ export default { UserImport, MsTableHeaderSelectPopover, UserCascader, - ProjectCascader, ShowMoreBtn }, inject: [ diff --git a/frontend/src/business/components/settings/system/components/ProjectCascader.vue b/frontend/src/business/components/settings/system/components/BatchToProjectGroupCascader.vue similarity index 74% rename from frontend/src/business/components/settings/system/components/ProjectCascader.vue rename to frontend/src/business/components/settings/system/components/BatchToProjectGroupCascader.vue index 1e6923dc0e..0c6cf02642 100644 --- a/frontend/src/business/components/settings/system/components/ProjectCascader.vue +++ b/frontend/src/business/components/settings/system/components/BatchToProjectGroupCascader.vue @@ -23,6 +23,7 @@ import ElUploadList from "element-ui/packages/upload/src/upload-list"; import MsTableButton from '../../../../components/common/components/MsTableButton'; -import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; +import {getCurrentProjectID, getCurrentWorkspaceId, listenGoBack, removeGoBackListener} from "@/common/js/utils"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import {GROUP_PROJECT} from "@/common/js/constants"; export default { - name: "User2ProjectCascader", + name: "BatchToProjectGroupCascader", components: {ElUploadList, MsTableButton, MsDialogFooter}, data() { let validateSelect = (rule, value, callback) => { @@ -78,12 +79,21 @@ export default { label: 'name', lazyLoad(node, resolve) { const {level, value} = node; - if (level === 0) { - self.getWorkspace(resolve); - } else if (level === 1) { - self.getProject(value, resolve); - } else { - resolve([]); + if (self.cascaderLevel === 1) { + if (level === 0) { + self.getProject(getCurrentWorkspaceId(), resolve); + } else { + resolve([]); + } + } else if (self.cascaderLevel === 2) { + // 先加载工作空间 + if (level === 0) { + self.getWorkspace(resolve); + } else if (level === 1) { + self.getProject(value, resolve); + } else { + resolve([]); + } } } }, @@ -95,11 +105,21 @@ export default { title: { type: String, default: '' - } + }, + // 几层 项目/工作空间-项目 + cascaderLevel: { + type: Number, + default: 2 + }, }, created() { this.getProjectUserGroup(); }, + computed: { + cascaderMenuWidth() { + return this.cascaderLevel === 1 ? '560' : '280'; + } + }, methods: { close() { removeGoBackListener(this.close); @@ -148,9 +168,20 @@ export default { }) }, getProjectUserGroup() { - this.$post("/user/group/get", {type: GROUP_PROJECT}, (res) => { - this.projectUserGroups = res.data ? res.data : []; - }) + // 系统菜单显示所有项目类型用户组 + if (this.cascaderLevel === 2) { + this.$post("/user/group/get", {type: GROUP_PROJECT}, (res) => { + this.projectUserGroups = res.data ? res.data : []; + }); + } else if (this.cascaderLevel === 1) { + // 过滤工作空间下用户组 + this.result = this.$post('/user/group/list', { + type: GROUP_PROJECT, + resourceId: getCurrentProjectID() + }, (res) => { + this.projectUserGroups = res.data ? res.data : []; + }); + } } } } @@ -174,6 +205,6 @@ export default { /deep/ .el-cascader-menu__wrap { height: 300px; - width: 280px; + width: var(--cascaderMenuWidth); } diff --git a/frontend/src/business/components/settings/workspace/WorkspaceMember.vue b/frontend/src/business/components/settings/workspace/WorkspaceMember.vue index cad989f181..1c8a982610 100644 --- a/frontend/src/business/components/settings/workspace/WorkspaceMember.vue +++ b/frontend/src/business/components/settings/workspace/WorkspaceMember.vue @@ -8,7 +8,22 @@ + + + + + @@ -72,6 +87,8 @@ + @@ -101,10 +118,13 @@ import UserCascader from "@/business/components/settings/system/components/UserC import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn"; import {GROUP_WORKSPACE} from "@/common/js/constants"; import AddMember from "@/business/components/settings/common/AddMember"; +import BatchToProjectGroupCascader from "@/business/components/settings/system/components/BatchToProjectGroupCascader"; +import GroupCascader from "@/business/components/settings/system/components/GroupCascader"; export default { name: "MsMember", components: { + BatchToProjectGroupCascader, GroupCascader, AddMember, MsCreateBox, MsTablePagination, MsTableHeader, MsRolesTag, MsTableOperator, MsDialogFooter, MsTableHeaderSelectPopover, UserCascader, ShowMoreBtn }, @@ -138,9 +158,9 @@ export default { referenced: false, batchAddUserRoleOptions: [], buttons: [ - // { - // name: this.$t('user.button.add_user_role_batch'), handleClick: this.addUserRoleBatch - // } + { + name: this.$t('user.add_project_batch'), handleClick: this.addToProjectBatch + }, ], }; }, @@ -261,6 +281,9 @@ export default { } }); }, + addToProjectBatch(){ + this.$refs.cascaderDialog.open(); + }, create() { let wsId = getCurrentWorkspaceId(); if (typeof wsId == "undefined" || wsId == null || wsId == "") {