2019-10-31 15:34:38 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
|
2020-11-30 18:22:22 +08:00
|
|
|
<dictionary-edit ref="edit" :company-list="companyList" @reloadTable="reloadTable" />
|
2020-03-30 15:28:13 +08:00
|
|
|
<create-user ref="createUser" />
|
2019-10-31 15:34:38 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { getUserList } from '@/api/management/user';
|
2020-11-30 18:22:22 +08:00
|
|
|
import { getCompanyList } from '@/api/company';
|
2019-10-31 15:34:38 +08:00
|
|
|
import DictionaryEdit from './edit';
|
2020-03-30 15:28:13 +08:00
|
|
|
import CreateUser from './createUser';
|
2019-10-31 15:34:38 +08:00
|
|
|
|
|
|
|
export default {
|
2019-11-08 16:22:05 +08:00
|
|
|
name: 'UserControl',
|
|
|
|
components: {
|
|
|
|
DictionaryEdit,
|
2020-03-30 15:28:13 +08:00
|
|
|
CreateUser
|
2019-11-08 16:22:05 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
pagerConfig: {
|
|
|
|
pageSize: 'pageSize',
|
|
|
|
pageIndex: 'pageNum'
|
|
|
|
},
|
2020-11-30 18:22:22 +08:00
|
|
|
companyMap: {},
|
|
|
|
companyList: [],
|
2019-11-08 16:22:05 +08:00
|
|
|
queryForm: {
|
|
|
|
labelWidth: '80px',
|
|
|
|
reset: true,
|
|
|
|
queryObject: {
|
|
|
|
name: {
|
|
|
|
type: 'text',
|
|
|
|
label: this.$t('system.name')
|
|
|
|
},
|
|
|
|
roles: {
|
|
|
|
type: 'select',
|
|
|
|
label: this.$t('system.roles'),
|
|
|
|
config: {
|
|
|
|
data: this.$ConstSelect.roleList
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-10-31 15:34:38 +08:00
|
|
|
|
2019-11-08 16:22:05 +08:00
|
|
|
},
|
|
|
|
queryList: {
|
|
|
|
query: getUserList,
|
|
|
|
selectCheckShow: false,
|
|
|
|
indexShow: true,
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
title: this.$t('system.name'),
|
|
|
|
prop: 'name'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('system.nickname'),
|
|
|
|
prop: 'nickname'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('global.mobile'),
|
|
|
|
prop: 'mobile'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t('global.email'),
|
|
|
|
prop: 'email'
|
|
|
|
},
|
2020-11-30 18:22:22 +08:00
|
|
|
{
|
|
|
|
title: '单位',
|
|
|
|
prop: 'companyId',
|
|
|
|
type: 'tag',
|
|
|
|
columnValue: (row) => { return this.getCompanyName(row.companyId); },
|
|
|
|
tagType: (row) => { return 'success'; }
|
|
|
|
},
|
2019-11-08 16:22:05 +08:00
|
|
|
{
|
|
|
|
title: this.$t('system.roles'),
|
|
|
|
prop: 'roles',
|
|
|
|
type: 'tagMore',
|
|
|
|
columnValue: (row) => { return this.$convertField(row.roles, this.$ConstSelect.roleList, ['value', 'label'], true); },
|
|
|
|
tagType: (row) => { return 'success'; }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'button',
|
|
|
|
title: this.$t('global.operate'),
|
|
|
|
width: '250',
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
name: this.$t('global.edit'),
|
|
|
|
handleClick: this.handleUserEdit
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2020-03-30 15:28:13 +08:00
|
|
|
],
|
|
|
|
actions: [
|
2020-10-15 18:33:36 +08:00
|
|
|
{ text: '创建本地用户', btnCode: 'employee_auto', handler: this.createLocalUsers },
|
|
|
|
{ text: '单位管理', btnCode: 'company_manage', handler: this.companyManage }
|
2019-11-08 16:22:05 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
currentModel: {}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
2020-11-30 18:22:22 +08:00
|
|
|
this.companyMap = {};
|
|
|
|
this.companyList = [];
|
|
|
|
getCompanyList().then(resp => {
|
|
|
|
if (resp && resp.data && resp.data.length) {
|
|
|
|
resp.data.forEach(item => {
|
|
|
|
this.companyMap[item.id] = item.name;
|
|
|
|
this.companyList.push({label: item.name, value: parseInt(item.id)});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).catch((error) => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
2019-11-08 16:22:05 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 编辑
|
|
|
|
handleUserEdit(index, row) {
|
|
|
|
this.$refs.edit.doShow(row);
|
|
|
|
},
|
2020-11-30 18:22:22 +08:00
|
|
|
getCompanyName(companyId) {
|
|
|
|
return this.companyMap[companyId];
|
|
|
|
},
|
2019-11-08 16:22:05 +08:00
|
|
|
reloadTable() {
|
|
|
|
this.queryList.reload();
|
2020-03-30 15:28:13 +08:00
|
|
|
},
|
|
|
|
createLocalUsers() {
|
|
|
|
this.$refs.createUser.doShow();
|
2020-10-15 18:33:36 +08:00
|
|
|
},
|
|
|
|
companyManage() {
|
|
|
|
this.$router.push({ path: `/system/companyManage`});
|
2019-11-08 16:22:05 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-31 15:34:38 +08:00
|
|
|
};
|
|
|
|
</script>
|