Commit 060784a8 by liimin

权限完善

1 parent c2e97b11
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 17:18:41
* @Last Modified time: 2019-09-02 14:26:14
*/
import request from './request'
......@@ -27,3 +27,12 @@ export function Reg (data = {}) {
data.method = `${user_path}register`
return request(data, RequestMethods.GET)
}
/**
* 获取用户列表
* @param {*} data 参数
*/
export function UserList (data = {}) {
data.method = `${user_path}search`
return request(data, RequestMethods.GET)
}
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-08-26 18:02:55
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 17:19:07
* @Last Modified time: 2019-09-02 10:49:21
*/
import request from './request'
......@@ -44,3 +44,12 @@ export function FetchRoleList (data = {}) {
data.method = `fims.role.list`
return request(data, RequestMethods.GET)
}
/**
* 获取职务列表
* @param {*} data 参数
*/
export function PostList (data = {}) {
data.method = `${path}post`
return request(data, RequestMethods.GET)
}
......@@ -116,6 +116,7 @@
.d2-layout-header-aside-content {
// [布局] 顶栏
.d2-theme-header {
transition: .1s ease;
// logo区域
.logo-group {
transition: width .3s;
......@@ -143,6 +144,7 @@
}
}
.el-menu-item {
transition: .1s ease;
@extend %header-menu-item;
border-bottom: none;
}
......
/*
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified time: 2019-09-02 10:52:44
*/
export const BaseData = {
ROLE: 'role',
COMPANY: 'company',
DEPART: 'depart',
STATION: 'station'
STATION: 'station',
POST:'post'
}
......@@ -48,8 +48,11 @@ export default {
},
created () {
// this.$vrm.setRoles(this.btnIdAll)
const { action, operation } = this.curBtns
this.isInRole = [...action, ...operation].find(obj => obj.id === this.id || obj.label === this.label)
if(this.curBtns){
// const { action, operation } = this.curBtns
// console.log(this.label);
this.isInRole = this.curBtns.find(obj => obj.id === this.id || obj.label === this.label)
}
},
methods: {
handleClick: function () {
......
......@@ -18,7 +18,7 @@ export default {
data () {
return {
options: [
{ label: '默认', value: 'default' },
{ label: '大', value: 'default' },
{ label: '中', value: 'medium' },
{ label: '小', value: 'small' },
{ label: '最小', value: 'mini' }
......
......@@ -16,12 +16,9 @@
flex-box="0"
flex>
<div class="logo-group d2-theme-header-logo" :class="asideCollapse ? 'logo-only' : 'logo-all'" flex-box="0">
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/icon-only.png`">
<img v-else :src="`${$baseUrl}image/theme/${themeActiveSetting.name}/logo/all.png`">
<img v-if="asideCollapse" :src="`${$baseUrl}image/theme/logo/icon-only.png`">
<img v-else :src="`${$baseUrl}image/theme/logo/all.png`">
</div>
<!-- <div class="toggle-aside-btn" @click="handleToggleAside" flex-box="0">
<d2-icon name="bars"/>
</div> -->
<hamburger :onClick="handleToggleAside" :isActive="asideCollapse" flex-box="0" class="toggle-aside-btn"></hamburger>
<d2-menu-header flex-box="1"/>
<!-- 顶栏右侧 -->
......
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 23:05:36
* @Last Modified time: 2019-09-02 16:20:21
*/
const permision = {}
/**
......@@ -16,21 +16,30 @@ permision.packRoutesBtns = function (resources, idsInPermision) {
}
let __aRouteInPermision = []
let __oBtnInPermision = {}
// __aBtnIdAll=[],
let __objResource = null
let __obj = null
idsInPermision.forEach(obj => {
__objResource = resources[obj.id]
if (__objResource) { // 直接能取到的为路由 (也可以在routes 中定标识变量)
__aRouteInPermision.push(resources[obj.id])// push 进 路由数组
__aRouteInPermision.push(resources[obj.id]) // push 进 路由数组
} else { // 如果取不到 判断是否有父节点 并且父节点是否有auth属性 有 则视为按钮 (同样可以定义标识变量)
__objResource = resources[obj.pid]
if (__objResource && __objResource.auth && !__oBtnInPermision[obj.pid]) {
__oBtnInPermision[obj.pid] = __objResource.auth
if (__objResource && __objResource.auth) {
__obj =__objResource.auth.find(o => o.id === obj.id)
if (__oBtnInPermision[obj.pid] && __oBtnInPermision[obj.pid].length) {
__oBtnInPermision[obj.pid].push(__obj)
} else {
__oBtnInPermision[obj.pid] = [__obj]
}
// __oBtnInPermision[obj.pid] = __objResource.auth
// __aBtnIdAll = __aBtnIdAll.concat([...__objResource.auth.action.map(o=>o.id),...__objResource.auth.operation.map(o=>o.id)])
}
}
})
return { 'route': __aRouteInPermision, 'btn': __oBtnInPermision }
return {
'route': __aRouteInPermision,
'btn': __oBtnInPermision
}
}
/**
......@@ -78,9 +87,23 @@ permision.packAsideMenus = function (resources, idsInPermision) {
*/
permision.format2Menu = function (oMenu) {
if (!oMenu) return null
const { icon, path, meta } = oMenu
const { title, id, pid } = meta
return { title, icon, path, id, pid }
const {
icon,
path,
meta
} = oMenu
const {
title,
id,
pid
} = meta
return {
title,
icon,
path,
id,
pid
}
}
export default permision
export default permision
\ No newline at end of file
......@@ -8,11 +8,12 @@ const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
*/
const frameIn = [{
path: '/',
redirect: { name: 'index' },
redirect: {
name: 'index'
},
component: layoutHeaderAside,
children: []
}
]
}]
/**
* 首页
*/
......@@ -94,18 +95,15 @@ export const resources = {
cache: true
},
component: _import('demo/page2'),
auth: {
'operation': [{ // 列表操作
id: '1020201',
pid: '10202',
label: '查看'
}, { //
id: '1020202',
pid: '10202',
label: '编辑'
}],
'action': [] // 按钮操作
}
auth: [{ // 列表操作
id: '1020201',
pid: '10202',
label: '查看'
}, { //
id: '1020202',
pid: '10202',
label: '编辑'
}],
},
'10203': {
path: '/page3',
......@@ -116,18 +114,15 @@ export const resources = {
id: '10203',
pid: '102'
},
auth: {
'operation': [{ // 列表操作
id: '1020301',
pid: '10203',
label: '查看'
}, { //
id: '1020302',
pid: '10203',
label: '编辑'
}],
'action': [] // 按钮操作
},
auth: [{ // 列表操作
id: '1020301',
pid: '10203',
label: '查看'
}, { //
id: '1020302',
pid: '10203',
label: '编辑'
}],
component: _import('demo/page3')
},
// '102': {
......@@ -202,7 +197,7 @@ export const resources = {
component: _import('maintainManagement')
},
'107': {
path: '/user',
path: '/userManager',
icon: 'users',
name: '用户管理',
meta: {
......@@ -213,7 +208,7 @@ export const resources = {
}
},
'10701': {
path: '/userManage',
path: '/user',
name: '用户管理',
icon: 'user',
meta: {
......@@ -222,7 +217,36 @@ export const resources = {
id: '10701',
pid: '107'
},
component: _import('userManage/loginLogs')
auth: [{ // 列表操作
id: '1070101',
pid: '10701',
label: '审核'
}, { //
id: '1070102',
pid: '10701',
label: '重置密码'
}, { //
id: '1070103',
pid: '10701',
label: '编辑'
}, { //
id: '1070104',
pid: '10701',
label: '延期'
}, { //
id: '1070105',
pid: '10701',
label: '禁用'
}, { //
id: '1070106',
pid: '10701',
label: '激活'
}, { // 列表操作
id: '1070107',
pid: '10701',
label: '创建用户'
}],
component: _import('userManage/user')
},
'10702': {
path: '/jurisdictionManage',
......@@ -293,4 +317,4 @@ export default [
// dashboard,
...frameOut,
errorPage
]
]
\ No newline at end of file
......@@ -37,7 +37,7 @@ export default {
name: user.name
}, { root: true })
// 强制初始化基础数据
await dispatch('d2admin/base/init', null, { root: true })
dispatch('d2admin/base/init', null, { root: true })
// 用户登录后从持久化数据加载一系列的设置
await dispatch('load')
// 结束
......@@ -84,13 +84,10 @@ export default {
await dispatch('d2admin/page/openedLoad', null, { root: true })
// DB -> store 持久化数据加载侧边栏折叠状态
await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// await dispatch('d2admin/size/set', 'medium', { root: true })
// DB -> store 持久化数据加载全局尺寸
await dispatch('d2admin/size/load', null, { root: true })
// DB - > 初始化 基础数据
// await dispatch('d2admin/base/init', null, { root: true })
// // store 设置系统主色
// await dispatch('d2admin/color/set', process.env.VUE_APP_MAIN_COLOR)
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
// end
......
......@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 19:00:46
* @Last Modified time: 2019-09-02 16:30:11
*/
import util from '@/libs/util.js'
import router from '@/router'
......@@ -118,7 +118,7 @@ export default {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const { route, btn } = util.permision.packRoutesBtns(sources, __source)
const { route, btn } = util.permision.packRoutesBtns({...sources,home}, __source)
frameInRoutes[0].children = [home, ...route, ...sys]
router.addRoutes(frameInRoutes)
state.btns = btn
......
......@@ -2,16 +2,17 @@
* @Author: limin
* @Date: 2019-09-01 17:56:57
* @Last Modified by: limin
* @Last Modified time: 2019-09-01 18:57:45
* @Last Modified time: 2019-09-02 11:20:15
*/
import { FetchRoleList, CompanyList, DepartList, StationList } from '@/api/sys.base'
import { FetchRoleList, CompanyList, DepartList, StationList,PostList } from '@/api/sys.base'
import { BaseData } from '@/common/constants'
const map = {
[BaseData.ROLE]: FetchRoleList,
[BaseData.COMPANY]: CompanyList,
[BaseData.DEPART]: DepartList,
[BaseData.STATION]: StationList
[BaseData.STATION]: StationList,
[BaseData.POST]: PostList
}
export default {
namespaced: true,
......@@ -23,7 +24,9 @@ export default {
// 部门
depart: [],
// 站点
station: []
station: [],
//职务
post:[]
},
actions: {
/**
......@@ -37,14 +40,16 @@ export default {
FetchRoleList(),
CompanyList(),
DepartList(),
StationList()
]).then( async ([role, company, depart, station] = res) => {
StationList(),
PostList()
]).then( async ([role, company, depart, station, post] = res) => {
state.role = role
state.station = station
state.depart = depart
state.company = company
await dispatch('save2db', {path: `base`,value: {role, company, depart, station}})
resolve({ role, company, depart, station })
state.post = post
await dispatch('save2db', {path: `base`,value: {role, company, depart, station,post}})
resolve({ role, company, depart, station,post })
})
})
},
......@@ -77,8 +82,8 @@ export default {
if (state.role.length === 0) {
state = await dispatch('getFromdb','base') || await dispatch('init')
}
const {role, company, depart, station} = state
resolve({role, company, depart, station})
const {role, company, depart, station, post} = state
resolve({role, company, depart, station, post})
})
},
/**
......
import Vue from 'vue'
import router from '@/router'
const size = 'medium' // medium small mini
export default {
namespaced: true,
state: {
// 尺寸
value: 'medium' // medium small mini
value: ''// medium small mini
},
actions: {
/**
......@@ -66,7 +66,7 @@ export default {
state.value = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'size.value',
defaultValue: 'default',
defaultValue: size,
user: true
}, { root: true })
// 应用
......
......@@ -3,6 +3,7 @@
<el-table
:data="tableData"
border
size="small"
style="width: 100%">
<el-table-column
fixed
......
......@@ -62,9 +62,9 @@
<el-form-item label="职务:" prop="postCode">
<el-select v-model="regForm.postCode" placeholder="请选择">
<el-option
:label="role.roleName"
:value="role.roleId"
v-for="(role,index) in baseData.roles"
:label="post.postName"
:value="post.postCode"
v-for="(post,index) in baseData.posts"
:key="index"
></el-option>
</el-select>
......@@ -191,8 +191,8 @@ export default {
baseData: {
// 所属站点
stations: [],
// 角色
roles: [],
// 职务
posts: [],
// 部门
departs: [],
// 公司
......@@ -220,8 +220,8 @@ export default {
},
// 加载业务所需所有数据
async fetchData () {
const { role, company, depart, station } = await this.load()
this.baseData.roles = role
const { role, company, depart, station,post } = await this.load()
this.baseData.posts = post
this.baseData.stations = station
this.baseData.departs = depart
this.baseData.companys = company
......
<!-- 车辆管理 -->
<template>
<d2-container class="user">
<el-form :inline="true" :model="searchForm" label-width="85px">
<el-form-item label="用户">
<el-input v-model="searchForm.name" placeholder="请输入用户名/姓名/联系电话" clearable></el-input>
</el-form-item>
<el-form-item label="所属公司:">
<el-select v-model="searchForm.companyCode" placeholder="请选择">
<el-option
:label="company.companyName"
:value="company.companyCode"
v-for="(company,index) in baseData.companys"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="注册时间">
<el-date-picker
v-model="searchForm.times"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
<el-form-item label="角色:">
<el-select v-model="searchForm.postCode" placeholder="请选择">
<el-option
:label="role.roleName"
:value="role.roleId"
v-for="(role,index) in baseData.roles"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="searchForm.status" placeholder="请选择状态" clearable filterable>
<el-option label="在网" value="1"></el-option>
<el-option label="离网" value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属站点:">
<el-select v-model="searchForm.stationCode" placeholder="请选择" class="sigle-select">
<el-option
:label="station.stationName"
:value="station.stationCode"
v-for="(station,index) in baseData.stations"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="职务:">
<el-select v-model="searchForm.postCode" placeholder="请选择">
<el-option
:label="post.postName"
:value="post.postCode"
v-for="(post,index) in baseData.posts"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">查询</el-button>
</el-form-item>
</el-form>
<el-row style="height: 40px; line-height: 40px">
<el-col :span="12">用户列表</el-col>
<el-col :span="12" style="text-align: right">
<el-button @click="register()">创建用户</el-button>
</el-col>
</el-row>
<el-table :data="tableData" v-loading="tableLoading" border style="margin: 20px 0;">
<el-table-column align="center" width="60px" label="序号" type="index"></el-table-column>
<el-table-column
v-for="(item, index) in tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
align="center"
>
<template slot-scope="scope">
<template v-if="item.formatter">{{item.formatter(scope.row)}}</template>
<template v-else>{{tableData[scope.$index][item.prop]}}</template>
</template>
</el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="scope">
<auth-button type="text" label="重置密码" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="审核" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="编辑" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="延期" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="禁用" @click="handleEdit(scope.row, scope.$index)"></auth-button>
<auth-button type="text" label="激活" @click="handleEdit(scope.row, scope.$index)"></auth-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
></el-pagination>
<!-- <edit-dialog
:isVisible="editVisible"
:editForm="editForm"
@closeDialog="handleEditClose"
@confirmDialog="handleEditConfirm"
></edit-dialog>-->
</d2-container>
</template>
<script>
// import EditDialog from './editDialog'
import { UserList } from "@/api/sys.account";
import notice from "@/common/notice";
import { mapActions } from "vuex";
export default {
name: "FimsUserUsers",
components: {
// EditDialog
},
data() {
return {
// 新增/编辑弹窗
editVisible: false,
editForm: {
name: "",
stationCode: "",
stationName: "",
merchantName: "",
openType: ""
},
// 搜索
searchForm: {
name: "",
companyCode: "",
times: "",
postCode: "",
status: "",
stationCode: "",
postCode: ""
},
// 表格
tableLoading: false,
tableData: [],
tableColumns: [
{
label: "用户名",
prop: "loginName"
},
{
label: "角色",
prop: "roleName"
},
{
label: "注册时间",
prop: "registerTime"
},
{
label: "有效期",
prop: "validTime"
},
{
label: "状态",
prop: "status",
formatter: cellValue => {
return {
1: "正常",
2: "已过期",
3:'禁用'
}[cellValue.status];
}
},
{
label: "姓名",
prop: "userName"
},
{
label: "联系电话",
prop: "mobile"
},
{
label: "所属公司",
prop: "companyName"
},
{
label: "部门",
prop: "departName"
},
{
label: "职务",
prop: "postName"
},
{
label: "所属站点",
prop: "stationName"
}
],
page: {
// 页码
pageCount: 1,
pageSize: 10
},
/* -----------------------基础数据---------------------- */
baseData: {
// 所属站点
stations: [],
// 职务
posts: [],
// 部门
departs: [],
// 公司
companys: [],
//角色
roles: []
}
};
},
mounted() {
this.fetchData();
},
methods: {
...mapActions("d2admin/base", ["load"]),
// 加载业务所需所有数据
fetchData() {
this.loadBaseData(), this.loadUserList();
},
async loadBaseData() {
const { role, company, depart, station, post } = await this.load();
this.baseData.posts = post;
this.baseData.stations = station;
this.baseData.departs = depart;
this.baseData.companys = company;
this.baseData.roles = role;
Object.freeze(this.baseData);
},
/* 接口请求-start */
getParams() {
return {
...this.page,
...this.searchForm
};
},
loadUserList() {
this.tableLoading = true;
const params = this.getParams();
UserList(params)
.then(res => {
this.tableData = res;
this.tableLoading = false;
})
.catch(err => {
notice.errorTips(err);
this.tableLoading = false;
});
},
// 页码
handleSizeChange(value) {
this.page.pageSize = value;
// 调接口
this.loadUserList();
},
handleCurrentChange(value) {
this.page.pageCount = value;
// 调接口
this.loadUserList();
},
handleDelete(index, row) {
this.$confirm("确认删除?", "删除", {
comfirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
console.log(index);
console.log(row);
this.$message({
type: "success",
message: "删除成功"
});
})
.catch(err => {});
}
}
};
</script>
<style scoped>
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!