Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
5af5aa7b
Commit
5af5aa7b
authored
May 10, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
99cd7b56
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
326 additions
and
25 deletions
+326
-25
iview-admin/src/api/meta.js
+26
-7
iview-admin/src/config/index.js
+1
-0
iview-admin/src/libs/axios.js
+5
-4
iview-admin/src/router/routers.js
+10
-1
iview-admin/src/store/module/metainfo/appinfo.js
+1
-1
iview-admin/src/store/module/metainfo/roleinfo.js
+2
-1
iview-admin/src/view/components/tables/forms/childs/checkgroups.vue
+25
-11
iview-admin/src/view/roleinfo/roleauth_page.vue
+252
-0
iview-admin/src/view/roleinfo/roleinfo_page.vue
+4
-0
No files found.
iview-admin/src/api/meta.js
View file @
5af5aa7b
import
axios
from
'@/libs/api.request'
import
config
from
'@/config'
export
const
refQuery
=
(
url
,
q
)
=>
{
console
.
log
(
">>>>>>>>>>>."
,
url
,
q
)
return
axios
.
request
({
...
...
@@ -15,11 +15,30 @@ export const ossConfig = (url,q) => {
data
:
q
})
}
export
const
getApp
=
()
=>
{
let
appkey
=
config
.
fromappkey
?
config
.
fromappkey
:
config
.
appkey
return
axios
.
request
({
url
:
"/web/common/appCtl/getApp"
,
method
:
'post'
,
data
:{
appkey
:
appkey
}
})
}
export
const
saveAuths
=
(
auths
)
=>
{
return
axios
.
request
({
url
:
"/web/auth/authCtl/saveAuths"
,
method
:
'post'
,
data
:{
auths
:
auths
}
})
}
export
const
findAuthsByRoles
=
(
roleids
)
=>
{
return
axios
.
request
({
url
:
"/web/auth/authCtl/findAuthsByRoles"
,
method
:
'post'
,
data
:{
roleids
:
roleids
}
})
}
// export const uploadImg = formData => {
// return axios.request({
// url: 'image/upload',
// data: formData
// })
// }
iview-admin/src/config/index.js
View file @
5af5aa7b
...
...
@@ -4,6 +4,7 @@ export default {
*/
title
:
'智慧中台 '
,
appkey
:
'cbb91171-3c68-49f9-b27f-fa38daa376ee'
,
companykey
:
'41fabc4fc3a049f9823eee96cec7a94d'
,
/**
* @description token在Cookie中存储的天数,默认1天
*/
...
...
iview-admin/src/libs/axios.js
View file @
5af5aa7b
...
...
@@ -29,8 +29,8 @@ class HttpRequest {
companykey
=
params
.
get
(
"companykey"
)
regrole
=
params
.
get
(
"regrole"
)
this
.
confapp
.
regrole
=
regrole
this
.
confapp
.
companykey
=
companykey
this
.
confapp
.
fromappkey
=
appkey
;
//为了区分当前切换应用上下文后,进入的应用非平台应用
this
.
confapp
.
fromcompanykey
=
companykey
?
companykey
:
this
.
confapp
.
companykey
//来源公司key,如果URL里没有,那么就取平台应用公司
this
.
confapp
.
fromappkey
=
appkey
?
appkey
:
this
.
confapp
.
appkey
;
//来源应用,如果URL里没有,那么就取平台应用key
}
catch
(
e
){
console
.
log
(
e
)
}
...
...
@@ -38,8 +38,9 @@ class HttpRequest {
baseURL
:
this
.
baseUrl
,
headers
:
{
Authorization
:
"Bearer "
+
getToken
(),
XAPPKEY
:
appkey
?
appkey
:
this
.
confapp
.
appkey
,
XCOMPANYKEY
:
companykey
,
XAPPKEY
:
this
.
confapp
.
appkey
,
//当前应用
XFROMAPPKEY
:
this
.
confapp
.
fromappkey
,
//来源应用
XFROMCOMPANYKEY
:
this
.
confapp
.
fromcompanykey
,
//来源公司
XREGROLE
:
regrole
,
//专用于注册时,区分是否是非租户注册
XBIZPATH
:
this
.
confapp
.
bizpath
}
...
...
iview-admin/src/router/routers.js
View file @
5af5aa7b
...
...
@@ -140,9 +140,18 @@ export default [
name
:
'role_info_page'
,
meta
:
{
icon
:
'md-clipboard'
,
title
:
'角色
信息
'
title
:
'角色
授权
'
},
component
:
()
=>
import
(
'@/view/roleinfo/roleinfo_page.vue'
)
},
{
path
:
'role_auth'
,
name
:
'role_auth'
,
meta
:
{
icon
:
'md-clipboard'
,
title
:
'授权操作'
},
component
:
()
=>
import
(
'@/view/roleinfo/roleauth_page.vue'
)
}
]
},
...
...
iview-admin/src/store/module/metainfo/appinfo.js
View file @
5af5aa7b
...
...
@@ -6,7 +6,7 @@ export default {
{
title
:
'名称'
,
key
:
'name'
,
sortable
:
true
,
insearch
:
true
},
//slot--自定义列 insearch--是否快速查询
{
title
:
'域名'
,
key
:
'domainName'
,
sortable
:
true
,
insearch
:
true
},
//slot--自定义列 insearch--是否快速查询
{
title
:
'服务'
,
key
:
'backend'
,
sortable
:
true
,
insearch
:
true
},
//slot--自定义列 insearch--是否快速查询
{
title
:
'创建时间'
,
key
:
'created_at'
,
slot
:
'created_at'
},
{
title
:
'创建时间'
,
key
:
'created_at'
,
slot
:
'created_at'
,
insearch
:
true
},
{
title
:
'操作'
,
key
:
'handle'
,
...
...
iview-admin/src/store/module/metainfo/roleinfo.js
View file @
5af5aa7b
...
...
@@ -49,7 +49,8 @@ export default {
// { "icon": "ios-cloud-download-outline", "title": "下载", "type": "text", "key": "export", "isOnGrid": true },
],
"edit"
:
[
{
"icon"
:
"ios-create-outline"
,
"title"
:
"修改"
,
"type"
:
"text"
,
"key"
:
"edit"
,
"isInRow"
:
true
}
{
"icon"
:
"ios-create-outline"
,
"title"
:
"修改"
,
"type"
:
"text"
,
"key"
:
"edit"
,
"isInRow"
:
true
},
{
"icon"
:
"ios-create-outline"
,
"title"
:
"授权"
,
"type"
:
"text"
,
"key"
:
"auth"
,
"isInRow"
:
true
}
],
"delete"
:
[
{
"icon"
:
"ios-trash-outline"
,
"title"
:
"删除"
,
"type"
:
"text"
,
"key"
:
"delete"
,
"isInRow"
:
true
},
...
...
iview-admin/src/view/components/tables/forms/childs/checkgroups.vue
View file @
5af5aa7b
<
template
>
<CheckboxGroup
v-model=
"sels"
@
on-change=
"onchange"
>
<Checkbox
v-for=
"item in datasource"
:label=
"item.value"
:key=
"item.value"
:Border=
"isborder"
>
{{
item
.
label
}}
</Checkbox>
<Checkbox
v-for=
"item in datasource"
:label=
"item.value"
:key=
"item.value"
:Border=
"isborder"
>
{{
item
.
label
}}
</Checkbox>
</CheckboxGroup>
</
template
>
<
script
>
import
{
refQuery
}
from
"@/api/meta"
;
export
default
{
name
:
"
c
heckgroups"
,
name
:
"
C
heckgroups"
,
components
:
{},
model
:
{
prop
:
"value"
,
event
:
"change"
},
props
:[
"value"
,
"dicName"
,
"refModel"
,
"labelField"
,
"valueField"
,
"refwhere"
,
"isborder"
],
props
:
[
"value"
,
"dicName"
,
"refModel"
,
"labelField"
,
"valueField"
,
"refwhere"
,
"isborder"
,
"baseData"
],
data
()
{
return
{
sels
:
this
.
value
?
this
.
value
:
[],
datasource
:
[]
sels
:
this
.
value
?
this
.
value
:
[],
datasource
:
this
.
baseData
?
this
.
baseData
:
[]
};
},
watch
:
{
...
...
@@ -29,7 +43,7 @@ export default {
this
.
$emit
(
"change"
,
this
.
sels
);
},
initDataSource
(
slike
)
{
if
(
this
.
dicName
&&
this
.
dicName
!=
""
)
{
if
(
this
.
dicName
&&
this
.
dicName
!=
""
)
{
let
objdic
=
this
.
$store
.
getters
.
dict_info
[
this
.
dicName
];
console
.
log
(
objdic
);
Object
.
keys
(
objdic
).
forEach
(
k
=>
{
...
...
@@ -47,18 +61,18 @@ export default {
refQuery
(
url
,
query
).
then
(
r
=>
{
if
(
r
.
data
)
{
this
.
datasource
=
r
.
data
;
console
.
log
(
">>>>>>>>>>>>>>>>>>>>"
,
r
.
data
)
console
.
log
(
">>>>>>>>>>>>>>>>>>>>"
,
r
.
data
);
}
});
}
}
},
created
()
{
this
.
initDataSource
()
if
(
!
this
.
baseData
)
{
this
.
initDataSource
();
}
},
mounted
()
{
}
mounted
()
{}
};
</
script
>
<
style
>
...
...
iview-admin/src/view/roleinfo/roleauth_page.vue
0 → 100644
View file @
5af5aa7b
<
template
>
<div>
<Card>
<Tree
:data=
"treedata"
:render=
"renderContent"
class=
"ptree"
></Tree>
</Card>
</div>
</
template
>
<
script
>
import
{
getApp
,
saveAuths
,
findAuthsByRoles
}
from
"@/api/meta"
;
import
Checks
from
"@/view/components/tables/forms/childs/checkgroups.vue"
;
import
config
from
"@/config"
;
export
default
{
name
:
"roleauth_page"
,
data
()
{
return
{
roleid
:
-
1
,
//
rolecode
:
""
,
roleauths
:
null
,
treedata
:
[],
buttonProps
:
{
type
:
"default"
,
size
:
"small"
}
};
},
components
:
{
Checks
},
computed
:
{
authdic
()
{
let
dic
=
{};
this
.
roleauths
.
forEach
(
item
=>
{
dic
[
item
.
bizcode
]
=
item
.
authstrs
.
split
(
","
);
});
return
dic
;
}
},
mounted
()
{
this
.
roleid
=
this
.
$route
.
query
.
roleid
;
this
.
rolecode
=
this
.
$route
.
query
.
rolecode
;
//获取当前应用的资源清单
this
.
initTree
();
},
methods
:
{
initTree
()
{
getApp
().
then
(
res
=>
{
let
rtn
=
res
.
data
;
if
(
rtn
.
status
==
0
)
{
console
.
log
(
rtn
.
data
.
functionJSON
);
let
tmptreedata
=
JSON
.
parse
(
rtn
.
data
.
functionJSON
);
this
.
treedata
=
tmptreedata
;
//
//按照当前角色,去获取当前应用的功能权限,对返回的数据进行处理
//赋予权限数据
findAuthsByRoles
([
this
.
roleid
]).
then
(
res
=>
{
let
rtn
=
res
.
data
if
(
rtn
.
status
==
0
){
this
.
roleauths
=
rtn
.
data
this
.
setAuthData
(
this
.
treedata
);
}
else
{
console
.
log
(
"fetch auths fails....."
)
}
})
}
});
},
setAuthData
(
datas
)
{
datas
.
forEach
(
td
=>
{
if
(
td
.
children
)
{
this
.
setAuthData
(
td
.
children
);
}
else
{
if
(
td
.
sels
){
console
.
log
(
this
.
authdic
)
td
.
sels
=
this
.
authdic
[
td
.
name
];
}
}
});
},
makeauths
(
datas
,
auths
)
{
datas
.
forEach
(
item
=>
{
if
(
item
.
children
)
{
this
.
makeauths
(
item
.
children
,
auths
);
}
else
{
if
(
item
.
sels
)
{
let
oneauth
=
{
role_id
:
this
.
roleid
,
rolecode
:
this
.
rolecode
,
bizcode
:
item
.
name
,
codepath
:
item
.
codepath
,
authstrs
:
item
.
sels
.
join
(
","
)
};
auths
.
push
(
oneauth
);
}
}
});
},
saveAuths
()
{
let
auths
=
[];
this
.
makeauths
(
this
.
treedata
,
auths
);
saveAuths
(
auths
).
then
(
res
=>
{
let
rtn
=
res
.
data
;
if
(
rtn
.
status
==
0
)
{
this
.
roleauths
=
rtn
.
data
;
this
.
$Message
.
success
(
"当前操作成功完成"
)
}
else
{
this
.
$Message
.
success
(
"当前操作未完成,请稍后重试或联系管理员"
)
}
});
},
refreshFunc
()
{},
renderContent
(
h
,
{
root
,
node
,
data
})
{
// console.log(node)
const
parentKey
=
root
.
find
(
el
=>
el
===
node
).
parent
;
console
.
log
(
parentKey
);
return
h
(
"span"
,
{
style
:
{
display
:
"inline-block"
,
width
:
"100%"
,
cursor
:
"pointer"
},
on
:
{
click
:
$event
=>
{
$
(
"span"
,
".ptree"
).
removeClass
(
"spansel"
);
$
(
$event
.
target
).
addClass
(
"spansel"
);
}
}
},
[
h
(
"span"
,
[
h
(
"Icon"
,
{
props
:
{
type
:
!
data
.
auths
?
"ios-folder-outline"
:
"ios-paper-outline"
},
style
:
{
marginRight
:
"8px"
}
}),
h
(
"span"
,
data
.
title
)
]),
h
(
"span"
,
{
style
:
{
display
:
"inline-block"
,
float
:
"right"
,
marginRight
:
"100px"
}
},
[
data
.
auths
?
h
(
"Checkbox"
,
{
on
:
{
"on-change"
:
b
=>
{
if
(
b
)
{
data
.
sels
=
data
.
auths
;
}
else
{
data
.
sels
=
[];
}
}
},
style
:
{
display
:
"inline-block"
,
float
:
"left"
,
marginRight
:
"10px"
,
marginTop
:
"3px"
}
},
[
h
(
"span"
,
[
"all"
])]
)
:
data
.
name
==
"root"
?
h
(
"span"
,
[
h
(
"Button"
,
{
props
:
{
type
:
"text"
},
on
:
{
click
:
()
=>
{
this
.
saveAuths
();
}
}
},
[
"保存"
]
),
h
(
"Button"
,
{
props
:
{
type
:
"text"
},
on
:
{
click
:
()
=>
{
this
.
refreshFunc
();
}
}
},
[
"刷新"
]
)
])
:
""
,
data
.
auths
?
h
(
"CheckboxGroup"
,
{
props
:
{
value
:
data
.
sels
},
on
:
{
"on-change"
:
v
=>
{
data
.
sels
=
v
;
console
.
log
(
v
);
}
}
},
[
data
.
auths
.
map
(
function
(
it
)
{
return
h
(
"Checkbox"
,
{
props
:
{
label
:
it
}
},
[
h
(
"span"
,
[
it
])]
);
})
]
)
:
""
]
)
]
);
}
}
};
</
script
>
<
style
>
.ptree
span
:hover
{
background-color
:
lightgray
;
}
.spansel
{
background-color
:
lightgray
;
}
</
style
>
iview-admin/src/view/roleinfo/roleinfo_page.vue
View file @
5af5aa7b
...
...
@@ -6,6 +6,7 @@
metaName=
"role_info"
packageName=
"auth"
isMulti
@
onexec=
"onexec"
></BizTable>
</div>
</
template
>
...
...
@@ -20,6 +21,9 @@ export default {
BizTable
},
methods
:
{
onexec
(
k
,
row
)
{
this
.
$router
.
push
({
name
:
"role_auth"
,
query
:{
roleid
:
row
.
id
,
rolecode
:
row
.
code
}})
},
// onnew() {
// this.$refs.bt.setFormCtlVisable("userName", true);
// },
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment