用户管理 角色管理修改

This commit is contained in:
fengachen
2021-08-25 11:32:17 +08:00
parent 858b8c12e7
commit c292e4e3ac
7 changed files with 241 additions and 68 deletions
+4 -1
View File
@@ -18,6 +18,8 @@ const frozenBatch = (params)=>putAction("/sys/user/frozenBatch",params);
const checkOnlyUser = (params)=>getAction("/sys/user/checkOnlyUser",params);
//改变密码
const changePassword = (params)=>putAction("/sys/user/changePassword",params);
// 重置密码
const resetUserPassword = (params) => putAction('',params)
//权限管理
const addPermission= (params)=>postAction("/sys/permission/add",params);
@@ -153,7 +155,8 @@ export {
saveDeptRolePermission,
queryMyDepartTreeList,
getUserNoticeInfo,
getDictItemsFromCache
getDictItemsFromCache,
resetUserPassword
}
+92 -63
View File
@@ -3,25 +3,25 @@
* 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal
* data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除
*/
import { filterObj } from '@/utils/util';
import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage'
import {filterObj} from '@/utils/util';
import {deleteAction, getAction, downFile, getFileAccessHttpUrl} from '@/api/manage'
import Vue from 'vue'
import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types"
import {ACCESS_TOKEN, TENANT_ID} from "@/store/mutation-types"
import store from '@/store'
import {Modal} from 'ant-design-vue'
import { deleteByDepartId } from "@api/api";
import {deleteByDepartId} from "@api/api";
export const JeroListMixin = {
data(){
data() {
return {
/* 查询条件-请不要在queryParam中声明非字符串值的属性 */
queryParam: {},
// 记录上一次查询的条件,防止查询处输入框的数据发生变化,未点击查询按钮,再点击分页的时候数据发生变化
lastQueryParam: {},
/* 数据源 */
dataSource:[],
dataSource: [],
/* 分页参数 */
ipagination:{
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30', '50'],
@@ -33,22 +33,22 @@ export const JeroListMixin = {
total: 0
},
/* 排序参数 */
isorter:{
isorter: {
column: 'createTime',
order: 'desc',
},
/* 筛选参数 */
filters: {},
/* table加载状态 */
loading:false,
loading: false,
/* table选中keys*/
selectedRowKeys: [],
/* table选中records*/
selectionRows: [],
/* 查询折叠 */
toggleSearchStatus:false,
toggleSearchStatus: false,
/* 高级查询条件生效状态 */
superQueryFlag:false,
superQueryFlag: false,
/* 高级查询条件 */
superQueryParams: '',
/** 高级查询拼接方式 */
@@ -56,26 +56,26 @@ export const JeroListMixin = {
}
},
created() {
if(!this.disableMixinCreated){
this.loadData();
//初始化字典配置 在自己页面定义
this.initDictConfig();
}
if (!this.disableMixinCreated) {
this.loadData();
//初始化字典配置 在自己页面定义
this.initDictConfig();
}
},
computed: {
//token header
tokenHeader(){
tokenHeader() {
let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)}
let tenantid = Vue.ls.get(TENANT_ID)
if(tenantid){
if (tenantid) {
head['tenant_id'] = tenantid
}
return head;
}
},
methods:{
methods: {
loadData(arg) {
if(!this.url.list){
if (!this.url.list) {
this.$message.error("请设置url.list属性!")
return
}
@@ -88,34 +88,33 @@ export const JeroListMixin = {
getAction(this.url.list, params).then((res) => {
if (res.success) {
//update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
this.dataSource = res.result.records||res.result;
if(res.result.total)
{
this.dataSource = res.result.records || res.result;
if (res.result.total) {
this.ipagination.total = res.result.total;
//清空列表选中
this.onClearSelected()
}else{
} else {
this.ipagination.total = 0;
}
//update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
}
if(res.code===510){
if (res.code === 510) {
this.$message.warning(res.message)
}
this.loading = false;
})
},
initDictConfig(){
initDictConfig() {
},
handleSuperQuery(params, matchType) {
//高级查询方法
if(!params){
this.superQueryParams=''
if (!params) {
this.superQueryParams = ''
this.superQueryFlag = false
}else{
} else {
this.superQueryFlag = true
this.superQueryParams=JSON.stringify(params)
this.superQueryParams = JSON.stringify(params)
this.superQueryMatchType = matchType
}
this.loadData(1)
@@ -123,12 +122,12 @@ export const JeroListMixin = {
getQueryParams() {
//获取查询条件
let sqp = {}
if(this.superQueryParams){
sqp['superQueryParams']=encodeURI(this.superQueryParams)
if (this.superQueryParams) {
sqp['superQueryParams'] = encodeURI(this.superQueryParams)
sqp['superQueryMatchType'] = this.superQueryMatchType
}
// var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
var param = Object.assign(sqp, this.lastQueryParam, this.isorter ,this.filters);
var param = Object.assign(sqp, this.lastQueryParam, this.isorter, this.filters);
param.field = this.getQueryField();
param.pageNo = this.ipagination.current;
param.pageSize = this.ipagination.pageSize;
@@ -152,7 +151,7 @@ export const JeroListMixin = {
this.selectionRows = [];
},
searchQuery() {
this.lastQueryParam = { ...this.queryParam }
this.lastQueryParam = {...this.queryParam}
this.loadData(1);
},
superQuery() {
@@ -164,7 +163,7 @@ export const JeroListMixin = {
this.loadData(1);
},
batchDel: function () {
if(!this.url.deleteBatch){
if (!this.url.deleteBatch) {
this.$message.error("请设置url.deleteBatch属性!")
return
}
@@ -204,7 +203,7 @@ export const JeroListMixin = {
}
},
handleDelete: function (id) {
if(!this.url.delete){
if (!this.url.delete) {
this.$message.error("请设置url.delete属性!")
return
}
@@ -212,7 +211,7 @@ export const JeroListMixin = {
this.$confirm({
title: "确认删除",
content: "确定要删除此条数据吗?",
onOk: function() {
onOk: function () {
deleteAction(that.url.delete, {id: id}).then((res) => {
if (res.success) {
that.$message.success(res.message);
@@ -248,11 +247,11 @@ export const JeroListMixin = {
this.ipagination = pagination;
this.loadData();
},
handleToggleSearch(){
handleToggleSearch() {
this.toggleSearchStatus = !this.toggleSearchStatus;
},
// 给popup查询使用(查询区域不支持回填多个字段,限制只返回一个字段)
getPopupField(fields){
getPopupField(fields) {
return fields.split(',')[0]
},
modalFormOk() {
@@ -261,39 +260,66 @@ export const JeroListMixin = {
//清空列表选中
this.onClearSelected()
},
handleDetail:function(record){
handleDetail: function (record) {
this.$refs.modalForm.edit(record);
this.$refs.modalForm.title="详情";
this.$refs.modalForm.title = "详情";
this.$refs.modalForm.disableSubmit = true;
},
/* 导出 */
handleExportXls2(){
handleExportXls2() {
let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()));
let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
window.location.href = url;
},
handleExportXls(fileName){
if(!fileName || typeof fileName != "string"){
handleExportXls(fileName) {
if (!fileName || typeof fileName != "string") {
fileName = "导出文件"
}
let param = this.getQueryParams();
if(this.selectedRowKeys && this.selectedRowKeys.length>0){
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
param['selections'] = this.selectedRowKeys.join(",")
}
console.log("导出参数",param)
downFile(this.url.exportXlsUrl,param).then((data)=>{
console.log("导出参数", param)
downFile(this.url.exportXlsUrl, param).then((data) => {
if (!data) {
this.$message.warning("文件下载失败")
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
}else{
let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls')
} else {
let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'}))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName+'.xls')
link.setAttribute('download', fileName + '.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link); //下载完成移除元素
window.URL.revokeObjectURL(url); //释放掉blob对象
}
})
},
/*
* 下载模板
* */
downTemplate(fileName) {
if (!fileName || typeof fileName != "string") {
fileName = "模板文件"
}
downFile(this.url.downTemplateUrl).then((data) => {
if (!data) {
this.$message.warning("文件下载失败")
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls')
} else {
let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'}))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName + '.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link); //下载完成移除元素
@@ -302,7 +328,7 @@ export const JeroListMixin = {
})
},
/* 导入 */
handleImportExcel(info){
handleImportExcel(info) {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList);
}
@@ -310,14 +336,17 @@ export const JeroListMixin = {
if (info.file.response.success) {
// this.$message.success(`${info.file.name} 文件上传成功`);
if (info.file.response.code === 201) {
let { message, result: { msg, fileUrl, fileName } } = info.file.response
let {message, result: {msg, fileUrl, fileName}} = info.file.response
let href = window._CONFIG['domianURL'] + fileUrl
this.$warning({
title: message,
content: (<div>
<span>{msg}</span><br/>
<span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span>
</div>
<span>{msg}</span>
<br/>
<span>具体详情请
<a href={href} target="_blank" download={fileName}>点击下载</a>
</span>
</div>
)
})
} else {
@@ -351,21 +380,21 @@ export const JeroListMixin = {
}
},
/* 图片预览 */
getImgView(text){
if(text && text.indexOf(",")>0){
text = text.substring(0,text.indexOf(","))
getImgView(text) {
if (text && text.indexOf(",") > 0) {
text = text.substring(0, text.indexOf(","))
}
return getFileAccessHttpUrl(text)
},
/* 文件下载 */
// update--autor:lvdandan-----date:20200630------for:修改下载文件方法名uploadFile改为downloadFile------
downloadFile(text){
if(!text){
downloadFile(text) {
if (!text) {
this.$message.warning("未知的文件")
return;
}
if(text.indexOf(",")>0){
text = text.substring(0,text.indexOf(","))
if (text.indexOf(",") > 0) {
text = text.substring(0, text.indexOf(","))
}
let url = getFileAccessHttpUrl(text)
window.open(url);
+1 -1
View File
@@ -119,7 +119,7 @@ export default {
}
],
url: {
// list: "/sys/role/page",
list: "/sys/role/page",
delete: "/sys/role/delete",
deleteBatch: "/sys/role/deleteBatch",
list2: "/sys/user/userRoleList",
+87
View File
@@ -11,6 +11,37 @@
</a-form-item>
</a-col>
<a-col :md="6" :sm="12">
<a-form-item
label="角色类型"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<a-tree-select
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 :md="6" :sm="12">
<a-form-item
label="组织机构"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<a-tree-select
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">查询</a-button>
@@ -24,6 +55,10 @@
<!-- 操作按钮区域 -->
<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">下载模板</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload>
<a-button @click="batchDel" type="danger" icon="delete">批量删除</a-button>
</div>
@@ -44,6 +79,7 @@
<span slot="action" class="action-span-cell" slot-scope="text, record">
<a @click="handleEdit(record)" v-has="'user:edit'">编辑</a>
<a @click="resetPassword(record.id)" >重置密码</a>
<a @click="handleDelete(record.id)" v-has="'sys:user:del'">删除</a>
</span>
<template slot="text" slot-scope="text">
@@ -66,6 +102,8 @@ import { getFileAccessHttpUrl } from "@/api/manage";
import { JeroListMixin } from "@/mixins/JeroListMixin";
import JInput from "@/components/jero/JInput";
import JEllipsis from "@comp/jero/JEllipsis";
import {queryDepartTreeList, resetUserPassword} from "@api/api";
export default {
name: "UserList",
@@ -151,6 +189,18 @@ export default {
width: 170
}
],
// 组织机构 下拉数据
treeDepartData:[],
// 角色类型下拉数据
treeRoleData:[],
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 20 },
sm: { span: 16 },
},
superQueryFieldList: [
{ type: "input", value: "username", text: "用户账号" }
],
@@ -163,12 +213,49 @@ export default {
}
};
},
created() {
this.loadDepartTreeData()
},
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);
}
}
})
},
/*
* 重置密码
* */
resetPassword(id){
resetUserPassword({id:id}).then( res => {
if(res.success){
this.$message.success(res.message)
}else {
this.$message.warning(res.message)
}
})
}
}
+3 -1
View File
@@ -75,7 +75,8 @@
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="授权标识">
<a-input placeholder="请输入授权标识, 如: user:list" @change="event => event.target.value = event.target.value.trim()" :maxLength="50" v-decorator="[ 'perms', {rules:[{ required: false, message: '请输入授权标识!' },{validator: this.validatePerms }]}]" :readOnly="disableSubmit"/>
<!-- {validator: this.validatePerms }-->
<a-input placeholder="请输入授权标识, 如: user:list" @change="event => event.target.value = event.target.value.trim()" :maxLength="50" v-decorator="[ 'perms', {rules:[{ required: false, message: '请输入授权标识!' }]}]" :readOnly="disableSubmit"/>
</a-form-item>
<a-form-item
@@ -243,6 +244,7 @@
temp.isLeaf = temp.leaf;
that.treeData.push(temp);
}
console.log(this.treeData)
}
});
},
-1
View File
@@ -102,7 +102,6 @@
this.edit({});
},
edit (record) {
debugger
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
+54 -1
View File
@@ -100,6 +100,36 @@
</a-select>
</a-form-item>
<a-form-item
label="角色类型"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<a-tree-select
style="width:100%"
:dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }"
:treeData="treeRoleData"
v-decorator="[ 'roleParentId', validatorRules.name]"
placeholder="请选择角色类型"
>
</a-tree-select>
</a-form-item>
<a-form-item
label="组织机构"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<a-tree-select
style="width:100%"
:dropdownStyle="{ maxHeight: '200px',maxWidth:'100px','overflow-x':'hidden',' overflo-y': 'auto' }"
:treeData="treeDepartData"
v-decorator="[ 'departId', validatorRules.name]"
placeholder="请选择组织机构">
</a-tree-select>
</a-form-item>
<a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input placeholder="请输入邮箱" :disabled="disableSubmit" @change="event => event.target.value = event.target.value.trim()" v-decorator="[ 'email', validatorRules.email]" :maxLength="50"/>
</a-form-item>
@@ -137,7 +167,7 @@ import moment from 'moment'
import Vue from 'vue'
import {ACCESS_TOKEN} from "@/store/mutation-types"
import {getAction} from '@/api/manage'
import {addUser, editUser, queryUserRole, queryall} from '@/api/api'
import {addUser, editUser, queryUserRole, queryall, queryDepartTreeList} from '@/api/api'
import {disabledAuthFilter} from "@/utils/authFilter"
import {duplicateCheck} from '@/api/api'
import { isEmail, passwordReg} from "@/utils/validate";
@@ -156,6 +186,12 @@ export default {
drawerWidth: 700,
modaltoggleFlag: true,
confirmDirty: false,
// 组织机构 下拉数据
treeDepartData:[],
// 角色类型下拉数据
treeRoleData:[],
selectedDepartKeys: [], //保存用户选择部门id
checkedDepartKeys: [],
checkedDepartNames: [], // 保存部门的名称 =>title
@@ -303,6 +339,8 @@ export default {
},
edit(record) {
this.resetScreenSize(); // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
// 加载组织机构数据
this.loadDepartTreeData()
// 获取公钥
this.getPublicKey()
let that = this;
@@ -341,6 +379,21 @@ export default {
}
//update-end-author:taoyan date:2020710 for:多租户配置
},
// 组织机构下拉数据
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);
}
}
})
},
//
getPublicKey() {
// 获取公钥