Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
SHR
/
tFIMS
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 69ed5484
authored
Sep 06, 2019
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加超级管理员权限生成逻辑
1 parent
52116f52
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
96 additions
and
37 deletions
src/common/constants.js
src/filters/index.js
src/filters/src/index.js
src/layout/header-aside/components/header-user/index.vue
src/layout/header-aside/components/personal-panel/index.vue
src/libs/util.js
src/libs/util.permision.js
src/plugin/d2admin/index.js
src/router/routes.js
src/store/modules/d2admin/modules/account.js
src/store/modules/d2admin/modules/auth.js
src/views/userManage/role/editDialog.vue
src/common/constants.js
View file @
69ed548
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Author: limin
* @Date: 2019-09-01 19:06:01
* @Date: 2019-09-01 19:06:01
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 2019-09-0
5 20:06:12
* @Last Modified time: 2019-09-0
6 12:22:40
*/
*/
import
{
LOGIN_URL
,
REG_URL
,
Role_LIST_URL
}
from
'@/api/sys.account'
import
{
LOGIN_URL
,
REG_URL
,
Role_LIST_URL
}
from
'@/api/sys.account'
...
@@ -47,3 +47,7 @@ export const LogExternals = [
...
@@ -47,3 +47,7 @@ export const LogExternals = [
* 登录来源
* 登录来源
*/
*/
export
const
LOGIN_TYPE
=
1
//1pc,2小程序
export
const
LOGIN_TYPE
=
1
//1pc,2小程序
/**
* 超级管理员类型
*/
export
const
SUPPER_ADMIN
=
1
//
\ No newline at end of file
\ No newline at end of file
src/filters/index.js
0 → 100644
View file @
69ed548
/*
* @Author: limin
* @Date: 2019-09-06 10:12:23
* @Last Modified by: limin
* @Last Modified time: 2019-09-06 13:23:25
*/
import
Vue
from
'vue'
import
*
as
filters
from
'./src'
Object
.
keys
(
filters
).
forEach
(
key
=>
{
Vue
.
filter
(
key
,
filters
[
key
])
})
src/filters/src/index.js
0 → 100644
View file @
69ed548
/*
* @Author: limin
* @Date: 2019-09-06 10:11:24
* @Last Modified by: limin
* @Last Modified time: 2019-09-06 13:30:14
*/
const
dateFormat
=
(
dateStr
,
time
)
=>
{
//得到特定的时间
var
date
=
new
Date
(
dateStr
);
var
year
=
date
.
getFullYear
();
//ES6语法填充:var month = (date.getMonth()+1).toString().padStart(2, '0');
var
month
=
date
.
getMonth
()
+
1
<
10
?
'0'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
var
day
=
date
.
getDate
()
<
10
?
'0'
+
date
.
getDate
()
:
date
.
getDate
();
var
hh
=
date
.
getHours
()
<
10
?
'0'
+
date
.
getHours
()
:
date
.
getHours
();
var
mm
=
date
.
getMinutes
()
<
10
?
'0'
+
date
.
getMinutes
()
:
date
.
getMinutes
();
var
ss
=
date
.
getSeconds
()
<
10
?
'0'
+
date
.
getSeconds
()
:
date
.
getSeconds
();
//return `${year}-${month}-${day}`;
if
(
time
&&
time
.
toLowerCase
()
===
'yyyy-mm-dd'
){
return
`
${
year
}
-
${
month
}
-
${
day
}
`
;
}
else
if
(
time
&&
time
.
toLowerCase
()
===
'hh:mm:ss'
){
return
`
${
hh
}
:
${
mm
}
:
${
ss
}
`
;
}
else
{
console
.
log
(
1
);
return
`
${
year
}
-
${
month
}
-
${
day
}
${
hh
}
:
${
mm
}
:
${
ss
}
`
;
}
}
export
{
dateFormat
}
src/layout/header-aside/components/header-user/index.vue
View file @
69ed548
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<
/el-dropdown-menu
>
<
/el-dropdown-menu
>
<
/el-dropdown>--
>
<
/el-dropdown>--
>
<
div
v
-
popover
:
popover
-
personal
class
=
"d2-mr personal-wrap"
>
<
div
v
-
popover
:
popover
-
personal
class
=
"d2-mr personal-wrap"
>
<
span
class
=
"btn-text"
>
{{
info
.
name
?
`${info.n
ame
}
`
:
'未登录'
}}
<
/span
>
<
span
class
=
"btn-text"
>
{{
info
.
userName
?
`${info.userN
ame
}
`
:
'未登录'
}}
<
/span
>
<
el
-
popover
ref
=
"popover-personal"
placement
=
"bottom-end"
trigger
=
"hover"
>
<
el
-
popover
ref
=
"popover-personal"
placement
=
"bottom-end"
trigger
=
"hover"
>
<
personal
-
panel
:
user
=
"info"
><
/personal-panel
>
<
personal
-
panel
:
user
=
"info"
><
/personal-panel
>
<
/el-popover
>
<
/el-popover
>
...
...
src/layout/header-aside/components/personal-panel/index.vue
View file @
69ed548
...
@@ -8,12 +8,12 @@
...
@@ -8,12 +8,12 @@
></el-avatar>
></el-avatar>
</div>
</div>
<div
class=
"name-role"
>
<div
class=
"name-role"
>
<span
class=
"sender"
>
{{
user
.
name
}}
-
{{
user
.
role
||
'超级管理员
'
}}
</span>
<span
class=
"sender"
>
{{
user
.
userName
}}
-
{{
user
.
roleType
||
'
'
}}
</span>
</div>
</div>
<div
class=
"registe-info"
>
<div
class=
"registe-info"
>
<span
class=
"registe-info"
>
<span
class=
"registe-info"
>
<li
class=
"fa fa-clock-o"
></li>
<li
class=
"fa fa-clock-o"
></li>
注册时间:
{{
user
.
registeInfo
||
'2019-08-08
'
}}
有效期:
{{
user
.
validTime
||
'未知
'
}}
</span>
</span>
</div>
</div>
</div>
</div>
...
@@ -51,15 +51,7 @@ import { Message, MessageBox } from 'element-ui'
...
@@ -51,15 +51,7 @@ import { Message, MessageBox } from 'element-ui'
export
default
{
export
default
{
name
:
'PersonalPanel'
,
name
:
'PersonalPanel'
,
props
:
{
props
:
{
user
:
{
user
:
Object
type
:
Object
,
default
:
{
name
:
'admin'
,
avatar
:
'@/assets/user.png'
,
role
:
'超级管理员'
,
registeInfo
:
'注册时间:2018-12-25 '
}
}
},
},
computed
:
{
computed
:
{
...
mapState
(
'd2admin/user'
,
[
'info'
])
...
mapState
(
'd2admin/user'
,
[
'info'
])
...
...
src/libs/util.js
View file @
69ed548
...
@@ -120,5 +120,17 @@ util.resetForm = function (formName) {
...
@@ -120,5 +120,17 @@ util.resetForm = function (formName) {
this
.
$refs
[
formName
]
&&
this
.
$refs
[
formName
].
resetFields
()
this
.
$refs
[
formName
]
&&
this
.
$refs
[
formName
].
resetFields
()
})
})
}
}
/**
* 扁平化 routes (@/router/routes)
*/
util
.
flatten
=
function
(
arr
)
{
return
arr
.
reduce
((
result
,
item
)
=>
{
item
.
authId
=
item
.
authId
||
item
.
meta
.
authId
item
.
parentId
=
item
.
parentId
||
item
.
meta
.
parentId
const
cloneItem
=
util
.
deepClone
(
item
)
delete
cloneItem
.
auth
return
result
.
concat
(
item
.
auth
?
util
.
flatten
([...
item
.
auth
,
cloneItem
])
:
item
);
},
[]);
}
export
default
util
export
default
util
src/libs/util.permision.js
View file @
69ed548
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 2019-09-0
4 00:48:28
* @Last Modified time: 2019-09-0
6 13:08:53
*/
*/
const
permision
=
{}
const
permision
=
{}
/**
/**
...
@@ -104,10 +104,10 @@ permision.packMenusBtns = function (resources) {
...
@@ -104,10 +104,10 @@ permision.packMenusBtns = function (resources) {
}
}
if
(
__oMenu
.
parentId
===
'0'
)
{
// 取出1级菜单
if
(
__oMenu
.
parentId
===
'0'
)
{
// 取出1级菜单
__aParent
.
push
(
__oMenu
)
__aParent
.
push
(
__oMenu
)
__aAll
.
push
(
__oMenu
)
//
__aAll.push(__oMenu)
if
(
__oMenu
.
auth
)
{
//
if (__oMenu.auth) {
__aAll
=
[...
__aAll
,
...
__oMenu
.
auth
]
//
__aAll = [...__aAll, ...__oMenu.auth]
}
//
}
}
else
{
// 取出子菜单
}
else
{
// 取出子菜单
__aSub
.
push
(
__oMenu
)
__aSub
.
push
(
__oMenu
)
}
}
...
@@ -117,10 +117,10 @@ permision.packMenusBtns = function (resources) {
...
@@ -117,10 +117,10 @@ permision.packMenusBtns = function (resources) {
*/
*/
let
__parent
=
null
let
__parent
=
null
__aSub
.
forEach
(
obj
=>
{
__aSub
.
forEach
(
obj
=>
{
__aAll
.
push
(
obj
)
//
__aAll.push(obj)
if
(
obj
.
auth
)
{
//
if (obj.auth) {
__aAll
=
[...
__aAll
,
...
obj
.
auth
]
//
__aAll = [...__aAll, ...obj.auth]
}
//
}
__parent
=
__aParent
.
find
(
menu
=>
menu
.
authId
===
obj
.
parentId
)
__parent
=
__aParent
.
find
(
menu
=>
menu
.
authId
===
obj
.
parentId
)
if
(
__parent
.
children
)
{
if
(
__parent
.
children
)
{
__parent
.
children
.
push
(
obj
)
__parent
.
children
.
push
(
obj
)
...
...
src/plugin/d2admin/index.js
View file @
69ed548
...
@@ -10,6 +10,9 @@ import '@/assets/svg-icons'
...
@@ -10,6 +10,9 @@ import '@/assets/svg-icons'
// 指令
// 指令
import
'@/directives'
import
'@/directives'
// 过滤器
import
'@/filters'
// 功能插件
// 功能插件
import
pluginError
from
'@/plugin/error'
import
pluginError
from
'@/plugin/error'
import
pluginLog
from
'@/plugin/log'
import
pluginLog
from
'@/plugin/log'
...
...
src/router/routes.js
View file @
69ed548
...
@@ -380,6 +380,10 @@ export const errorPage = {
...
@@ -380,6 +380,10 @@ export const errorPage = {
// 导出需要显示菜单的
// 导出需要显示菜单的
export
const
frameInRoutes
=
frameIn
export
const
frameInRoutes
=
frameIn
export
const
localRoutes
=
{
...
resources
,
[
home
.
meta
.
authId
]:
home
}
// 重新组织后导出
// 重新组织后导出
export
default
[
export
default
[
// ...resources,
// ...resources,
...
...
src/store/modules/d2admin/modules/account.js
View file @
69ed548
import
util
from
'@/libs/util.js'
import
util
from
'@/libs/util.js'
import
router
from
'@/router
'
import
{
cloneDeep
}
from
'lodash
'
import
{
AccountLogin
}
from
'@api/sys.account'
import
{
AccountLogin
}
from
'@api/sys.account'
import
{
SUPPER_ADMIN
}
from
'@/common/constants'
import
{
resources
as
sources
,
home
}
from
'@/router/routes'
export
default
{
export
default
{
namespaced
:
true
,
namespaced
:
true
,
actions
:
{
actions
:
{
...
@@ -21,21 +23,20 @@ export default {
...
@@ -21,21 +23,20 @@ export default {
AccountLogin
({
AccountLogin
({
username
,
username
,
password
password
})
}).
then
(
async
(
data
=
{})
=>
{
.
then
(
async
res
=>
{
// 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 设置 cookie 一定要存 uuid 和 token 两个 cookie
// 整个系统依赖这两个数据进行校验和存储
// 整个系统依赖这两个数据进行校验和存储
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
// uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
// token 代表用户当前登录状态 建议在网络请求中携带 token
// token 代表用户当前登录状态 建议在网络请求中携带 token
// 如有必要 token 需要定时更新,默认保存一天
// 如有必要 token 需要定时更新,默认保存一天
util
.
cookies
.
set
(
'uuid'
,
res
.
uuid
)
util
.
cookies
.
set
(
'uuid'
,
data
.
loginName
)
// util.cookies.set('token', 'token')
const
authes
=
data
.
roleType
===
SUPPER_ADMIN
?
const
{
user
,
authes
}
=
res
util
.
flatten
(
Object
.
values
({...
sources
,
[
home
.
meta
.
authId
]:
home
}))
.
map
(
obj
=>
({
authId
:
obj
.
authId
,
parentId
:
obj
.
parentId
}))
:
cloneDeep
(
data
.
authes
)
&&
delete
data
.
authes
await
dispatch
(
'd2admin/auth/set'
,
authes
,
{
root
:
true
})
await
dispatch
(
'd2admin/auth/set'
,
authes
,
{
root
:
true
})
// 设置 vuex 用户信息
// 设置 vuex 用户信息
await
dispatch
(
'd2admin/user/set'
,
{
await
dispatch
(
'd2admin/user/set'
,
data
,
{
root
:
true
})
name
:
user
.
name
},
{
root
:
true
})
// 强制初始化基础数据
// 强制初始化基础数据
dispatch
(
'd2admin/base/init'
,
null
,
{
root
:
true
})
dispatch
(
'd2admin/base/init'
,
null
,
{
root
:
true
})
// 用户登录后从持久化数据加载一系列的设置
// 用户登录后从持久化数据加载一系列的设置
...
...
src/store/modules/d2admin/modules/auth.js
View file @
69ed548
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
* @Author: limin
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified by: limin
* @Last Modified time: 2019-09-0
4 10:44:27
* @Last Modified time: 2019-09-0
6 13:12:51
*/
*/
import
util
from
'@/libs/util.js'
import
util
from
'@/libs/util.js'
import
router
from
'@/router'
import
router
from
'@/router'
import
{
resources
as
sourc
es
,
home
,
frameInRoutes
,
sys
}
from
'@/router/routes'
import
{
localRout
es
,
home
,
frameInRoutes
,
sys
}
from
'@/router/routes'
export
default
{
export
default
{
namespaced
:
true
,
namespaced
:
true
,
state
:
{
state
:
{
...
@@ -118,12 +118,12 @@ export default {
...
@@ -118,12 +118,12 @@ export default {
// 获取权限资源点
// 获取权限资源点
const
__source
=
await
dispatch
(
'load'
)
const
__source
=
await
dispatch
(
'load'
)
// 过滤资源点 并动态添加到路由
// 过滤资源点 并动态添加到路由
const
{
route
,
btn
}
=
util
.
permision
.
packRoutesBtns
(
{
...
sources
,
[
home
.
meta
.
authId
]:
home
}
,
__source
)
const
{
route
,
btn
}
=
util
.
permision
.
packRoutesBtns
(
localRoutes
,
__source
)
frameInRoutes
[
0
].
children
=
[
home
,
...
route
,
...
sys
]
frameInRoutes
[
0
].
children
=
[
home
,
...
route
,
...
sys
]
router
.
addRoutes
(
frameInRoutes
)
router
.
addRoutes
(
frameInRoutes
)
state
.
btns
=
btn
state
.
btns
=
btn
await
commit
(
'd2admin/page/init'
,
frameInRoutes
,
{
root
:
true
})
await
commit
(
'd2admin/page/init'
,
frameInRoutes
,
{
root
:
true
})
const
__aMenus
=
[
util
.
permision
.
format2Menu
(
home
),
...
util
.
permision
.
packAsideMenus
(
sources
,
__source
)]
const
__aMenus
=
util
.
permision
.
packAsideMenus
(
localRoutes
,
__source
)
// 过滤左侧菜单栏
// 过滤左侧菜单栏
await
commit
(
'd2admin/menu/asideSet'
,
__aMenus
,
{
root
:
true
})
await
commit
(
'd2admin/menu/asideSet'
,
__aMenus
,
{
root
:
true
})
// 初始化页面搜索
// 初始化页面搜索
...
...
src/views/userManage/role/editDialog.vue
View file @
69ed548
...
@@ -40,7 +40,7 @@ import { Reg } from '@/api/sys.account'
...
@@ -40,7 +40,7 @@ import { Reg } from '@/api/sys.account'
import
{
mapActions
}
from
'vuex'
import
{
mapActions
}
from
'vuex'
import
notice
from
'@/common/notice'
import
notice
from
'@/common/notice'
import
RoleTree
from
'./roleTree'
import
RoleTree
from
'./roleTree'
import
{
resources
as
sources
,
home
}
from
'@/router/routes'
import
{
localRoutes
}
from
'@/router/routes'
import
util
from
'@/libs/util.js'
import
util
from
'@/libs/util.js'
export
default
{
export
default
{
name
:
'editDialog'
,
name
:
'editDialog'
,
...
@@ -74,7 +74,10 @@ export default {
...
@@ -74,7 +74,10 @@ export default {
return
this
.
isVisible
return
this
.
isVisible
},
},
resources
()
{
resources
()
{
return
util
.
permision
.
packMenusBtns
(
util
.
deepClone
(
Object
.
values
({
...
sources
,
[
home
.
meta
.
id
]:
home
})))
const
clone
=
util
.
deepClone
(
Object
.
values
(
localRoutes
))
const
{
menus
}
=
util
.
permision
.
packMenusBtns
(
clone
)
const
all
=
util
.
flatten
(
clone
)
return
{
menus
,
all
}
}
}
},
},
data
()
{
data
()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment