fix(权限设置): 修复组织成员可以修改工作空间成员的bug

This commit is contained in:
Captain.B 2021-05-28 11:24:18 +08:00 committed by 刘瑞斌
parent 03fe07833e
commit 9279cb6751

View File

@ -2,7 +2,8 @@
<div> <div>
<el-card class="table-card" v-loading="result.loading"> <el-card class="table-card" v-loading="result.loading">
<template v-slot:header> <template v-slot:header>
<ms-table-header :create-permission="['ORGANIZATION_WORKSPACE:READ+CREATE']" :condition.sync="condition" @search="list" @create="create" <ms-table-header :create-permission="['ORGANIZATION_WORKSPACE:READ+CREATE']" :condition.sync="condition"
@search="list" @create="create"
:create-tip="$t('workspace.create')" :title="$t('commons.workspace')"/> :create-tip="$t('workspace.create')" :title="$t('commons.workspace')"/>
</template> </template>
<el-table border class="adjust-table" :data="items" style="width: 100%" <el-table border class="adjust-table" :data="items" style="width: 100%"
@ -31,7 +32,8 @@
:total="total"/> :total="total"/>
</el-card> </el-card>
<el-dialog :close-on-click-modal="false" :title="$t('workspace.create')" :visible.sync="dialogWsAddVisible" width="30%" @close="close"> <el-dialog :close-on-click-modal="false" :title="$t('workspace.create')" :visible.sync="dialogWsAddVisible"
width="30%" @close="close">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small"> <el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name"> <el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/> <el-input v-model="form.name" autocomplete="off"/>
@ -46,7 +48,8 @@
@confirm="submit('form')"/> @confirm="submit('form')"/>
</template> </template>
</el-dialog> </el-dialog>
<el-dialog :close-on-click-modal="false" :title="$t('workspace.update')" :visible.sync="dialogWsUpdateVisible" width="30%"> <el-dialog :close-on-click-modal="false" :title="$t('workspace.update')" :visible.sync="dialogWsUpdateVisible"
width="30%">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small"> <el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name"> <el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/> <el-input v-model="form.name" autocomplete="off"/>
@ -63,9 +66,11 @@
</el-dialog> </el-dialog>
<!-- dialog of workspace member --> <!-- dialog of workspace member -->
<el-dialog :close-on-click-modal="false" :visible.sync="dialogWsMemberVisible" width="70%" :destroy-on-close="true" @close="close" <el-dialog :close-on-click-modal="false" :visible.sync="dialogWsMemberVisible" width="70%" :destroy-on-close="true"
@close="close"
class="dialog-css"> class="dialog-css">
<ms-table-header :condition.sync="dialogCondition" @create="addMember" @search="dialogSearch" <ms-table-header :condition.sync="dialogCondition" @create="addMember" @search="dialogSearch"
:create-permission="['ORGANIZATION_WORKSPACE:READ+CREATE', 'ORGANIZATION_WORKSPACE:READ+EDIT']"
:create-tip="$t('member.create')" :title="$t('commons.member')"/> :create-tip="$t('member.create')" :title="$t('commons.member')"/>
<!-- organization member table --> <!-- organization member table -->
<el-table :data="memberLineData" style="width: 100%;margin-top: 5px;"> <el-table :data="memberLineData" style="width: 100%;margin-top: 5px;">
@ -80,7 +85,10 @@
<el-table-column :label="$t('commons.operating')"> <el-table-column :label="$t('commons.operating')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<div> <div>
<ms-table-operator :tip2="$t('commons.remove')" @editClick="editMember(scope.row)" <ms-table-operator :tip2="$t('commons.remove')"
:edit-permission="['ORGANIZATION_WORKSPACE:READ+CREATE', 'ORGANIZATION_WORKSPACE:READ+EDIT']"
:delete-permission="['ORGANIZATION_WORKSPACE:READ+CREATE', 'ORGANIZATION_WORKSPACE:READ+EDIT']"
@editClick="editMember(scope.row)"
@deleteClick="delMember(scope.row)"/> @deleteClick="delMember(scope.row)"/>
</div> </div>
</template> </template>
@ -92,12 +100,14 @@
</el-dialog> </el-dialog>
<!-- add workspace member dialog --> <!-- add workspace member dialog -->
<el-dialog :close-on-click-modal="false" :title="$t('member.create')" :visible.sync="dialogWsMemberAddVisible" width="30%" <el-dialog :close-on-click-modal="false" :title="$t('member.create')" :visible.sync="dialogWsMemberAddVisible"
width="30%"
:destroy-on-close="true" :destroy-on-close="true"
@close="closeFunc"> @close="closeFunc">
<el-form :model="memberForm" ref="form" :rules="wsMemberRule" label-position="right" label-width="100px" <el-form :model="memberForm" ref="form" :rules="wsMemberRule" label-position="right" label-width="100px"
size="small"> size="small">
<el-form-item :label="$t('commons.member')" prop="memberSign" :rules="{required: true, message: $t('member.input_id_or_email'), trigger: 'change'}"> <el-form-item :label="$t('commons.member')" prop="memberSign"
:rules="{required: true, message: $t('member.input_id_or_email'), trigger: 'change'}">
<el-autocomplete <el-autocomplete
class="input-with-autocomplete" class="input-with-autocomplete"
v-model="memberForm.memberSign" v-model="memberForm.memberSign"
@ -135,7 +145,8 @@
</el-dialog> </el-dialog>
<!-- update workspace member dialog --> <!-- update workspace member dialog -->
<el-dialog :close-on-click-modal="false" :title="$t('member.modify')" :visible.sync="dialogWsMemberUpdateVisible" width="30%" <el-dialog :close-on-click-modal="false" :title="$t('member.modify')" :visible.sync="dialogWsMemberUpdateVisible"
width="30%"
:destroy-on-close="true" :destroy-on-close="true"
@close="closeFunc"> @close="closeFunc">
<el-form :model="memberForm" label-position="right" label-width="100px" size="small" ref="updateUserForm"> <el-form :model="memberForm" label-position="right" label-width="100px" size="small" ref="updateUserForm">
@ -151,7 +162,8 @@
<el-form-item :label="$t('commons.phone')" prop="phone"> <el-form-item :label="$t('commons.phone')" prop="phone">
<el-input v-model="memberForm.phone" autocomplete="off" :disabled="true"/> <el-input v-model="memberForm.phone" autocomplete="off" :disabled="true"/>
</el-form-item> </el-form-item>
<el-form-item label="用户组" prop="groupIds" :rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}"> <el-form-item label="用户组" prop="groupIds"
:rules="{required: true, message: $t('role.please_choose_role'), trigger: 'change'}">
<el-select v-model="memberForm.groupIds" multiple placeholder="请选择用户组" <el-select v-model="memberForm.groupIds" multiple placeholder="请选择用户组"
class="select-width"> class="select-width">
<el-option <el-option
@ -178,7 +190,7 @@
<script> <script>
import MsCreateBox from "../CreateBox"; import MsCreateBox from "../CreateBox";
import {Message} from "element-ui"; import {Message} from "element-ui";
import {DEFAULT, GROUP_ORGANIZATION, GROUP_WORKSPACE} from "../../../../common/js/constants"; import {DEFAULT, GROUP_WORKSPACE} from "../../../../common/js/constants";
import MsTablePagination from "../../common/pagination/TablePagination"; import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader"; import MsTableHeader from "../../common/components/MsTableHeader";
import MsRolesTag from "../../common/components/MsRolesTag"; import MsRolesTag from "../../common/components/MsRolesTag";
@ -186,10 +198,11 @@
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import MsDialogFooter from "../../common/components/MsDialogFooter"; import MsDialogFooter from "../../common/components/MsDialogFooter";
import { import {
getCurrentOrganizationId,
getCurrentUser, getCurrentUser,
getCurrentWorkspaceId, listenGoBack, getCurrentWorkspaceId,
refreshSessionAndCookies, removeGoBackListener listenGoBack,
refreshSessionAndCookies,
removeGoBackListener
} from "../../../../common/js/utils"; } from "../../../../common/js/utils";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm"; import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
@ -223,7 +236,7 @@
if (valid) { if (valid) {
let saveType = 'add'; let saveType = 'add';
if (this.form.id) { if (this.form.id) {
saveType = 'update' saveType = 'update';
} }
this.$post("/workspace/" + saveType, this.form, () => { this.$post("/workspace/" + saveType, this.form, () => {
this.dialogWsAddVisible = false; this.dialogWsAddVisible = false;
@ -311,12 +324,12 @@
let param = { let param = {
name: '', name: '',
workspaceId: this.items[i].id workspaceId: this.items[i].id
} };
let path = "user/ws/member/list/all"; let path = "user/ws/member/list/all";
this.$post(path, param, res => { this.$post(path, param, res => {
let member = res.data; let member = res.data;
this.$set(this.items[i], "memberSize", member.length); this.$set(this.items[i], "memberSize", member.length);
}) });
} }
this.total = data.itemCount; this.total = data.itemCount;
}); });
@ -331,7 +344,7 @@
}); });
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => { this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
this.$set(this.memberForm, "groups", response.data); this.$set(this.memberForm, "groups", response.data);
}) });
listenGoBack(this.close); listenGoBack(this.close);
}, },
cellClick(row) { cellClick(row) {
@ -353,7 +366,7 @@
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => { this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
let groups = response.data; let groups = response.data;
this.$set(this.memberLineData[i], "groups", groups); this.$set(this.memberLineData[i], "groups", groups);
}) });
} }
this.dialogTotal = data.itemCount; this.dialogTotal = data.itemCount;
}); });
@ -373,7 +386,7 @@
this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => { this.$get(url + "/" + encodeURIComponent(this.memberLineData[i].id), response => {
let groups = response.data; let groups = response.data;
this.$set(this.memberLineData[i], "groups", groups); this.$set(this.memberLineData[i], "groups", groups);
}) });
} }
this.dialogTotal = data.itemCount; this.dialogTotal = data.itemCount;
}); });
@ -404,7 +417,7 @@
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
this.dialogWsMemberAddVisible = false; this.dialogWsMemberAddVisible = false;
}) });
} else { } else {
return false; return false;
} }
@ -416,7 +429,7 @@
let groupIds = this.memberForm.groups.map(r => r.id); let groupIds = this.memberForm.groups.map(r => r.id);
this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => { this.result = this.$post('/user/group/list', {type: GROUP_WORKSPACE, resourceId: this.wsId}, response => {
this.$set(this.memberForm, "allgroups", response.data); this.$set(this.memberForm, "allgroups", response.data);
}) });
// //
this.$set(this.memberForm, 'groupIds', groupIds); this.$set(this.memberForm, 'groupIds', groupIds);
listenGoBack(this.close); listenGoBack(this.close);
@ -443,7 +456,7 @@
phone: this.memberForm.phone, phone: this.memberForm.phone,
groupIds: this.memberForm.groupIds, groupIds: this.memberForm.groupIds,
workspaceId: this.currentWorkspaceRow.id workspaceId: this.currentWorkspaceRow.id
} };
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
this.result = this.$post("/workspace/member/update", param, () => { this.result = this.$post("/workspace/member/update", param, () => {
@ -452,7 +465,7 @@
this.cellClick(this.currentWorkspaceRow); this.cellClick(this.currentWorkspaceRow);
}); });
} }
}) });
}, },
close: function () { close: function () {
removeGoBackListener(this.close); removeGoBackListener(this.close);
@ -529,9 +542,9 @@
}, },
currentWorkspaceRow: {}, currentWorkspaceRow: {},
wsId: "" wsId: ""
};
} }
} };
}
</script> </script>
<style scoped> <style scoped>