refactor(系统设置): 工作空间成员批量添加到项目

--story=1003797 --user=lyh
5.系统-用户列表增加批量添加到工作空间,工作空间成员列表增加批量操作,支持批量添加到项目,批量添加用户组
https://www.tapd.cn/55049933/s/1065444
This commit is contained in:
shiziyuan9527 2021-11-08 16:14:50 +08:00 committed by shiziyuan9527
parent 19bb132115
commit 3c30089dfa
3 changed files with 74 additions and 19 deletions

View File

@ -98,7 +98,8 @@
</span>
</el-dialog>
<user-import ref="userImportDialog" @refreshAll="search"></user-import>
<project-cascader :title="batchAddTitle" @confirm="cascaderConfirm" ref="cascaderDialog"></project-cascader>
<batch-to-project-group-cascader :title="batchAddTitle" @confirm="cascaderConfirm"
:cascader-level="2" ref="cascaderDialog"/>
<workspace-cascader :title="addToWorkspaceTitle" @confirm="cascaderConfirm" ref="workspaceCascader"></workspace-cascader>
<group-cascader :title="$t('user.add_user_group_batch')" @confirm="cascaderConfirm" ref="groupCascaderDialog"></group-cascader>
<edit-user ref="editUser" @refresh="search"/>
@ -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: [

View File

@ -23,6 +23,7 @@
<el-form-item prop="project" label-width="0px">
<el-cascader-panel :props="props"
popper-class="ms-cascade"
:style="{'--cascaderMenuWidth': cascaderMenuWidth + 'px'}"
v-model="selectedIds"
ref="cascadeSelector"
:key="isResourceShow"
@ -42,12 +43,12 @@
<script>
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);
}
</style>

View File

@ -8,7 +8,22 @@
</template>
<el-table border class="adjust-table" :data="tableData" style="width: 100%"
:height="screenHeight"
@select-all="handleSelectAll"
@select="handleSelect"
ref="userTable">
<el-table-column type="selection" width="50"/>
<ms-table-header-select-popover v-show="total>0"
:page-size="pageSize>total?total:pageSize"
:total="total"
:select-data-counts="selectDataCounts"
:table-data-count-in-page="tableData.length"
@selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/>
<el-table-column width="30" min-width="30" :resizable="false" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
</template>
</el-table-column>
<el-table-column prop="id" label="ID"/>
<el-table-column prop="name" :label="$t('commons.username')"/>
<el-table-column prop="email" :label="$t('commons.email')"/>
@ -72,6 +87,8 @@
</el-dialog>
<user-cascader :lable="batchAddLable" :title="batchAddTitle" @confirm="cascaderConfirm"
ref="cascaderDialog"></user-cascader>
<batch-to-project-group-cascader :title="$t('user.add_project_batch')" @confirm="cascaderConfirm"
:cascader-level="1" ref="cascaderDialog"/>
</div>
</template>
@ -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 == "") {