Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
project
jinfa-admin
Commits
78c7a4d8
Commit
78c7a4d8
authored
Oct 27, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:会员角色权限
parent
4ba1438a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
95 deletions
+74
-95
proxy.ts
config/proxy.ts
+1
-1
ruleSettingRoutes.ts
config/routes/ruleSettingRoutes.ts
+10
-0
app.tsx
src/app.tsx
+0
-2
index.ts
src/constants/index.ts
+2
-2
global.d.ts
src/global/config/global.d.ts
+1
-1
useTreeTabs.ts
src/hooks/useTreeTabs.ts
+7
-3
detail.tsx
src/pages/ruleSettingManage/memberAuthManage/detail.tsx
+31
-33
index.tsx
src/pages/ruleSettingManage/memberAuthManage/index.tsx
+22
-53
No files found.
config/proxy.ts
View file @
78c7a4d8
export
default
{
'/api'
:
{
'target'
:
'http://10.0.0.25:8100/'
,
'target'
:
process
.
env
.
BACK_GATEWAY
||
'http://10.0.0.25:8100/'
,
'changeOrigin'
:
true
,
'pathRewrite'
:
{
'^/api'
:
''
},
}
...
...
config/routes/ruleSettingRoutes.ts
View file @
78c7a4d8
...
...
@@ -54,6 +54,7 @@ const router = {
name
:
'memberAuthManage'
,
component
:
'@/pages/ruleSettingManage/memberAuthManage'
,
},
// 设置会员角色
{
path
:
'/ruleSettingManager/memberAuthManage/detail'
,
name
:
'memberAuthManageDetail'
,
...
...
@@ -61,6 +62,14 @@ const router = {
hideInMenu
:
true
,
hidePageHeader
:
true
},
// 查看会员角色
{
path
:
'/ruleSettingManager/memberAuthManage/preview'
,
name
:
'memberAuthManageDetail'
,
component
:
'@/pages/ruleSettingManage/memberAuthManage/detail'
,
hideInMenu
:
true
,
hidePageHeader
:
true
}
]
}
export
default
router
\ No newline at end of file
src/app.tsx
View file @
78c7a4d8
...
...
@@ -84,8 +84,6 @@ export function render(oldRender:Function) {
* @param {*} { routes, matchedRoutes, location, action }
*/
export
function
onRouteChange
({
routes
,
matchedRoutes
,
location
,
action
})
{
console
.
log
(
'onRouteChange'
)
if
(
isDev
)
{
console
.
log
(
'dev'
)
return
;
...
...
src/constants/index.ts
View file @
78c7a4d8
...
...
@@ -104,8 +104,8 @@ export enum LAYOUT_TYPE {
}
// 本地环境跳过权限校验
//
export const isDev = process.env.NODE_ENV === "development"
export
const
isDev
=
tru
e
export
const
isDev
=
process
.
env
.
NODE_ENV
===
"development"
// export const isDev = fals
e
export
const
STATUS_ENUM
=
[
{
...
...
src/global/config/global.d.ts
View file @
78c7a4d8
...
...
@@ -49,7 +49,7 @@ export interface ShopInfo {
type
:
number
;
environment
:
number
;
logoUrl
:
string
;
describe
?:
any
;
describe
:
string
;
state
:
number
;
url
:
string
;
}
...
...
src/hooks/useTreeTabs.ts
View file @
78c7a4d8
...
...
@@ -24,11 +24,13 @@ export interface useTreeTabOptions {
// 右侧表单的实例操作方法
formActions
?:
ISchemaFormActions
// 删除菜单时调用的API
deleteMenu
?:
any
deleteMenu
?:
any
,
menuDataKey
?:
string
}
export
const
useTreeTabs
=
(
options
:
useTreeTabOptions
=
{})
=>
{
const
{
selectCallback
,
fetchMenuData
,
fetchItemDetailData
,
resetDetail
,
treeActions
,
formActions
,
extendsToolsRender
,
deleteMenu
}
=
options
const
{
selectCallback
,
fetchMenuData
,
fetchItemDetailData
,
resetDetail
,
treeActions
,
formActions
,
extendsToolsRender
,
deleteMenu
,
menuDataKey
}
=
options
const
[
treeExtraMaps
,
{
set
,
get
}
]
=
useMap
<
any
,
any
>
()
const
[
treeData
,
setTreeData
]
=
useState
<
any
[]
>
([])
const
[
treeStatus
,
setTreeStatus
]
=
useState
<
FormState
>
(
FormState
.
FREE
)
...
...
@@ -42,7 +44,7 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
const
resetMenu
=
async
()
=>
{
if
(
fetchMenuData
)
{
const
res
=
await
fetchMenuData
()
setTreeData
(
res
.
data
||
[])
setTreeData
(
menuDataKey
?
res
.
data
[
menuDataKey
]
:
res
.
data
||
[])
}
}
...
...
@@ -137,6 +139,8 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
...
extendsToolsRender
}
return
{
handleSelect
,
treeStatus
,
...
...
src/pages/ruleSettingManage/memberAuthManage/detail.tsx
View file @
78c7a4d8
...
...
@@ -11,7 +11,7 @@ import { MEMBER_ROLE_MAPS, MEMBER_TYPE_MAPS } from '@/constants';
import
{
history
}
from
'umi'
const
fetchMenuData
=
async
()
=>
{
const
res
=
await
PublicApi
.
getMemberRoleAuthTree
()
const
res
=
await
PublicApi
.
getMember
Platform
RoleAuthTree
()
return
res
}
...
...
@@ -24,10 +24,25 @@ const SetMemberAuth: React.FC<{}> = () => {
}
=
usePageStatus
()
const
getMenuSelectData
=
async
()
=>
{
const
res
=
await
PublicApi
.
getMemberRoleAuthTreeCheck
({
memberRoleId
:
id
})
const
res
=
await
PublicApi
.
getMemberPlatformRoleAuthTreeCheck
({
roleId
:
id
})
return
{
data
:
{
ids
:
res
.
data
.
checkIds
}
}
}
// 编辑和预览模式下需回显数据
const
fetchRoleDetail
=
async
()
=>
{
// 10秒缓存
const
res
=
await
PublicApi
.
getMemberPlatformRoleAuthTree
({
roleId
:
id
},
{
useCache
:
true
,
ttl
:
10
*
1000
})
return
res
}
const
fetchItemDetailData
=
async
({
id
:
menuId
})
=>
{
return
await
PublicApi
.
getMemberPlatformRoleAuthButton
({
roleId
:
id
,
menuId
})
}
const
{
treeData
,
handleSelect
,
...
...
@@ -36,26 +51,20 @@ const SetMemberAuth: React.FC<{}> = () => {
setIsEditForm
,
isEditForm
}
=
useTreeTabs
({
fetchMenuData
,
fetchItemDetailData
:
PublicApi
.
getMemberRoleAuthButton
fetchMenuData
:
fetchRoleDetail
,
menuDataKey
:
'auth'
,
fetchItemDetailData
})
const
actionRef
=
useRef
<
any
>
({})
const
formInitValue
=
nodeRecord
?
getTreeMaps
(
nodeRecord
.
key
)
:
null
const
[
formValue
,
setFormValue
]
=
useState
<
any
>
(
null
)
// 编辑和预览模式下需回显数据
const
fetchRoleDetail
=
async
(
id
)
=>
{
// 10秒缓存
const
res
=
await
PublicApi
.
getMemberRoleGet
({
memberRoleId
:
id
},
{
useCache
:
true
,
ttl
:
10
*
1000
})
return
res
}
// 储存的按钮数据
const
[
buttonInfos
,
setButtonInfos
]
=
useState
<
any
>
([])
useEffect
(()
=>
{
if
(
!
id
)
return
;
fetchRoleDetail
(
id
).
then
(
res
=>
{
fetchRoleDetail
().
then
(
res
=>
{
const
{
data
}
=
res
setFormValue
(
data
)
})
...
...
@@ -63,18 +72,8 @@ const SetMemberAuth: React.FC<{}> = () => {
useEffect
(()
=>
{
if
(
formInitValue
)
{
// 显示右侧checkbox
setButtonInfos
(
formInitValue
.
buttons
||
[])
// 回显右侧checkbox的值
if
(
actionRef
.
current
.
setSelected
)
{
PublicApi
.
getMemberRoleAuthButtonCheck
({
memberRoleId
:
id
,
menuId
:
formInitValue
.
id
}).
then
(
res
=>
{
const
{
data
}
=
res
actionRef
.
current
.
setSelected
(
data
.
checkIds
)
})
}
actionRef
.
current
.
setSelected
(
formInitValue
.
checkIds
)
}
},
[
getTreeMaps
])
...
...
@@ -84,17 +83,16 @@ const SetMemberAuth: React.FC<{}> = () => {
// 右侧有编辑过,则需要调按钮提交接口
await
PublicApi
.
postMember
Role
Update
({
await
PublicApi
.
postMember
PlatformRoleAuth
Update
({
menuIds
:
menuIds
,
memberRoleId
:
id
,
roleName
:
''
roleId
:
id
,
},
{
ctlType
:
isEditForm
?
'none'
:
'message'
})
if
(
isEditForm
)
{
await
PublicApi
.
postMember
RoleButtonUpsert
({
await
PublicApi
.
postMember
PlatformRoleButtonUpdate
({
buttonIds
:
buttonIds
,
memberR
oleId
:
id
,
r
oleId
:
id
,
menuId
:
nodeRecord
.
id
})
}
...
...
@@ -111,14 +109,14 @@ const SetMemberAuth: React.FC<{}> = () => {
<
div
>
<
Row
align=
'middle'
>
<
Col
style=
{
{
marginRight
:
24
}
}
><
ArrowLeftOutlined
onClick=
{
()
=>
history
.
goBack
()
}
/></
Col
>
<
Col
style=
{
{
marginRight
:
24
}
}
className=
{
selfStyle
.
titleAvator
}
>
{
MEMBER_ROLE_MAPS
[
formValue
.
roleType
]
[
0
]
}
</
Col
>
<
div
className=
{
selfStyle
.
fontBold18
}
>
{
MEMBER_ROLE_MAPS
[
formValue
.
roleType
]
}
</
div
>
<
Col
style=
{
{
marginRight
:
24
}
}
className=
{
selfStyle
.
titleAvator
}
>
{
formValue
.
roleTypeName
[
0
]
}
</
Col
>
<
div
className=
{
selfStyle
.
fontBold18
}
>
{
formValue
.
roleTypeName
}
</
div
>
</
Row
>
</
div
>
<
div
>
<
Row
style=
{
{
marginTop
:
24
,
fontSize
:
12
}
}
>
<
Col
span=
{
10
}
offset=
{
2
}
>
会员类型:
{
MEMBER_TYPE_MAPS
[
formValue
.
memberType
]
}
</
Col
>
<
Col
>
会员角色:
{
formValue
.
n
ame
}
</
Col
>
<
Col
span=
{
10
}
offset=
{
2
}
>
会员类型:
{
formValue
.
memberTypeName
}
</
Col
>
<
Col
>
会员角色:
{
formValue
.
roleN
ame
}
</
Col
>
</
Row
>
</
div
>
</
div
>
...
...
@@ -137,7 +135,7 @@ const SetMemberAuth: React.FC<{}> = () => {
<
Col
span=
{
17
}
className=
{
selfStyle
[
'menu-role-tree'
]
}
>
<
TabTree
title=
'菜单列表'
fetchData=
{
params
=>
fetch
MenuData
()
}
fetchData=
{
params
=>
fetch
RoleDetail
()
}
getMenuSelectData=
{
getMenuSelectData
}
customKey=
'id'
checkable
...
...
src/pages/ruleSettingManage/memberAuthManage/index.tsx
View file @
78c7a4d8
...
...
@@ -12,11 +12,11 @@ import EyePreview from '@/components/EyePreview';
import
DeleteItem
from
'@/components/DeleteItem'
;
const
setInformation
=
(
id
)
=>
{
history
.
push
(
`/
memberManage/memberAuthManage/setMemberAuth
?id=
${
id
}
`
)
history
.
push
(
`/
ruleSettingManager/memberAuthManage/detail
?id=
${
id
}
`
)
}
const
fetchData
=
async
(
params
:
any
)
=>
{
const
data
=
await
PublicApi
.
getMemberRolePage
(
params
)
const
data
=
await
PublicApi
.
getMember
Platform
RolePage
(
params
)
return
data
.
data
}
...
...
@@ -26,44 +26,44 @@ const MemberRoleManage: React.FC<{}> = () => {
const
columns
:
ColumnType
<
{}
>
[]
=
[
{
title
:
'会员角色ID'
,
dataIndex
:
'
i
d'
,
dataIndex
:
'
roleI
d'
,
align
:
'center'
,
key
:
'
i
d'
,
key
:
'
roleI
d'
,
},
{
title
:
'会员角色'
,
dataIndex
:
'
n
ame'
,
dataIndex
:
'
roleN
ame'
,
align
:
'center'
,
key
:
'
n
ame'
,
key
:
'
roleN
ame'
,
className
:
'commonPickColor'
,
render
:
(
text
:
any
,
record
:
any
)
=>
<
EyePreview
handleClick=
{
editMember
.
bind
(
null
,
record
,
'1'
)
}
type=
'button'
>
{
text
}
</
EyePreview
>
render
:
(
text
:
any
,
record
:
any
)
=>
<
EyePreview
url=
{
`/ruleSettingManager/memberAuthManage/preview?id=${record.roleId}&preview=1`
}
>
{
text
}
</
EyePreview
>
},
{
title
:
'业务类型'
,
align
:
'center'
,
dataIndex
:
'
serviceTyp
e'
,
key
:
'
serviceTyp
e'
dataIndex
:
'
businessTypeNam
e'
,
key
:
'
businessTypeNam
e'
},
{
title
:
'角色类型'
,
align
:
'center'
,
dataIndex
:
'roleType'
,
key
:
'roleType'
,
render
:
(
data
)
=>
findArrayItem
(
MEMBER_ROLE_LISTS
,
data
).
label
dataIndex
:
'roleType
Name
'
,
key
:
'roleType
Name
'
,
//
render: (data) => findArrayItem(MEMBER_ROLE_LISTS, data).label
},
{
title
:
'会员类型'
,
align
:
'center'
,
dataIndex
:
'memberType'
,
key
:
'memberType'
,
render
:
(
data
)
=>
findArrayItem
(
MEMBER_TYPE_LISTS
,
data
).
label
dataIndex
:
'memberType
Name
'
,
key
:
'memberType
Name
'
,
//
render: (data) => findArrayItem(MEMBER_TYPE_LISTS, data).label
},
{
title
:
'状态'
,
align
:
'center'
,
dataIndex
:
'stat
e
'
,
key
:
'stat
e
'
,
render
:
(
text
:
any
,
record
:
any
)
=>
<
StatusSwitch
handleCancel=
{
cancel
}
handleConfirm=
{
()
=>
handleModify
(
text
,
record
)
}
record=
{
record
}
></
StatusSwitch
>
dataIndex
:
'stat
us
'
,
key
:
'stat
us
'
,
render
:
(
text
:
any
,
record
:
any
)
=>
<
StatusSwitch
handleCancel=
{
cancel
}
fieldNames=
'status'
handleConfirm=
{
()
=>
handleModify
(
text
,
record
)
}
record=
{
record
}
></
StatusSwitch
>
},
{
title
:
'操作'
,
...
...
@@ -72,51 +72,19 @@ const MemberRoleManage: React.FC<{}> = () => {
render
:
(
text
:
any
,
record
:
any
)
=>
{
return
(
<>
{
record
.
state
===
0
&&
<
Button
className=
'commonShow'
type=
'link'
onClick=
{
editMember
.
bind
(
null
,
record
,
'0'
)
}
>
修改
</
Button
>
}
{
record
.
state
===
0
&&
<
DeleteItem
confirm=
{
()
=>
deleteMember
(
record
)
}
/>
}
{
record
.
state
===
1
&&
<
Button
className=
'commonShow'
type=
'link'
onClick=
{
()
=>
setInformation
(
record
.
id
)
}
>
设置会员权限
</
Button
>
}
{
record
.
status
===
1
&&
<
Button
className=
'commonShow'
type=
'link'
onClick=
{
()
=>
setInformation
(
record
.
roleId
)
}
>
设置会员权限
</
Button
>
}
</>
)
}
}
];
const
editMember
=
(
memberInfo
:
any
,
preview
?)
=>
{
history
.
push
({
pathname
:
'/memberManage/memberRoleManage/addMemberRole'
,
state
:
memberInfo
,
query
:
{
id
:
'custom'
,
preview
}
})
}
const
deleteMember
=
(
memberInfo
:
any
)
=>
{
PublicApi
.
postMemberRoleDelete
({
memberRoleId
:
memberInfo
.
id
})
ref
.
current
.
reload
()
}
const
formSearch
:
ISchema
=
{
type
:
'object'
,
properties
:
{
name
:
{
type
:
'string'
,
"x-component-props"
:
{
placeholder
:
'请输入会员角色'
}
}
}
}
const
cancel
=
()
=>
{
console
.
log
(
'cancel'
)
}
const
handleModify
=
async
(
text
:
number
,
record
:
any
)
=>
{
await
PublicApi
.
postMember
RoleUpdatestatus
({
id
:
record
.
id
,
status
:
text
})
await
PublicApi
.
postMember
PlatformRoleStatusUpdate
({
roleId
:
record
.
roleId
,
status
:
text
===
1
?
0
:
1
})
ref
.
current
.
reload
()
}
...
...
@@ -125,6 +93,7 @@ const MemberRoleManage: React.FC<{}> = () => {
<
StandardTable
columns=
{
columns
}
currentRef=
{
ref
}
rowKey=
'roleId'
fetchTableData=
{
(
params
:
any
)
=>
fetchData
(
params
)
}
formilyLayouts=
{
{
justify
:
'space-between'
...
...
@@ -137,7 +106,7 @@ const MemberRoleManage: React.FC<{}> = () => {
schema
:
{
type
:
'object'
,
properties
:
{
n
ame
:
{
roleN
ame
:
{
type
:
'Search'
,
"x-component-props"
:
{
placeholder
:
'请输入角色名称'
...
...
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