diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index c0bb3c33a4..92f6f3b3cc 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -54,6 +54,9 @@ export default { 'search_by_name': 'Search by name', 'input_name': 'Please enter a workspace name', }, + member: { + 'create': 'Create' + }, load_test: { 'recent': 'Recent Tests', 'search_by_name': 'Search by name', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 4edf8a21fa..c335e62eed 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -54,6 +54,9 @@ export default { 'search_by_name': '根据名称搜索', 'input_name': '请输入项目名称', }, + member: { + 'create': '添加成员' + }, load_test: { 'recent': '最近的测试', 'search_by_name': '根据名称搜索', diff --git a/frontend/src/performance/components/settings/Member.vue b/frontend/src/performance/components/settings/Member.vue index 00a74d5c84..099f93bc5f 100644 --- a/frontend/src/performance/components/settings/Member.vue +++ b/frontend/src/performance/components/settings/Member.vue @@ -152,7 +152,7 @@ return JSON.parse(user); }, initTableData() { - if (this.currentUser.lastWorkspaceId === null) { + if (this.currentUser().lastWorkspaceId === null) { return false; } this.loading = true; diff --git a/frontend/src/performance/components/settings/Organization.vue b/frontend/src/performance/components/settings/Organization.vue index bf07889ca9..93df39b3b4 100644 --- a/frontend/src/performance/components/settings/Organization.vue +++ b/frontend/src/performance/components/settings/Organization.vue @@ -13,11 +13,15 @@ - + - 123 + + + @@ -91,14 +202,23 @@ result: {}, createVisible: false, updateVisible: false, + memberVisible: false, + addMemberVisible: false, + updateMemberVisible: false, multipleSelection: [], currentPage: 1, pageSize: 5, total: 0, - btnTips: this.$t('organization.create'), + currentMemberPage: 1, + pageMemberSize: 5, + memberTotal: 0, + currentRow: {}, + btnTips: this.$t('member.create'), condition: "", tableData: [], + memberLineData: [], form: {}, + memberForm: {}, rule: { name: [ {required: true, message: this.$t('organization.input_name'), trigger: 'blur'}, @@ -123,13 +243,51 @@ create() { this.createVisible = true; }, + addMember() { + this.addMemberVisible = true; + this.memberForm = {}; + this.result = this.$get('/user/list/', response => { + this.$set(this.memberForm, "userList", response.data); + }); + this.result = this.$get('/role/list/org', response => { + this.$set(this.memberForm, "roles", response.data); + }) + }, edit(row) { // this.loading = true; this.updateVisible = true; this.form = row; }, - cellClick(){ - alert(1) + editMember(row) { + this.updateMemberVisible = true; + this.memberForm = row; + let roleIds = this.memberForm.roles.map(r => r.id); + this.result = this.$get('/role/list/org', response => { + this.$set(this.memberForm, "allroles", response.data); + }) + // 编辑时填充角色信息 + this.$set(this.memberForm, 'roleIds', roleIds); + }, + cellClick(row){ + this.currentRow = row; + this.memberVisible = true; + let param = { + name: '', + organizationId: row.id + }; + let path = "/user/orgmember/list"; + this.result = this.$post(this.buildPagePath(path), param, res => { + let data = res.data; + this.memberLineData = data.listObject; + let url = "/userrole/list/org/" + row.id; + for (let i = 0; i < this.memberLineData.length; i++) { + this.$get(url + "/" + this.memberLineData[i].id, response => { + let roles = response.data; + this.$set(this.memberLineData[i], "roles", roles); + }) + } + this.memberTotal = data.itemCount; + }); }, del(row) { this.$confirm(this.$t('organization.delete_confirm'), '', { @@ -151,6 +309,26 @@ }); }); }, + delMember(row) { + this.$confirm('是否删除用户 ' + row.name + ' ?', '', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.result = this.$get('/user/orgmember/delete/' + this.currentRow.id + '/' + row.id, () => { + this.$message({ + type: 'success', + message: '删除成功!' + }); + this.cellClick(this.currentRow); + }); + }).catch(() => { + this.$message({ + type: 'info', + message: '已取消删除' + }); + }); + }, createOrganization(createOrganizationForm) { this.$refs[createOrganizationForm].validate( valide => { if (valide) { @@ -184,15 +362,30 @@ }) }, initTableData() { - this.result = this.$post(this.buildPagePath(this.queryPath),{},response => { + this.$post(this.buildPagePath(this.queryPath),{},response => { let data = response.data; - this.total = data.itemCount; this.tableData = data.listObject; + for (let i = 0; i < this.tableData.length; i++) { + let param = { + name: '', + organizationId: this.tableData[i].id + } + let path = "user/orgmember/list/all"; + this.$post(path, param, res => { + let member = res.data; + this.$set(this.tableData[i], "memberSize", member.length); + }) + } + this.total = data.itemCount; }) }, closeFunc() { this.form = {}; }, + closeMemberFunc() { + this.memberLineData = []; + this.initTableData(); + }, buildPagePath(path) { return path + "/" + this.currentPage + "/" + this.pageSize; }, @@ -204,9 +397,53 @@ this.currentPage = current; this.initTableData(); }, + // + handleMemberSizeChange(size) { + this.pageMemberSize = size; + this.cellClick(this.currentRow); + }, + handleMemberCurrentChange(current) { + this.currentMemberPage = current; + this.cellClick(this.currentRow); + }, handleSelectionChange(val) { this.multipleSelection = val; - } + }, + submitForm(formName) { + this.$refs[formName].validate((valid) => { + if (valid) { + let param = { + userIds: this.memberForm.userIds, + roleIds: this.memberForm.roleIds, + organizationId: this.currentRow.id + }; + this.result = this.$post("user/orgmember/add", param,() => { + this.cellClick(this.currentRow); + this.addMemberVisible = false; + }) + } else { + return false; + } + }); + }, + updateOrgMember() { + let param = { + id: this.memberForm.id, + name: this.memberForm.name, + email: this.memberForm.email, + phone: this.memberForm.phone, + roleIds: this.memberForm.roleIds, + organizationId: this.currentRow.id + } + this.result = this.$post("/organization/member/update", param,() => { + this.$message({ + type: 'success', + message: '修改成功!' + }); + this.updateMemberVisible = false; + this.cellClick(this.currentRow); + }); + }, } } @@ -222,4 +459,30 @@ margin-right: -9px; float: right; } + + .member-size { + text-decoration:underline; + cursor:pointer; + } + + .title { + margin-bottom: 50px; + font-size: 32px; + letter-spacing: 0; + text-align: center; + } + + .org-member-name { + float: left; + } + + .org-member-email { + float: right; + color: #8492a6; + font-size: 13px; + } + + .select-width { + width: 100%; + }