353 lines
11 KiB
Vue
353 lines
11 KiB
Vue
<template>
|
|
<div>
|
|
<page-header-title :img-for-icon="IconImg"></page-header-title>
|
|
<a-card :bordered="false">
|
|
<!-- 查询区域 -->
|
|
<div class="table-page-search-wrapper">
|
|
<a-form layout="inline" @keyup.enter.native="searchQuery">
|
|
<a-row :gutter="24">
|
|
|
|
<a-col :xl="8" :lg="8" :md="8" :sm="24">
|
|
<a-form-item label="用户账号">
|
|
<a-input placeholder="请输入用户账号" v-model="queryParam.username" :maxLength="50"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
|
|
<a-col :xl="8" :lg="8" :md="8" :sm="24">
|
|
<a-form-item label="用户姓名">
|
|
<a-input placeholder="请输入用户姓名" v-model="queryParam.realname" :maxLength="50"></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
|
|
<a-col :xl="8" :lg="8" :md="8" :sm="24">
|
|
<a-form-item
|
|
label="角色类型"
|
|
:labelCol="labelCol"
|
|
:wrapperCol="wrapperCol">
|
|
<a-tree-select
|
|
:multiple="false"
|
|
show-search
|
|
tree-default-expand-all
|
|
tree-node-filter-prop="title"
|
|
style="width:100%"
|
|
:dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }"
|
|
:treeData="treeRoleData"
|
|
v-model="queryParam.roleId"
|
|
placeholder="请选择角色类型"
|
|
>
|
|
</a-tree-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
|
|
<a-col :xl="8" :lg="8" :md="8" :sm="24">
|
|
<a-form-item
|
|
label="组织机构"
|
|
:labelCol="labelCol"
|
|
:wrapperCol="wrapperCol">
|
|
<a-tree-select
|
|
:multiple="false"
|
|
show-search
|
|
tree-default-expand-all
|
|
tree-node-filter-prop="title"
|
|
style="width:100%"
|
|
:dropdownStyle="{ maxHeight: '200px',maxWidth:'100px','overflow-x':'hidden',' overflo-y': 'auto' }"
|
|
:treeData="treeDepartData"
|
|
v-model="queryParam.departId"
|
|
placeholder="请选择组织机构">
|
|
</a-tree-select>
|
|
</a-form-item>
|
|
</a-col>
|
|
|
|
<a-col :md="6" :sm="8">
|
|
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
|
<a-button type="primary" @click="searchQuery" icon="search" v-has="'user:search'">查询</a-button>
|
|
<a-button class="reset-button" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
|
|
</span>
|
|
</a-col>
|
|
</a-row>
|
|
</a-form>
|
|
</div>
|
|
|
|
<!-- 操作按钮区域 -->
|
|
<div class="table-operator" style="border-top: 5px">
|
|
<a-button @click="handleAdd" type="primary" icon="plus" v-has="'user:add'">新增</a-button>
|
|
<a-button @click="downTemplate('用户导入模板')" type="primary" icon="download" v-has="'user:downTemplate'">下载模板</a-button>
|
|
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
|
|
@change="handleImportExcel" v-has="'sys:user:import'">
|
|
<a-button type="primary" icon="import">导入</a-button>
|
|
</a-upload>
|
|
<a-button @click="handleExportXls('用户列表')" type="primary" icon="export" v-has="'sys:user:export'">导出</a-button>
|
|
<a-button @click="batchDel" type="danger" icon="delete" v-has="'user:batchDel'">批量删除</a-button>
|
|
</div>
|
|
|
|
<!-- table区域-begin -->
|
|
<div>
|
|
|
|
<a-table
|
|
ref="table"
|
|
bordered
|
|
size="middle"
|
|
rowKey="id"
|
|
:scroll="{x:true}"
|
|
:columns="columns"
|
|
:dataSource="dataSource"
|
|
:pagination="ipagination"
|
|
:loading="loading"
|
|
class="j-table-force-nowrap"
|
|
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
|
|
@change="handleTableChange">
|
|
|
|
<span slot="action" class="action-span-cell" slot-scope="text, record">
|
|
<!-- 1是启用 2是禁用 按钮需要反着来-->
|
|
<a @click="handleEnable(record)"
|
|
:class="{'color-red':record.status === 1}"
|
|
v-has="'user:enable'">{{ record.status === 1 ? '禁用' : '启用' }}</a>
|
|
<a @click="handleEdit(record)" v-has="'user:edit'">编辑</a>
|
|
<a @click="resetPassword(record)" v-has="'user:resetPassword'">重置密码</a>
|
|
<a @click="handleDelete(record.id)" v-has="'sys:user:del'">删除</a>
|
|
</span>
|
|
<template slot="text" slot-scope="text">
|
|
<j-ellipsis v-if="text" :length="20" :value="text"></j-ellipsis>
|
|
<span v-else></span>
|
|
</template>
|
|
|
|
</a-table>
|
|
</div>
|
|
<!-- table区域-end -->
|
|
|
|
<user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
|
|
|
|
</a-card>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import UserModal from './modules/UserModal'
|
|
import { getAction, getFileAccessHttpUrl } from '@/api/manage'
|
|
import { frozenBatch } from '@api/api'
|
|
import '@/assets/less/TableExpand.less'
|
|
import { JeroListMixin } from '@/mixins/JeroListMixin'
|
|
import '@/assets/less/TableExpand.less'
|
|
// import JInput from '@/components/jero/JInput'
|
|
import JEllipsis from '@comp/jero/JEllipsis'
|
|
import { queryDepartTreeList, resetUserPassword } from '@api/api'
|
|
import IconImg from '@/assets/imgs/icon/icon_system.png'
|
|
import PageHeaderTitle from '../../components/layouts/PageHeaderTitle'
|
|
|
|
|
|
export default {
|
|
name: 'UserList',
|
|
mixins: [JeroListMixin],
|
|
components: {
|
|
UserModal,
|
|
// JInput,
|
|
JEllipsis,
|
|
PageHeaderTitle
|
|
},
|
|
data() {
|
|
return {
|
|
IconImg,
|
|
description: '这是用户管理页面',
|
|
columns: [
|
|
{
|
|
title: '序号',
|
|
dataIndex: '',
|
|
key: 'rowIndex',
|
|
width: 60,
|
|
align: 'center',
|
|
customRender: function (t, r, index) {
|
|
return parseInt(index) + 1
|
|
}
|
|
},
|
|
{
|
|
title: '用户账号',
|
|
align: 'center',
|
|
dataIndex: 'username',
|
|
width: 120,
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{
|
|
title: '用户姓名',
|
|
align: 'center',
|
|
width: 160,
|
|
dataIndex: 'realname',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
// {
|
|
// title: "性别",
|
|
// align: "center",
|
|
// width: 80,
|
|
// dataIndex: "sex_dictText",
|
|
// scopedSlots: { customRender: "text" },
|
|
// },
|
|
{
|
|
title: '手机号码',
|
|
align: 'center',
|
|
width: 160,
|
|
dataIndex: 'phone',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{
|
|
title: '角色类型',
|
|
align: 'center',
|
|
width: 100,
|
|
dataIndex: 'roleName',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{
|
|
title: '组织机构',
|
|
align: 'center',
|
|
width: 180,
|
|
dataIndex: 'departIds_dictText',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
// {
|
|
// title: '生日',
|
|
// align: "center",
|
|
// width: 100,
|
|
// dataIndex: 'birthday'
|
|
// },
|
|
// {
|
|
// title: '负责部门',
|
|
// align: "center",
|
|
// width: 180,
|
|
// dataIndex: 'departIds_dictText'
|
|
// },
|
|
{
|
|
title: '创建时间',
|
|
dataIndex: 'createTime',
|
|
align: 'center',
|
|
width: 170,
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{
|
|
title: '状态',
|
|
align: 'center',
|
|
width: 80,
|
|
dataIndex: 'status_dictText',
|
|
scopedSlots: { customRender: 'text' }
|
|
},
|
|
{
|
|
title: '操作',
|
|
dataIndex: 'action',
|
|
scopedSlots: { customRender: 'action' },
|
|
align: 'center'
|
|
}
|
|
],
|
|
// 组织机构 下拉数据
|
|
treeDepartData: [],
|
|
// 角色类型下拉数据
|
|
treeRoleData: [],
|
|
labelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 5 }
|
|
},
|
|
wrapperCol: {
|
|
xs: { span: 20 },
|
|
sm: { span: 16 }
|
|
},
|
|
superQueryFieldList: [
|
|
{ type: 'input', value: 'username', text: '用户账号' }
|
|
],
|
|
url: {
|
|
list: '/sys/user/pageRoleAndDepart',
|
|
delete: '/sys/user/delete',
|
|
deleteBatch: '/sys/user/deleteBatch',
|
|
exportXlsUrl: '/sys/user/exportXls',
|
|
importExcelUrl: 'sys/user/importExcel',
|
|
downTemplateUrl: 'sys/user/exportTemplate'
|
|
}
|
|
}
|
|
},
|
|
created() {
|
|
this.loadDepartTreeData()
|
|
this.initAllRole()
|
|
},
|
|
computed: {
|
|
importExcelUrl() {
|
|
return `${ window._CONFIG['domianURL'] }/${ this.url.importExcelUrl }`
|
|
}
|
|
},
|
|
methods: {
|
|
getAvatarView: function (avatar) {
|
|
return getFileAccessHttpUrl(avatar)
|
|
},
|
|
passwordModalOk() {
|
|
//TODO 密码修改完成 不需要刷新页面,可以把datasource中的数据更新一下
|
|
},
|
|
/*
|
|
* 组织机构下拉数据
|
|
* */
|
|
loadDepartTreeData() {
|
|
const that = this
|
|
queryDepartTreeList().then((res) => {
|
|
if (res.success) {
|
|
that.treeDepartData = []
|
|
let treeList = res.result
|
|
for (let a = 0; a < treeList.length; a++) {
|
|
let temp = treeList[a]
|
|
temp.isLeaf = temp.leaf
|
|
that.treeDepartData.push(temp)
|
|
}
|
|
}
|
|
})
|
|
},
|
|
/*
|
|
* 角色下拉数据
|
|
* */
|
|
initAllRole() {
|
|
getAction('/sys/role/treeList').then(res => {
|
|
this.treeRoleData = res.result || []
|
|
})
|
|
},
|
|
/*
|
|
* 重置密码
|
|
* */
|
|
resetPassword(record) {
|
|
const that = this
|
|
this.$confirm({
|
|
title: '确认重置密码',
|
|
content: '是否重置该用户密码',
|
|
onOk: function () {
|
|
resetUserPassword({ username: record.username }).then(res => {
|
|
if (res.success) {
|
|
that.$message.success(res.message)
|
|
} else {
|
|
that.$message.warning(res.message)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
},
|
|
/*
|
|
* 启用禁用
|
|
* */
|
|
handleEnable(record) {
|
|
let status
|
|
if (record.status === 1) {
|
|
status = 2
|
|
} else if (record.status === 2) {
|
|
status = 1
|
|
}
|
|
frozenBatch({ ids: record.id, status }).then(res => {
|
|
if (res.success) {
|
|
this.$message.success(res.message)
|
|
this.loadData()
|
|
} else {
|
|
this.$message.warn(res.message)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
}
|
|
</script>
|
|
<style scoped lang="less">
|
|
@import '~@assets/less/common.less';
|
|
|
|
.color-red {
|
|
color: red;
|
|
}
|
|
</style>
|