修改工作空间管理员添加成员的方式
This commit is contained in:
parent
b34c209257
commit
b61dbfe107
|
@ -75,18 +75,23 @@
|
||||||
@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="userIds">
|
<el-form-item :label="$t('commons.member')" prop="memberSign" :rules="{required: true, message: '请先选择正确的信息', trigger: 'change'}">
|
||||||
<el-select v-model="memberForm.userIds" multiple :placeholder="$t('member.please_choose_member')"
|
<el-autocomplete
|
||||||
class="select-width">
|
class="input-with-autocomplete"
|
||||||
<el-option
|
v-model="memberForm.memberSign"
|
||||||
v-for="item in memberForm.userList"
|
placeholder="请输入用户 ID , 或者用户邮箱"
|
||||||
:key="item.id"
|
:trigger-on-focus="false"
|
||||||
:label="item.name"
|
:fetch-suggestions="querySearch"
|
||||||
:value="item.id">
|
size="small"
|
||||||
<span class="ws-member-name">{{ item.name }}</span>
|
highlight-first-item
|
||||||
<span class="ws-member-email">{{ item.email }}</span>
|
value-key="email"
|
||||||
</el-option>
|
@select="handleSelect"
|
||||||
</el-select>
|
>
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
<span class="ws-member-name">{{scope.item.id}}</span>
|
||||||
|
<span class="ws-member-email">{{scope.item.email}}</span>
|
||||||
|
</template>
|
||||||
|
</el-autocomplete>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
||||||
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
|
<el-select v-model="memberForm.roleIds" multiple :placeholder="$t('role.please_choose_role')"
|
||||||
|
@ -256,7 +261,7 @@
|
||||||
this.dialogWsMemberAddVisible = true;
|
this.dialogWsMemberAddVisible = true;
|
||||||
this.memberForm = {};
|
this.memberForm = {};
|
||||||
this.result = this.$get('/user/list/', response => {
|
this.result = this.$get('/user/list/', response => {
|
||||||
this.$set(this.memberForm, "userList", response.data);
|
this.userList = response.data;
|
||||||
});
|
});
|
||||||
this.result = this.$get('/role/list/test', response => {
|
this.result = this.$get('/role/list/test', response => {
|
||||||
this.$set(this.memberForm, "roles", response.data);
|
this.$set(this.memberForm, "roles", response.data);
|
||||||
|
@ -315,12 +320,24 @@
|
||||||
submitForm(formName) {
|
submitForm(formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
let userIds = [];
|
||||||
|
let userId = this.memberForm.userId;
|
||||||
|
let email = this.memberForm.memberSign;
|
||||||
|
let member = this.userList.find(user => user.id === email || user.email === email);
|
||||||
|
if (!member) {
|
||||||
|
this.$warning("未找到该用户信息,请输入正确ID 或者 邮箱!");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
userId = member.id;
|
||||||
|
}
|
||||||
|
userIds.push(userId);
|
||||||
let param = {
|
let param = {
|
||||||
userIds: this.memberForm.userIds,
|
userIds: userIds,
|
||||||
roleIds: this.memberForm.roleIds,
|
roleIds: this.memberForm.roleIds,
|
||||||
workspaceId: this.currentWorkspaceRow.id
|
workspaceId: this.currentWorkspaceRow.id
|
||||||
};
|
};
|
||||||
this.result = this.$post("user/ws/member/add", param, () => {
|
this.result = this.$post("user/ws/member/add", param, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
this.cellClick(this.currentWorkspaceRow);
|
this.cellClick(this.currentWorkspaceRow);
|
||||||
this.dialogWsMemberAddVisible = false;
|
this.dialogWsMemberAddVisible = false;
|
||||||
})
|
})
|
||||||
|
@ -371,6 +388,20 @@
|
||||||
buildPagePath(path) {
|
buildPagePath(path) {
|
||||||
return path + "/" + this.dialogCurrentPage + "/" + this.dialogPageSize;
|
return path + "/" + this.dialogCurrentPage + "/" + this.dialogPageSize;
|
||||||
},
|
},
|
||||||
|
querySearch(queryString, cb) {
|
||||||
|
var userList = this.userList;
|
||||||
|
var results = queryString ? userList.filter(this.createFilter(queryString)) : userList;
|
||||||
|
// 调用 callback 返回建议列表的数据
|
||||||
|
cb(results);
|
||||||
|
},
|
||||||
|
createFilter(queryString) {
|
||||||
|
return (user) => {
|
||||||
|
return (user.email.indexOf(queryString.toLowerCase()) === 0 || user.id.indexOf(queryString.toLowerCase()) === 0);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
handleSelect(item) {
|
||||||
|
this.$set(this.form, "userId", item.id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -382,6 +413,7 @@
|
||||||
condition: {},
|
condition: {},
|
||||||
dialogCondition: {},
|
dialogCondition: {},
|
||||||
items: [],
|
items: [],
|
||||||
|
userList: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
total: 0,
|
total: 0,
|
||||||
|
@ -449,5 +481,9 @@
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-with-autocomplete {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
@ -28,18 +28,23 @@
|
||||||
<el-dialog :title="$t('member.create')" :visible.sync="createVisible" width="30%" :destroy-on-close="true"
|
<el-dialog :title="$t('member.create')" :visible.sync="createVisible" width="30%" :destroy-on-close="true"
|
||||||
@close="handleClose">
|
@close="handleClose">
|
||||||
<el-form :model="form" ref="form" :rules="rules" label-position="right" label-width="100px" size="small">
|
<el-form :model="form" ref="form" :rules="rules" label-position="right" label-width="100px" size="small">
|
||||||
<el-form-item :label="$t('commons.member')" prop="userIds">
|
<el-form-item :label="$t('commons.member')" prop="memberSign" :rules="{required: true, message: '请先选择正确的信息', trigger: 'change'}">
|
||||||
<el-select v-model="form.userIds" multiple :placeholder="$t('member.please_choose_member')"
|
<el-autocomplete
|
||||||
class="select-width">
|
class="input-with-autocomplete"
|
||||||
<el-option
|
v-model="form.memberSign"
|
||||||
v-for="item in form.userList"
|
placeholder="请输入用户 ID , 或者用户邮箱"
|
||||||
:key="item.id"
|
:trigger-on-focus="false"
|
||||||
:label="item.name"
|
:fetch-suggestions="querySearch"
|
||||||
:value="item.id">
|
size="small"
|
||||||
<span class="workspace-member-name">{{ item.name }}</span>
|
highlight-first-item
|
||||||
<span class="workspace-member-email">{{ item.email }}</span>
|
value-key="email"
|
||||||
</el-option>
|
@select="handleSelect"
|
||||||
</el-select>
|
>
|
||||||
|
<template v-slot:default="scope">
|
||||||
|
<span class="workspace-member-name">{{scope.item.id}}</span>
|
||||||
|
<span class="workspace-member-email">{{scope.item.email}}</span>
|
||||||
|
</template>
|
||||||
|
</el-autocomplete>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
<el-form-item :label="$t('commons.role')" prop="roleIds">
|
||||||
<el-select v-model="form.roleIds" multiple :placeholder="$t('role.please_choose_role')" class="select-width">
|
<el-select v-model="form.roleIds" multiple :placeholder="$t('role.please_choose_role')" class="select-width">
|
||||||
|
@ -116,6 +121,7 @@
|
||||||
queryPath: "/user/ws/member/list",
|
queryPath: "/user/ws/member/list",
|
||||||
condition: {},
|
condition: {},
|
||||||
tableData: [],
|
tableData: [],
|
||||||
|
userList: [],
|
||||||
rules: {
|
rules: {
|
||||||
userIds: [
|
userIds: [
|
||||||
{required: true, message: this.$t('member.please_choose_member'), trigger: ['blur']}
|
{required: true, message: this.$t('member.please_choose_member'), trigger: ['blur']}
|
||||||
|
@ -219,7 +225,7 @@
|
||||||
}
|
}
|
||||||
this.$post('/user/org/member/list/all', param, response => {
|
this.$post('/user/org/member/list/all', param, response => {
|
||||||
this.createVisible = true;
|
this.createVisible = true;
|
||||||
this.$set(this.form, "userList", response.data);
|
this.userList = response.data;
|
||||||
})
|
})
|
||||||
this.result = this.$get('/role/list/test', response => {
|
this.result = this.$get('/role/list/test', response => {
|
||||||
this.$set(this.form, "roles", response.data);
|
this.$set(this.form, "roles", response.data);
|
||||||
|
@ -228,17 +234,43 @@
|
||||||
submitForm(formName) {
|
submitForm(formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
let userIds = [];
|
||||||
|
let userId = this.form.userId;
|
||||||
|
let email = this.form.memberSign;
|
||||||
|
let member = this.userList.find(user => user.id === email || user.email === email);
|
||||||
|
if (!member) {
|
||||||
|
this.$warning("未找到该用户信息,请输入正确ID 或者 邮箱!");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
userId = member.id;
|
||||||
|
}
|
||||||
|
userIds.push(userId);
|
||||||
let param = {
|
let param = {
|
||||||
userIds: this.form.userIds,
|
userIds: userIds,
|
||||||
roleIds: this.form.roleIds,
|
roleIds: this.form.roleIds,
|
||||||
workspaceId: this.currentUser().lastWorkspaceId
|
workspaceId: this.currentUser().lastWorkspaceId
|
||||||
};
|
};
|
||||||
this.result = this.$post("user/ws/member/add", param, () => {
|
this.result = this.$post("user/ws/member/add", param, () => {
|
||||||
|
this.$success(this.$t('commons.save_success'));
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
this.createVisible = false;
|
this.createVisible = false;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
querySearch(queryString, cb) {
|
||||||
|
var userList = this.userList;
|
||||||
|
var results = queryString ? userList.filter(this.createFilter(queryString)) : userList;
|
||||||
|
// 调用 callback 返回建议列表的数据
|
||||||
|
cb(results);
|
||||||
|
},
|
||||||
|
createFilter(queryString) {
|
||||||
|
return (user) => {
|
||||||
|
return (user.email.indexOf(queryString.toLowerCase()) === 0 || user.id.indexOf(queryString.toLowerCase()) === 0);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
handleSelect(item) {
|
||||||
|
this.$set(this.form, "userId", item.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,4 +296,8 @@
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-with-autocomplete {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue