Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
56491903de
|
@ -50,7 +50,8 @@
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!--Create user-->
|
<!--Create user-->
|
||||||
<el-dialog :close-on-click-modal="false" :title="$t('user.create')" :visible.sync="createVisible" width="35%" @closed="handleClose"
|
<el-dialog :close-on-click-modal="false" :title="$t('user.create')" :visible.sync="createVisible" width="35%"
|
||||||
|
@closed="handleClose"
|
||||||
:destroy-on-close="true">
|
:destroy-on-close="true">
|
||||||
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="createUserForm">
|
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="createUserForm">
|
||||||
<el-form-item label="ID" prop="id">
|
<el-form-item label="ID" prop="id">
|
||||||
|
@ -81,10 +82,11 @@
|
||||||
:label="$t('role.' + item.id)"
|
:label="$t('role.' + item.id)"
|
||||||
:value="item.id"
|
:value="item.id"
|
||||||
>
|
>
|
||||||
{{$t('role.' + item.id)}}
|
{{ $t('role.' + item.id) }}
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button @click.prevent="removeRole(role)" style="margin-left: 20px;" v-if="form.roles.length > 1">{{$t('commons.delete')}}
|
<el-button @click.prevent="removeRole(role)" style="margin-left: 20px;" v-if="form.roles.length > 1">
|
||||||
|
{{ $t('commons.delete') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-if="role.id === 'org_admin'">
|
<div v-if="role.id === 'org_admin'">
|
||||||
|
@ -151,7 +153,9 @@
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<template>
|
<template>
|
||||||
<el-button type="success" style="width: 100%;" @click="addRole('createUserForm')" :disabled="btnAddRole">{{$t('role.add')}}</el-button>
|
<el-button type="success" style="width: 100%;" @click="addRole('createUserForm')" :disabled="btnAddRole">
|
||||||
|
{{ $t('role.add') }}
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -163,7 +167,8 @@
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!--Modify user information in system settings-->
|
<!--Modify user information in system settings-->
|
||||||
<el-dialog :close-on-click-modal="false" :title="$t('user.modify')" :visible.sync="updateVisible" width="35%" :destroy-on-close="true"
|
<el-dialog :close-on-click-modal="false" :title="$t('user.modify')" :visible.sync="updateVisible" width="35%"
|
||||||
|
:destroy-on-close="true"
|
||||||
@close="handleClose" v-loading="result.loading">
|
@close="handleClose" v-loading="result.loading">
|
||||||
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="updateUserForm">
|
<el-form :model="form" label-position="right" label-width="120px" size="small" :rules="rule" ref="updateUserForm">
|
||||||
<el-form-item label="ID" prop="id">
|
<el-form-item label="ID" prop="id">
|
||||||
|
@ -191,7 +196,8 @@
|
||||||
:value="item.id">
|
:value="item.id">
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-button @click.prevent="removeRole(role)" style="margin-left: 20px;" v-if="form.roles.length > 1">{{$t('commons.delete')}}
|
<el-button @click.prevent="removeRole(role)" style="margin-left: 20px;" v-if="form.roles.length > 1">
|
||||||
|
{{ $t('commons.delete') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-if="role.id === 'org_admin'">
|
<div v-if="role.id === 'org_admin'">
|
||||||
|
@ -257,7 +263,9 @@
|
||||||
</div>
|
</div>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<template>
|
<template>
|
||||||
<el-button type="success" style="width: 100%;" @click="addRole('updateUserForm')" :disabled="btnAddRole">{{$t('role.add')}}</el-button>
|
<el-button type="success" style="width: 100%;" @click="addRole('updateUserForm')" :disabled="btnAddRole">
|
||||||
|
{{ $t('role.add') }}
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -268,7 +276,8 @@
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!--Changing user password in system settings-->
|
<!--Changing user password in system settings-->
|
||||||
<el-dialog :close-on-click-modal="false" :title="$t('member.edit_password')" :visible.sync="editPasswordVisible" width="30%"
|
<el-dialog :close-on-click-modal="false" :title="$t('member.edit_password')" :visible.sync="editPasswordVisible"
|
||||||
|
width="30%"
|
||||||
:destroy-on-close="true" @close="handleClose" left>
|
:destroy-on-close="true" @close="handleClose" left>
|
||||||
<el-form :model="ruleForm" label-position="right" label-width="120px" size="small" :rules="rule"
|
<el-form :model="ruleForm" label-position="right" label-width="120px" size="small" :rules="rule"
|
||||||
ref="editPasswordForm" class="demo-ruleForm">
|
ref="editPasswordForm" class="demo-ruleForm">
|
||||||
|
@ -290,297 +299,301 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MsCreateBox from "../CreateBox";
|
import MsCreateBox from "../CreateBox";
|
||||||
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 MsTableOperator from "../../common/components/MsTableOperator";
|
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||||
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
import {hasRole, listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||||
|
import {ROLE_ADMIN} from "@/common/js/constants";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsUser",
|
name: "MsUser",
|
||||||
components: {
|
components: {
|
||||||
MsCreateBox,
|
MsCreateBox,
|
||||||
MsTablePagination,
|
MsTablePagination,
|
||||||
MsTableHeader,
|
MsTableHeader,
|
||||||
MsTableOperator,
|
MsTableOperator,
|
||||||
MsDialogFooter,
|
MsDialogFooter,
|
||||||
MsTableOperatorButton,
|
MsTableOperatorButton,
|
||||||
MsRolesTag
|
MsRolesTag
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
queryPath: '/user/special/list',
|
queryPath: '/user/special/list',
|
||||||
deletePath: '/user/special/delete/',
|
deletePath: '/user/special/delete/',
|
||||||
createPath: '/user/special/add',
|
createPath: '/user/special/add',
|
||||||
updatePath: '/user/special/update',
|
updatePath: '/user/special/update',
|
||||||
editPasswordPath: '/user/special/password',
|
editPasswordPath: '/user/special/password',
|
||||||
result: {},
|
result: {},
|
||||||
createVisible: false,
|
createVisible: false,
|
||||||
updateVisible: false,
|
updateVisible: false,
|
||||||
editPasswordVisible: false,
|
editPasswordVisible: false,
|
||||||
btnAddRole: false,
|
btnAddRole: false,
|
||||||
multipleSelection: [],
|
multipleSelection: [],
|
||||||
userRole: [],
|
userRole: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
total: 0,
|
total: 0,
|
||||||
condition: {},
|
condition: {},
|
||||||
tableData: [],
|
tableData: [],
|
||||||
form: {
|
form: {
|
||||||
roles: [{
|
roles: [{
|
||||||
id: ''
|
id: ''
|
||||||
}]
|
}]
|
||||||
},
|
|
||||||
checkPasswordForm: {},
|
|
||||||
ruleForm: {},
|
|
||||||
rule: {
|
|
||||||
id: [
|
|
||||||
{required: true, message: this.$t('user.input_id'), trigger: 'blur'},
|
|
||||||
{min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'},
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
pattern: '^[^\u4e00-\u9fa5]+$',
|
|
||||||
message: this.$t('user.special_characters_are_not_supported'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
name: [
|
|
||||||
{required: true, message: this.$t('user.input_name'), trigger: 'blur'},
|
|
||||||
{min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'},
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: this.$t('user.special_characters_are_not_supported'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
phone: [
|
|
||||||
{
|
|
||||||
required: false,
|
|
||||||
pattern: '^1(3|4|5|7|8)\\d{9}$',
|
|
||||||
message: this.$t('user.mobile_number_format_is_incorrect'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
email: [
|
|
||||||
{required: true, message: this.$t('user.input_email'), trigger: 'blur'},
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
pattern: /^[a-zA-Z0-9_._-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
|
||||||
message: this.$t('user.email_format_is_incorrect'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
password: [
|
|
||||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
|
||||||
message: this.$t('member.password_format_is_incorrect'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
newpassword: [
|
|
||||||
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
|
||||||
message: this.$t('member.password_format_is_incorrect'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
activated() {
|
|
||||||
this.search();
|
|
||||||
this.getAllRole();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
create() {
|
|
||||||
this.createVisible = true;
|
|
||||||
this.getOrgList();
|
|
||||||
this.getWsList();
|
|
||||||
listenGoBack(this.handleClose);
|
|
||||||
},
|
},
|
||||||
edit(row) {
|
checkPasswordForm: {},
|
||||||
this.updateVisible = true;
|
ruleForm: {},
|
||||||
this.form = Object.assign({}, row);
|
rule: {
|
||||||
this.$get("/organization/list", response => {
|
id: [
|
||||||
this.$set(this.form, "orgList", response.data);
|
{required: true, message: this.$t('user.input_id'), trigger: 'blur'},
|
||||||
});
|
{min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'},
|
||||||
this.$get("/workspace/list", response => {
|
{
|
||||||
this.$set(this.form, "wsList", response.data);
|
required: true,
|
||||||
});
|
pattern: '^[^\u4e00-\u9fa5]+$',
|
||||||
if (row.id) {
|
message: this.$t('user.special_characters_are_not_supported'),
|
||||||
this.$get('/userrole/all/' + encodeURIComponent(row.id), response => {
|
trigger: 'blur'
|
||||||
let data = response.data;
|
|
||||||
this.$set(this.form, "roles", data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
listenGoBack(this.handleClose);
|
|
||||||
},
|
|
||||||
editPassword(row) {
|
|
||||||
this.editPasswordVisible = true;
|
|
||||||
this.ruleForm = Object.assign({}, row);
|
|
||||||
listenGoBack(this.handleClose);
|
|
||||||
},
|
|
||||||
del(row) {
|
|
||||||
this.$confirm(this.$t('user.delete_confirm'), '', {
|
|
||||||
confirmButtonText: this.$t('commons.confirm'),
|
|
||||||
cancelButtonText: this.$t('commons.cancel'),
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
this.result = this.$get(this.deletePath + encodeURIComponent(row.id), () => {
|
|
||||||
this.$success(this.$t('commons.delete_success'));
|
|
||||||
this.search();
|
|
||||||
});
|
|
||||||
}).catch(() => {
|
|
||||||
this.$info(this.$t('commons.delete_cancel'));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
createUser(createUserForm) {
|
|
||||||
this.$refs[createUserForm].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
this.result = this.$post(this.createPath, this.form, () => {
|
|
||||||
this.$success(this.$t('commons.save_success'));
|
|
||||||
this.search();
|
|
||||||
this.createVisible = false;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
})
|
],
|
||||||
},
|
name: [
|
||||||
updateUser(updateUserForm) {
|
{required: true, message: this.$t('user.input_name'), trigger: 'blur'},
|
||||||
this.$refs[updateUserForm].validate(valid => {
|
{min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'},
|
||||||
if (valid) {
|
{
|
||||||
this.result = this.$post(this.updatePath, this.form, () => {
|
required: true,
|
||||||
this.$success(this.$t('commons.modify_success'));
|
message: this.$t('user.special_characters_are_not_supported'),
|
||||||
this.updateVisible = false;
|
trigger: 'blur'
|
||||||
this.search();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
})
|
],
|
||||||
},
|
phone: [
|
||||||
editUserPassword(editPasswordForm) {
|
{
|
||||||
this.$refs[editPasswordForm].validate(valid => {
|
required: false,
|
||||||
if (valid) {
|
pattern: '^1(3|4|5|7|8)\\d{9}$',
|
||||||
this.result = this.$post(this.editPasswordPath, this.ruleForm, () => {
|
message: this.$t('user.mobile_number_format_is_incorrect'),
|
||||||
this.$success(this.$t('commons.modify_success'));
|
trigger: 'blur'
|
||||||
this.editPasswordVisible = false;
|
|
||||||
this.search();
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
})
|
],
|
||||||
},
|
email: [
|
||||||
search() {
|
{required: true, message: this.$t('user.input_email'), trigger: 'blur'},
|
||||||
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
|
{
|
||||||
let data = response.data;
|
required: true,
|
||||||
this.total = data.itemCount;
|
pattern: /^[a-zA-Z0-9_._-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
||||||
this.tableData = data.listObject;
|
message: this.$t('user.email_format_is_incorrect'),
|
||||||
let url = "/user/special/user/role";
|
trigger: 'blur'
|
||||||
for (let i = 0; i < this.tableData.length; i++) {
|
|
||||||
if (this.tableData[i].id) {
|
|
||||||
this.$get(url + '/' + encodeURIComponent(this.tableData[i].id), result => {
|
|
||||||
let data = result.data;
|
|
||||||
let roles = data.roles;
|
|
||||||
// let userRoles = result.userRoles;
|
|
||||||
this.$set(this.tableData[i], "roles", roles);
|
|
||||||
this.$set(this.tableData[i], "isLdapUser", this.tableData[i].source === 'LDAP');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
],
|
||||||
},
|
password: [
|
||||||
handleClose() {
|
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||||
this.form = {roles: [{id: ''}]};
|
{
|
||||||
this.btnAddRole = false;
|
required: true,
|
||||||
removeGoBackListener(this.handleClose);
|
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||||
this.editPasswordVisible = false;
|
message: this.$t('member.password_format_is_incorrect'),
|
||||||
this.createVisible = false;
|
trigger: 'blur'
|
||||||
this.updateVisible = false;
|
|
||||||
},
|
|
||||||
changeSwitch(row) {
|
|
||||||
this.$post('/user/special/update_status', row, () => {
|
|
||||||
this.$success(this.$t('commons.modify_success'));
|
|
||||||
})
|
|
||||||
},
|
|
||||||
buildPagePath(path) {
|
|
||||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
|
||||||
},
|
|
||||||
handleSelectionChange(val) {
|
|
||||||
this.multipleSelection = val;
|
|
||||||
},
|
|
||||||
getOrgList() {
|
|
||||||
this.$get("/organization/list", response => {
|
|
||||||
this.$set(this.form, "orgList", response.data);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getWsList() {
|
|
||||||
this.$get("/workspace/list", response => {
|
|
||||||
this.$set(this.form, "wsList", response.data);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
getAllRole() {
|
|
||||||
this.$get("/role/all", response => {
|
|
||||||
this.userRole = response.data;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
addRole(validForm) {
|
|
||||||
this.$refs[validForm].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
let roleInfo = {};
|
|
||||||
roleInfo.selects = [];
|
|
||||||
let ids = this.form.roles.map(r => r.id);
|
|
||||||
ids.forEach(id => {
|
|
||||||
roleInfo.selects.push(id);
|
|
||||||
})
|
|
||||||
let roles = this.form.roles;
|
|
||||||
roles.push(roleInfo);
|
|
||||||
if (this.form.roles.length > this.userRole.length - 1) {
|
|
||||||
this.btnAddRole = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
})
|
],
|
||||||
},
|
newpassword: [
|
||||||
removeRole(item) {
|
{required: true, message: this.$t('user.input_password'), trigger: 'blur'},
|
||||||
let index = this.form.roles.indexOf(item);
|
{
|
||||||
if (index !== -1) {
|
required: true,
|
||||||
this.form.roles.splice(index, 1)
|
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||||
}
|
message: this.$t('member.password_format_is_incorrect'),
|
||||||
if (this.form.roles.length < this.userRole.length) {
|
trigger: 'blur'
|
||||||
this.btnAddRole = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
activeRole(roleInfo) {
|
|
||||||
return this.userRole.filter(function (role) {
|
|
||||||
let value = true;
|
|
||||||
if (!roleInfo.selects) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (roleInfo.selects.length === 0) {
|
]
|
||||||
value = true;
|
|
||||||
}
|
|
||||||
for (let i = 0; i < roleInfo.selects.length; i++) {
|
|
||||||
if (role.id === roleInfo.selects[i]) {
|
|
||||||
value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
activated() {
|
||||||
|
this.search();
|
||||||
|
this.getAllRole();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
create() {
|
||||||
|
this.createVisible = true;
|
||||||
|
this.getOrgList();
|
||||||
|
this.getWsList();
|
||||||
|
listenGoBack(this.handleClose);
|
||||||
|
},
|
||||||
|
edit(row) {
|
||||||
|
this.updateVisible = true;
|
||||||
|
this.form = Object.assign({}, row);
|
||||||
|
this.$get("/organization/list", response => {
|
||||||
|
this.$set(this.form, "orgList", response.data);
|
||||||
|
});
|
||||||
|
this.$get("/workspace/list", response => {
|
||||||
|
this.$set(this.form, "wsList", response.data);
|
||||||
|
});
|
||||||
|
if (row.id) {
|
||||||
|
this.$get('/userrole/all/' + encodeURIComponent(row.id), response => {
|
||||||
|
let data = response.data;
|
||||||
|
this.$set(this.form, "roles", data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
listenGoBack(this.handleClose);
|
||||||
|
},
|
||||||
|
editPassword(row) {
|
||||||
|
this.editPasswordVisible = true;
|
||||||
|
this.ruleForm = Object.assign({}, row);
|
||||||
|
listenGoBack(this.handleClose);
|
||||||
|
},
|
||||||
|
del(row) {
|
||||||
|
this.$confirm(this.$t('user.delete_confirm'), '', {
|
||||||
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
|
cancelButtonText: this.$t('commons.cancel'),
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
this.result = this.$get(this.deletePath + encodeURIComponent(row.id), () => {
|
||||||
|
this.$success(this.$t('commons.delete_success'));
|
||||||
|
this.search();
|
||||||
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
this.$info(this.$t('commons.delete_cancel'));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
createUser(createUserForm) {
|
||||||
|
this.$refs[createUserForm].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.result = this.$post(this.createPath, this.form, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
|
this.search();
|
||||||
|
this.createVisible = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateUser(updateUserForm) {
|
||||||
|
this.$refs[updateUserForm].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.result = this.$post(this.updatePath, this.form, () => {
|
||||||
|
this.$success(this.$t('commons.modify_success'));
|
||||||
|
this.updateVisible = false;
|
||||||
|
this.search();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
editUserPassword(editPasswordForm) {
|
||||||
|
this.$refs[editPasswordForm].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.result = this.$post(this.editPasswordPath, this.ruleForm, () => {
|
||||||
|
this.$success(this.$t('commons.modify_success'));
|
||||||
|
this.editPasswordVisible = false;
|
||||||
|
this.search();
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
search() {
|
||||||
|
if (!hasRole(ROLE_ADMIN)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.result = this.$post(this.buildPagePath(this.queryPath), this.condition, response => {
|
||||||
|
let data = response.data;
|
||||||
|
this.total = data.itemCount;
|
||||||
|
this.tableData = data.listObject;
|
||||||
|
let url = "/user/special/user/role";
|
||||||
|
for (let i = 0; i < this.tableData.length; i++) {
|
||||||
|
if (this.tableData[i].id) {
|
||||||
|
this.$get(url + '/' + encodeURIComponent(this.tableData[i].id), result => {
|
||||||
|
let data = result.data;
|
||||||
|
let roles = data.roles;
|
||||||
|
// let userRoles = result.userRoles;
|
||||||
|
this.$set(this.tableData[i], "roles", roles);
|
||||||
|
this.$set(this.tableData[i], "isLdapUser", this.tableData[i].source === 'LDAP');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleClose() {
|
||||||
|
this.form = {roles: [{id: ''}]};
|
||||||
|
this.btnAddRole = false;
|
||||||
|
removeGoBackListener(this.handleClose);
|
||||||
|
this.editPasswordVisible = false;
|
||||||
|
this.createVisible = false;
|
||||||
|
this.updateVisible = false;
|
||||||
|
},
|
||||||
|
changeSwitch(row) {
|
||||||
|
this.$post('/user/special/update_status', row, () => {
|
||||||
|
this.$success(this.$t('commons.modify_success'));
|
||||||
|
})
|
||||||
|
},
|
||||||
|
buildPagePath(path) {
|
||||||
|
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||||
|
},
|
||||||
|
handleSelectionChange(val) {
|
||||||
|
this.multipleSelection = val;
|
||||||
|
},
|
||||||
|
getOrgList() {
|
||||||
|
this.$get("/organization/list", response => {
|
||||||
|
this.$set(this.form, "orgList", response.data);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getWsList() {
|
||||||
|
this.$get("/workspace/list", response => {
|
||||||
|
this.$set(this.form, "wsList", response.data);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getAllRole() {
|
||||||
|
this.$get("/role/all", response => {
|
||||||
|
this.userRole = response.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
addRole(validForm) {
|
||||||
|
this.$refs[validForm].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
let roleInfo = {};
|
||||||
|
roleInfo.selects = [];
|
||||||
|
let ids = this.form.roles.map(r => r.id);
|
||||||
|
ids.forEach(id => {
|
||||||
|
roleInfo.selects.push(id);
|
||||||
|
})
|
||||||
|
let roles = this.form.roles;
|
||||||
|
roles.push(roleInfo);
|
||||||
|
if (this.form.roles.length > this.userRole.length - 1) {
|
||||||
|
this.btnAddRole = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
removeRole(item) {
|
||||||
|
let index = this.form.roles.indexOf(item);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.form.roles.splice(index, 1)
|
||||||
|
}
|
||||||
|
if (this.form.roles.length < this.userRole.length) {
|
||||||
|
this.btnAddRole = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
activeRole(roleInfo) {
|
||||||
|
return this.userRole.filter(function (role) {
|
||||||
|
let value = true;
|
||||||
|
if (!roleInfo.selects) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (roleInfo.selects.length === 0) {
|
||||||
|
value = true;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < roleInfo.selects.length; i++) {
|
||||||
|
if (role.id === roleInfo.selects[i]) {
|
||||||
|
value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
Loading…
Reference in New Issue