Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
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
黄庭坚
jinfa-platform
Commits
5018e3c2
Commit
5018e3c2
authored
Dec 23, 2021
by
xiexiuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:商品货品按钮权限控制
parent
d77c99b4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
58 deletions
+98
-58
AuthUrl.ts
src/components/AuthButton/AuthUrl.ts
+21
-11
index.tsx
src/components/AuthButton/index.tsx
+20
-14
按钮状态.mad
src/components/AuthButton/按钮状态.mad
+10
-4
index.tsx
src/pages/commodity/goods/index.tsx
+44
-26
index.tsx
src/pages/priceManage/priceStrategy/index.tsx
+3
-3
No files found.
src/components/AuthButton/AuthUrl.ts
View file @
5018e3c2
// 这里是处理比较特殊的url 跳转的
export
const
AuthUrl
=
(
menuCode
:
string
,
urlCode
:
string
,
btnCode
?
:
string
)
=>
{
export
const
AuthUrl
=
(
btnCode
:
string
,
menuCode
:
string
)
=>
{
const
userBtn
=
require
(
'../../../config/router.config.json'
)
const
AuthRoutes
=
userBtn
.
filter
((
item
:
any
)
=>
item
.
relationParentCode
===
urlCode
);
const
AuthButton
=
AuthRoutes
[
0
]?.
routes
;
const
AuthCode
:
any
=
[];
for
(
let
i
=
0
;
i
<
AuthButton
.
length
;
i
++
)
{
if
(
AuthButton
[
i
].
btns
.
length
!=
0
)
{
for
(
let
j
=
0
;
j
<
AuthButton
[
i
].
btns
.
length
;
j
++
)
{
if
(
AuthButton
[
i
].
btns
[
j
].
buttonCode
===
menuCode
)
{
AuthCode
.
push
(
AuthButton
[
i
].
btns
[
j
]);
const
AuthRoutes
=
userBtn
.
find
((
item
:
any
)
=>
item
?.
relationParentCode
===
menuCode
);
let
AuthCode
:
any
=
[];
if
(
AuthRoutes
)
{
for
(
let
i
=
0
;
i
<
AuthRoutes
.
routes
.
length
;
i
++
)
{
const
pathList
=
AuthRoutes
.
routes
[
i
];
if
(
pathList
.
routes
)
{
for
(
let
j
=
0
;
j
<
pathList
.
routes
.
length
;
j
++
)
{
// console.log(pathList.routes[j].path)
if
(
pathList
.
routes
[
j
].
path
===
location
.
pathname
)
{
AuthCode
=
pathList
.
routes
[
j
].
btns
break
;
}
}
}
else
{
if
(
AuthRoutes
.
routes
[
i
].
path
===
location
.
pathname
)
{
AuthCode
=
AuthRoutes
.
routes
[
i
].
btns
break
;
}
}
}
}
// console.log(AuthCode, 'AuthCode')
// 本地开发时传的特殊标识,直接开放权限
if
(
btnCode
===
'DevTest'
)
return
true
for
(
let
i
=
0
;
i
<
AuthCode
.
length
;
i
++
)
{
if
(
menu
Code
)
{
if
(
btn
Code
)
{
// 是否有页面标识
// 找到该页面标识的按钮权限数据,并匹配权限按钮是否勾选
if
(
AuthCode
[
i
].
buttonCode
===
menu
Code
)
{
if
(
AuthCode
[
i
].
buttonCode
===
btn
Code
)
{
return
true
}
}
...
...
src/components/AuthButton/index.tsx
View file @
5018e3c2
export
interface
AuthButtonProps
{
btnCode
?
:
string
btnCode
:
string
menuCode
:
string
children
:
any
,
urlCode
:
string
,
}
/**
* 按钮权限
...
...
@@ -15,32 +14,39 @@ const AuthButton = (props: AuthButtonProps) => {
children
,
btnCode
,
// 按钮标识
menuCode
,
// 按钮页面标识
urlCode
,
// 父级别菜单
}
=
props
const
userBtn
=
require
(
'../../../config/router.config.json'
)
const
AuthRoutes
=
userBtn
.
filter
((
item
:
any
)
=>
item
.
relationParentCode
===
urlCode
);
const
AuthButton
=
AuthRoutes
[
0
]?.
routes
;
const
AuthCode
:
any
=
[];
for
(
let
i
=
0
;
i
<
AuthButton
.
length
;
i
++
)
{
if
(
AuthButton
[
i
].
btns
.
length
!=
0
)
{
for
(
let
j
=
0
;
j
<
AuthButton
[
i
].
btns
.
length
;
j
++
)
{
if
(
AuthButton
[
i
].
btns
[
j
].
buttonCode
===
menuCode
)
{
AuthCode
.
push
(
AuthButton
[
i
].
btns
[
j
]);
const
AuthRoutes
=
userBtn
.
find
((
item
:
any
)
=>
item
?.
relationParentCode
===
menuCode
);
let
AuthCode
:
any
=
[];
if
(
AuthRoutes
)
{
for
(
let
i
=
0
;
i
<
AuthRoutes
.
routes
.
length
;
i
++
)
{
const
pathList
=
AuthRoutes
.
routes
[
i
];
if
(
pathList
.
routes
)
{
for
(
let
j
=
0
;
j
<
pathList
.
routes
.
length
;
j
++
)
{
// console.log(pathList.routes[j].path)
if
(
pathList
.
routes
[
j
].
path
===
location
.
pathname
)
{
AuthCode
=
pathList
.
routes
[
j
].
btns
break
;
}
}
}
else
{
if
(
AuthRoutes
.
routes
[
i
].
path
===
location
.
pathname
)
{
AuthCode
=
AuthRoutes
.
routes
[
i
].
btns
break
;
}
}
}
}
// console.log(AuthCode, 'AuthCode')
;
// console.log(AuthCode, 'AuthCode')
const
_authorityBtn
=
()
=>
{
// 本地开发时传的特殊标识,直接开放权限
if
(
btnCode
===
'DevTest'
)
return
true
for
(
let
i
=
0
;
i
<
AuthCode
.
length
;
i
++
)
{
if
(
menu
Code
)
{
if
(
btn
Code
)
{
// 是否有页面标识
// 找到该页面标识的按钮权限数据,并匹配权限按钮是否勾选
if
(
AuthCode
[
i
].
buttonCode
===
menu
Code
)
{
if
(
AuthCode
[
i
].
buttonCode
===
btn
Code
)
{
return
true
}
}
...
...
src/components/AuthButton/按钮状态.mad
View file @
5018e3c2
// 价格策略
// 价格策略
priceManage.add" 价格策略列表新曾
priceManage.del 价格策略列表删除
priceManage.edit 价格策略编辑
priceManage.state 价格策略设置是否有效按钮
priceManage.see 价格策略查看详情
\ No newline at end of file
priceManage.see 价格策略查看详情
// 货品
goods.add : '货品列表新曾'
goods.batch :'货品列表批量'
goods.see :'货品列表查看'
goods.del :'货品列表删除'
goods.edit :'货品列表修改'
\ No newline at end of file
src/pages/commodity/goods/index.tsx
View file @
5018e3c2
...
...
@@ -23,6 +23,8 @@ import { goodsSchema } from './schema'
import
{
FORM_FILTER_PATH
}
from
'@/formSchema/const'
import
{
searchBrandOptionEffect
,
searchCustomerCategoryOptionEffect
}
from
'./effect'
import
{
getProductGoodsGetGoodsList
,
postProductGoodsDeleteBatchGoods
}
from
'@/services/ProductV2Api'
import
AuthButton
from
'@/components/AuthButton'
import
{
AuthUrl
}
from
'@/components/AuthButton/AuthUrl'
const
{
Option
}
=
Select
;
const
{
confirm
}
=
Modal
...
...
@@ -45,6 +47,12 @@ const Goods: React.FC<{}> = () => {
currentRefRow
.
current
=
goodsRowCtl
.
selectRow
},
[
goodsRowCtl
])
const
Jump
=
(
record
:
any
)
=>
{
if
(
AuthUrl
(
'goods.see'
,
'commodityAbility'
))
{
history
.
push
(
`/memberCenter/commodityAbility/commodity/goods/detail?id=
${
record
.
id
}
&isSee=true`
)
}
}
const
columns
:
ColumnType
<
any
>
[]
=
[
{
title
:
intl
.
formatMessage
({
id
:
'commodity.goods.columns.code'
}),
...
...
@@ -58,7 +66,8 @@ const Goods: React.FC<{}> = () => {
className
:
'commonPickColor'
,
render
:
(
text
:
any
,
record
:
any
)
=>
<
span
className=
"commonPickColor"
onClick=
{
()
=>
history
.
push
(
`/memberCenter/commodityAbility/commodity/goods/detail?id=${record.id}&isSee=true`
)
}
onClick=
{
()
=>
Jump
(
record
)
}
>
{
text
}
<
EyeOutlined
/>
</
span
>
...
...
@@ -100,16 +109,20 @@ const Goods: React.FC<{}> = () => {
render
:
(
text
:
any
,
record
:
any
)
=>
{
return
(
<>
<
Button
type=
'link'
onClick=
{
()
=>
history
.
push
(
`/memberCenter/commodityAbility/commodity/goods/edit?id=${record.id}`
)
}
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.1'
})
}
</
Button
>
<
Popconfirm
title=
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2.popconfirm.title'
})
}
onConfirm=
{
()
=>
handleSingleDelete
(
record
)
}
onCancel=
{
()
=>
console
.
log
(
'取消'
)
}
okText=
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2.popconfirm.okText'
})
}
cancelText=
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2.popconfirm.cancelText'
})
}
>
<
Button
type=
'link'
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2'
})
}
</
Button
>
</
Popconfirm
>
<
AuthButton
btnCode=
'goods.edit'
menuCode=
'commodityAbility'
>
<
Button
type=
'link'
onClick=
{
()
=>
history
.
push
(
`/memberCenter/commodityAbility/commodity/goods/edit?id=${record.id}`
)
}
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.1'
})
}
</
Button
>
</
AuthButton
>
<
AuthButton
btnCode=
'goods.del'
menuCode=
'commodityAbility'
>
<
Popconfirm
title=
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2.popconfirm.title'
})
}
onConfirm=
{
()
=>
handleSingleDelete
(
record
)
}
onCancel=
{
()
=>
console
.
log
(
'取消'
)
}
okText=
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2.popconfirm.okText'
})
}
cancelText=
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2.popconfirm.cancelText'
})
}
>
<
Button
type=
'link'
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.columns.option.button.2'
})
}
</
Button
>
</
Popconfirm
>
</
AuthButton
>
</>
)
}
...
...
@@ -297,18 +310,23 @@ const Goods: React.FC<{}> = () => {
const
controllerBtns
=
(
<
Space
>
<
Button
type=
'primary'
onClick=
{
()
=>
history
.
push
(
'/memberCenter/commodityAbility/commodity/goods/add'
)
}
>
<
PlusOutlined
/>
{
intl
.
formatMessage
({
id
:
'commodity.goods.controllerBtns.button.1'
})
}
</
Button
>
{
/* <Button style={{ margin: '0 16px' }} onClick={() => setImportModal(true)}>导入数据</Button> */
}
<
Dropdown
overlay=
{
menuMore
}
trigger=
{
[
'click'
]
}
>
<
Button
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.controllerBtns.button.2'
})
}
<
DownOutlined
/>
<
AuthButton
btnCode=
'goods.add'
menuCode=
'commodityAbility'
>
<
Button
type=
'primary'
onClick=
{
()
=>
history
.
push
(
'/memberCenter/commodityAbility/commodity/goods/add'
)
}
>
<
PlusOutlined
/>
{
intl
.
formatMessage
({
id
:
'commodity.goods.controllerBtns.button.1'
})
}
</
Button
>
</
Dropdown
>
</
AuthButton
>
{
/* <Button style={{ margin: '0 16px' }} onClick={() => setImportModal(true)}>导入数据</Button> */
}
<
AuthButton
btnCode=
'goods.batch'
menuCode=
'commodityAbility'
>
<
Dropdown
overlay=
{
menuMore
}
trigger=
{
[
'click'
]
}
>
<
Button
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.controllerBtns.button.2'
})
}
<
DownOutlined
/>
</
Button
>
</
Dropdown
>
</
AuthButton
>
</
Space
>
);
...
...
@@ -398,13 +416,13 @@ const Goods: React.FC<{}> = () => {
<
Result
icon=
{
<
Progress
type=
"circle"
percent=
{
100
}
status=
"exception"
/>
}
title=
{
step2Exception
}
extra=
{
<
Button
onClick=
{
exportErrorLog
}
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.button.2'
})
}
</
Button
>
}
extra=
{
<
Button
onClick=
{
exportErrorLog
}
>
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.button.2'
})
}
</
Button
>
}
/>
</>
}
</
Modal
>
<
Modal
title=
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.title'
})
}
title=
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.title'
})
}
visible=
{
deleteBatchModal
}
onOk=
{
handleOkDeleteBatch
}
onCancel=
{
handleCancelDelete
}
...
...
@@ -413,8 +431,8 @@ const Goods: React.FC<{}> = () => {
<
Form
layout=
"vertical"
>
<
Form
.
Item
label=
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.form.label'
})
}
>
<
Select
placeholder=
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.form.placeholder'
})
}
>
<
Form
.
Item
label=
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.form.label'
})
}
>
<
Select
placeholder=
{
intl
.
formatMessage
({
id
:
'commodity.goods.modal.form.placeholder'
})
}
>
<
Select
.
Option
value=
"542424"
>
4245242452
</
Select
.
Option
>
</
Select
>
</
Form
.
Item
>
...
...
src/pages/priceManage/priceStrategy/index.tsx
View file @
5018e3c2
...
...
@@ -138,10 +138,10 @@ const PriceManage: React.FC<{}> = () => {
render
:
(
text
:
any
,
record
:
any
)
=>
{
return
(
<>
<
AuthButton
menuCode=
'priceManage.edit'
url
Code=
'jiageguanl'
>
<
AuthButton
btnCode=
'priceManage.edit'
menu
Code=
'jiageguanl'
>
<
Button
type=
'link'
className=
"padLeft0"
onClick=
{
()
=>
handleModify
(
record
)
}
>
{
intl
.
formatMessage
({
id
:
'dealAbility.xiugai'
})
}
</
Button
>
</
AuthButton
>
<
AuthButton
menuCode=
'priceManage.del'
url
Code=
'jiageguanl'
>
<
AuthButton
btnCode=
'priceManage.del'
menu
Code=
'jiageguanl'
>
<
Popconfirm
title=
{
intl
.
formatMessage
({
id
:
'priceManage.priceStrategy.popconfirm.title'
})
}
okText=
{
intl
.
formatMessage
({
id
:
'priceManage.priceStrategy.popconfirm.okText'
})
}
cancelText=
{
intl
.
formatMessage
({
id
:
'priceManage.priceStrategy.popconfirm.cancelText'
})
}
onConfirm=
{
()
=>
handleDelete
(
record
)
}
>
<
Button
type=
'link'
className=
"padLeft0"
>
{
intl
.
formatMessage
({
id
:
'priceManage.priceStrategy.popconfirm.link'
})
}
</
Button
>
</
Popconfirm
>
...
...
@@ -187,7 +187,7 @@ const PriceManage: React.FC<{}> = () => {
const
controllerBtns
=
(
<
Space
>
<
AuthButton
menuCode=
'priceManage.add'
url
Code=
'jiageguanl'
>
<
AuthButton
btnCode=
'priceManage.add'
menu
Code=
'jiageguanl'
>
<
Button
type=
'primary'
onClick=
{
()
=>
history
.
push
(
'/memberCenter/commodityAbility/priceManage/priceStrategy/setStrategy/add'
)
}
...
...
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