代码调整
This commit is contained in:
parent
ace5268922
commit
e8b8147aee
@ -17,6 +17,32 @@ export function getUserList(params) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询所有用户列表*/
|
||||
export function getManageUserList(params) {
|
||||
return request({
|
||||
url: `/api/manage/user/list`,
|
||||
method: 'get',
|
||||
params: params
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据用户查询用户角色列表*/
|
||||
export function getUserRolesList(uid) {
|
||||
return request({
|
||||
url: `/api/manage/${uid}/roles`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/** 绑定用户角色*/
|
||||
export function getBindUserRoles(data) {
|
||||
return request({
|
||||
url: `/api/manage/bind/org`,
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
/** 模糊查询用户 昵称、名称、手机号*/
|
||||
export function getDimUserList(params) {
|
||||
return request({
|
||||
|
@ -17,6 +17,12 @@ export default {
|
||||
{ label: '销售用户', value: '06' }
|
||||
],
|
||||
|
||||
schoolRoleList: [
|
||||
{ label: '管理员', value: 'Admin' },
|
||||
{ label: '教师', value: 'Teacher' },
|
||||
{ label: '学生', value: 'Student' }
|
||||
],
|
||||
|
||||
examResultList: [
|
||||
{ label: '未计算', value: '01' },
|
||||
{ label: '通过', value: '02' },
|
||||
|
@ -36,17 +36,31 @@
|
||||
移出
|
||||
</el-button>
|
||||
</span>
|
||||
<span v-if="node.data.type === 'ORG'" @click.stop>
|
||||
<el-button
|
||||
type="text"
|
||||
size="small"
|
||||
@click="() => addNode(node,data)"
|
||||
>
|
||||
添加
|
||||
</el-button>
|
||||
</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
</el-card>
|
||||
<selectUserRole ref="selectUserRole" @add="addTreeUser" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getOrgTreeById, deleteDepartUserRelation } from '@/api/company';
|
||||
import localStore from 'storejs';
|
||||
import selectUserRole from './selectUserRole.vue';
|
||||
export default {
|
||||
name: 'OrgDetail',
|
||||
components: {
|
||||
selectUserRole
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
filterText: '',
|
||||
@ -71,6 +85,12 @@ export default {
|
||||
localStore.set('orgDetail-treeKey-' + this.$route.query.orgId, this.expandedKeys);
|
||||
},
|
||||
methods: {
|
||||
addTreeUser(data, parentId) {
|
||||
this.$refs.tree && this.$refs.tree.append(data, parentId);
|
||||
},
|
||||
addNode(node, data) {
|
||||
this.$refs.selectUserRole.doShow(data);
|
||||
},
|
||||
initData() {
|
||||
getOrgTreeById(this.$route.query.orgId).then(resp => {
|
||||
this.treeData = [];
|
||||
|
117
src/views/system/companyManage/selectUserRole.vue
Normal file
117
src/views/system/companyManage/selectUserRole.vue
Normal file
@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<el-dialog v-dialogDrag title="绑定组织成员" :visible.sync="dialogVisible" width="30%" :before-close="doClose" center :close-on-click-modal="false">
|
||||
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="doConfirm">{{ $t('global.confirm') }}</el-button>
|
||||
<el-button @click="doClose">{{ $t('global.cancel') }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { getBindUserRoles, getManageUserList } from '@/api/management/user';
|
||||
import ConstConfig from '@/scripts/ConstConfig';
|
||||
|
||||
export default {
|
||||
name:'SelectUserRole',
|
||||
props: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
userList: [],
|
||||
formModel: {
|
||||
keyId: '',
|
||||
orgName: '',
|
||||
orgId: '',
|
||||
uid: '',
|
||||
role:''
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
form() {
|
||||
const form = {
|
||||
labelWidth: '150px',
|
||||
items: [
|
||||
{ prop: 'orgName', label: '组织', type: 'text', disabled:true, rightWidth:true },
|
||||
{ prop: 'uid', label: '用户', type: 'select', options: this.userList},
|
||||
{ prop: 'role', label: '角色', type: 'select', options: ConstConfig.ConstSelect.schoolRoleList}
|
||||
]
|
||||
};
|
||||
return form;
|
||||
},
|
||||
rules() {
|
||||
const crules = {
|
||||
uid: [
|
||||
{ required: true, message: '请选择用户', trigger: 'change' }
|
||||
],
|
||||
role: [
|
||||
{ required: true, message: '请选择角色', trigger: 'change' }
|
||||
]
|
||||
};
|
||||
return crules;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
getManageUserList().then(resp => {
|
||||
if (resp && resp.data && resp.data.length) {
|
||||
resp.data.forEach(item => {
|
||||
this.userList.push({label: item.name, value: item.id});
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
doShow(row) {
|
||||
this.dialogVisible = true;
|
||||
this.formModel.orgName = row.name;
|
||||
this.formModel.orgId = row.id;
|
||||
this.formModel.uid = '';
|
||||
this.formModel.role = '';
|
||||
this.formModel.keyId = row.keyId;
|
||||
},
|
||||
doClose() {
|
||||
this.dialogVisible = false;
|
||||
this.formModel = {
|
||||
keyId: '',
|
||||
orgName: '',
|
||||
orgId: '',
|
||||
uid: '',
|
||||
role:''
|
||||
};
|
||||
},
|
||||
getUserName(id) {
|
||||
let name = '';
|
||||
const findItem = this.userList.find(item => {
|
||||
return item.value == id;
|
||||
});
|
||||
if (findItem) {
|
||||
name = findItem.label;
|
||||
}
|
||||
return name;
|
||||
},
|
||||
doConfirm() {
|
||||
this.$refs.dataform.validateForm(() => {
|
||||
const formModel = Object.assign({}, this.formModel);
|
||||
delete formModel.orgName;
|
||||
getBindUserRoles(formModel).then(res=>{
|
||||
const nodeData = {
|
||||
keyId: this.formModel.keyId + 'USER' + this.formModel.uid,
|
||||
name: this.getUserName(this.formModel.uid),
|
||||
orgRole: this.formModel.role,
|
||||
type: 'USER',
|
||||
userId: this.formModel.uid
|
||||
};
|
||||
this.$emit('add', nodeData, this.formModel.keyId);
|
||||
this.doClose();
|
||||
}).catch((error) => {
|
||||
this.$message.error('绑定组织成员失败: ' + error.message);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
104
src/views/system/userControl/companyRelation.vue
Normal file
104
src/views/system/userControl/companyRelation.vue
Normal file
@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<el-dialog v-dialogDrag title="组织关系列表" :visible.sync="dialogVisible" width="50%" :before-close="doClose" center :close-on-click-modal="false">
|
||||
<QueryListPage ref="queryListPage1" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="doClose">{{ $t('global.cancel') }}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { getUserRolesList } from '@/api/management/user';
|
||||
|
||||
export default {
|
||||
name:'CompanyRelation',
|
||||
props: {
|
||||
companyMap: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
pagerConfig: {
|
||||
pageSize: 'pageSize',
|
||||
pageIndex: 'pageNum'
|
||||
},
|
||||
queryForm: {
|
||||
show: false
|
||||
},
|
||||
queryList: {
|
||||
query: this.getUserRolesList,
|
||||
paginationHiden: true,
|
||||
selectCheckShow: false,
|
||||
indexShow: true,
|
||||
columns: [
|
||||
{
|
||||
title: '用户名称',
|
||||
prop: 'name',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '组织',
|
||||
prop: 'orgId',
|
||||
type: 'tag',
|
||||
columnValue: (row) => { return this.getCompanyName(row.orgId); },
|
||||
tagType: (row) => { return 'success'; }
|
||||
},
|
||||
{
|
||||
title: '根组织',
|
||||
prop: 'rootOrgId',
|
||||
type: 'tag',
|
||||
columnValue: (row) => { return this.getCompanyName(row.rootOrgId); },
|
||||
tagType: (row) => { return 'success'; }
|
||||
},
|
||||
{
|
||||
title: this.$t('system.roles'),
|
||||
prop: 'role',
|
||||
type: 'tag',
|
||||
columnValue: (row) => { return this.$convertField(row.role, this.$ConstSelect.schoolRoleList, ['value', 'label']); },
|
||||
tagType: (row) => { return 'success'; }
|
||||
}
|
||||
]
|
||||
},
|
||||
userId: '',
|
||||
userName: ''
|
||||
};
|
||||
},
|
||||
methods:{
|
||||
getCompanyName(companyId) {
|
||||
return this.companyMap[companyId];
|
||||
},
|
||||
getUserRolesList() {
|
||||
return new Promise((resolve, reject) => {
|
||||
getUserRolesList(this.userId).then(res => {
|
||||
res.data && res.data.forEach(item => {
|
||||
item.name = this.userName;
|
||||
});
|
||||
resolve(res);
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
},
|
||||
doShow(row) {
|
||||
this.dialogVisible = true;
|
||||
this.userId = row.id;
|
||||
this.userName = row.name || '';
|
||||
this.reloadTable();
|
||||
},
|
||||
reloadTable() {
|
||||
if (this.queryList && this.queryList.reload) {
|
||||
this.queryList.reload();
|
||||
}
|
||||
},
|
||||
doClose() {
|
||||
this.dialogVisible = false;
|
||||
this.userId = '';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -5,6 +5,7 @@
|
||||
<create-user ref="createUser" />
|
||||
<create-single-user ref="createSingleUser" @reloadTable="reloadTable" />
|
||||
<bind-company ref="bindCompany" :company-list="companyList" @create="create" />
|
||||
<CompanyRelation ref="companyRelation" :company-map="companyMap" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -15,6 +16,7 @@ import DictionaryEdit from './edit';
|
||||
import CreateUser from './createUser';
|
||||
import CreateSingleUser from './createSingleUser';
|
||||
import BindCompany from './bindCompany';
|
||||
import CompanyRelation from './companyRelation';
|
||||
import {adminResetUserPassword} from '@/api/management/user';
|
||||
|
||||
export default {
|
||||
@ -23,7 +25,8 @@ export default {
|
||||
DictionaryEdit,
|
||||
CreateUser,
|
||||
CreateSingleUser,
|
||||
BindCompany
|
||||
BindCompany,
|
||||
CompanyRelation
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -145,7 +148,7 @@ export default {
|
||||
tagType: (row) => { return 'success'; }
|
||||
},
|
||||
{
|
||||
title: this.$t('system.roles'),
|
||||
title: '权限',
|
||||
prop: 'roles',
|
||||
type: 'tagMore',
|
||||
columnValue: (row) => { return this.$convertField(row.roles, this.$ConstSelect.roleList, ['value', 'label'], true); },
|
||||
@ -160,9 +163,13 @@ export default {
|
||||
name: this.$t('global.edit'),
|
||||
handleClick: this.handleUserEdit
|
||||
},
|
||||
// {
|
||||
// name: '绑定组织管理员',
|
||||
// handleClick: this.handleBind
|
||||
// },
|
||||
{
|
||||
name: '绑定组织管理员',
|
||||
handleClick: this.handleBind
|
||||
name: '组织关系',
|
||||
handleClick: this.handleRelation
|
||||
},
|
||||
{
|
||||
name: '重置密码',
|
||||
@ -227,6 +234,9 @@ export default {
|
||||
handleBind(index, row) {
|
||||
this.$refs.bindCompany.doShow(row);
|
||||
},
|
||||
handleRelation(index, row) {
|
||||
this.$refs.companyRelation.doShow(row);
|
||||
},
|
||||
resetPassword(index, row) {
|
||||
this.$confirm('操作会将改用户密码重置为初始密码,是否继续', this.$t('global.tips'), {
|
||||
confirmButtonText: this.$t('global.confirm'),
|
||||
|
Loading…
Reference in New Issue
Block a user