代码调整

This commit is contained in:
dong 2022-11-25 18:33:55 +08:00
parent ace5268922
commit e8b8147aee
6 changed files with 287 additions and 4 deletions

View File

@ -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) { export function getDimUserList(params) {
return request({ return request({

View File

@ -17,6 +17,12 @@ export default {
{ label: '销售用户', value: '06' } { label: '销售用户', value: '06' }
], ],
schoolRoleList: [
{ label: '管理员', value: 'Admin' },
{ label: '教师', value: 'Teacher' },
{ label: '学生', value: 'Student' }
],
examResultList: [ examResultList: [
{ label: '未计算', value: '01' }, { label: '未计算', value: '01' },
{ label: '通过', value: '02' }, { label: '通过', value: '02' },

View File

@ -36,17 +36,31 @@
移出 移出
</el-button> </el-button>
</span> </span>
<span v-if="node.data.type === 'ORG'" @click.stop>
<el-button
type="text"
size="small"
@click="() => addNode(node,data)"
>
添加
</el-button>
</span>
</span> </span>
</el-tree> </el-tree>
</el-card> </el-card>
<selectUserRole ref="selectUserRole" @add="addTreeUser" />
</div> </div>
</template> </template>
<script> <script>
import { getOrgTreeById, deleteDepartUserRelation } from '@/api/company'; import { getOrgTreeById, deleteDepartUserRelation } from '@/api/company';
import localStore from 'storejs'; import localStore from 'storejs';
import selectUserRole from './selectUserRole.vue';
export default { export default {
name: 'OrgDetail', name: 'OrgDetail',
components: {
selectUserRole
},
data() { data() {
return { return {
filterText: '', filterText: '',
@ -71,6 +85,12 @@ export default {
localStore.set('orgDetail-treeKey-' + this.$route.query.orgId, this.expandedKeys); localStore.set('orgDetail-treeKey-' + this.$route.query.orgId, this.expandedKeys);
}, },
methods: { methods: {
addTreeUser(data, parentId) {
this.$refs.tree && this.$refs.tree.append(data, parentId);
},
addNode(node, data) {
this.$refs.selectUserRole.doShow(data);
},
initData() { initData() {
getOrgTreeById(this.$route.query.orgId).then(resp => { getOrgTreeById(this.$route.query.orgId).then(resp => {
this.treeData = []; this.treeData = [];

View 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>

View 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>

View File

@ -5,6 +5,7 @@
<create-user ref="createUser" /> <create-user ref="createUser" />
<create-single-user ref="createSingleUser" @reloadTable="reloadTable" /> <create-single-user ref="createSingleUser" @reloadTable="reloadTable" />
<bind-company ref="bindCompany" :company-list="companyList" @create="create" /> <bind-company ref="bindCompany" :company-list="companyList" @create="create" />
<CompanyRelation ref="companyRelation" :company-map="companyMap" />
</div> </div>
</template> </template>
@ -15,6 +16,7 @@ import DictionaryEdit from './edit';
import CreateUser from './createUser'; import CreateUser from './createUser';
import CreateSingleUser from './createSingleUser'; import CreateSingleUser from './createSingleUser';
import BindCompany from './bindCompany'; import BindCompany from './bindCompany';
import CompanyRelation from './companyRelation';
import {adminResetUserPassword} from '@/api/management/user'; import {adminResetUserPassword} from '@/api/management/user';
export default { export default {
@ -23,7 +25,8 @@ export default {
DictionaryEdit, DictionaryEdit,
CreateUser, CreateUser,
CreateSingleUser, CreateSingleUser,
BindCompany BindCompany,
CompanyRelation
}, },
data() { data() {
return { return {
@ -145,7 +148,7 @@ export default {
tagType: (row) => { return 'success'; } tagType: (row) => { return 'success'; }
}, },
{ {
title: this.$t('system.roles'), title: '权限',
prop: 'roles', prop: 'roles',
type: 'tagMore', type: 'tagMore',
columnValue: (row) => { return this.$convertField(row.roles, this.$ConstSelect.roleList, ['value', 'label'], true); }, columnValue: (row) => { return this.$convertField(row.roles, this.$ConstSelect.roleList, ['value', 'label'], true); },
@ -160,9 +163,13 @@ export default {
name: this.$t('global.edit'), name: this.$t('global.edit'),
handleClick: this.handleUserEdit handleClick: this.handleUserEdit
}, },
// {
// name: '',
// handleClick: this.handleBind
// },
{ {
name: '绑定组织管理员', name: '组织关系',
handleClick: this.handleBind handleClick: this.handleRelation
}, },
{ {
name: '重置密码', name: '重置密码',
@ -227,6 +234,9 @@ export default {
handleBind(index, row) { handleBind(index, row) {
this.$refs.bindCompany.doShow(row); this.$refs.bindCompany.doShow(row);
}, },
handleRelation(index, row) {
this.$refs.companyRelation.doShow(row);
},
resetPassword(index, row) { resetPassword(index, row) {
this.$confirm('操作会将改用户密码重置为初始密码,是否继续', this.$t('global.tips'), { this.$confirm('操作会将改用户密码重置为初始密码,是否继续', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'), confirmButtonText: this.$t('global.confirm'),