Commit 5aebd008 authored by xiexiuxing's avatar xiexiuxing

feat:价格策略按钮权限控制

parent 5009f32c
// 这里是处理比较特殊的url 跳转的
export const AuthUrl = (menuCode: string, urlCode: string, btnCode?: 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]);
break;
}
}
}
}
if (btnCode === 'DevTest') return true
for (let i = 0; i < AuthCode.length; i++) {
if (menuCode) {
// 是否有页面标识
// 找到该页面标识的按钮权限数据,并匹配权限按钮是否勾选
if (AuthCode[i].buttonCode === menuCode) {
return true
}
}
continue
}
return false
}
\ No newline at end of file
export interface AuthButtonProps {
btnCode?: string
menuCode: string
children: any,
urlCode: string,
}
/**
* 按钮权限
* @param {String} menuCode 页面标识
* @param {String} btnCode 按钮标识
*/
const AuthButton = (props: AuthButtonProps) => {
const {
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]);
break;
}
}
}
}
// console.log(AuthCode, 'AuthCode');
const _authorityBtn = () => {
// 本地开发时传的特殊标识,直接开放权限
if (btnCode === 'DevTest') return true
for (let i = 0; i < AuthCode.length; i++) {
if (menuCode) {
// 是否有页面标识
// 找到该页面标识的按钮权限数据,并匹配权限按钮是否勾选
if (AuthCode[i].buttonCode === menuCode) {
return true
}
}
continue
}
return false
}
return _authorityBtn() ? children : null
}
export default AuthButton;
priceManage.add" 价格策略列表新曾
priceManage.del 价格策略列表删除
priceManage.edit 价格策略编辑
priceManage.state 价格策略设置是否有效按钮
priceManage.see 价格策略查看详情
\ No newline at end of file
......@@ -14,6 +14,8 @@ import { history, useIntl } from 'umi'
import StatusSwitch from '@/components/StatusSwitch'
import { PlusOutlined } from '@ant-design/icons'
import { getProductCommodityGetUnitPriceStrategyList, postProductCommodityDeleteUnitPriceStrategy, postProductCommodityUpdateUnitPriceStrategyStatus } from '@/services/ProductV2Api'
import AuthButton from '@/components/AuthButton'
import { AuthUrl } from '@/components/AuthButton/AuthUrl'
const formActions = createFormActions();
......@@ -32,11 +34,14 @@ const PriceManage: React.FC<{}> = () => {
dataIndex: 'name',
key: 'name',
className: 'commonPickColor',
render: (text: any, record: any) => <EyePreview
url={`/memberCenter/commodityAbility/priceManage/priceStrategy/setStrategy/detail?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
render: (text: any, record: any) =>
<EyePreview
url={`/memberCenter/commodityAbility/priceManage/priceStrategy/setStrategy/detail?id=${record.id}&preview=1`}
type={AuthUrl('priceManage.see', 'jiageguanl') ? 'link' : 'button'}
>
{text}
</EyePreview>
},
// {
// title: '商品ID',
......@@ -133,10 +138,14 @@ const PriceManage: React.FC<{}> = () => {
render: (text: any, record: any) => {
return (
<>
<Button type='link' className="padLeft0" onClick={() => handleModify(record)}>{intl.formatMessage({ id: 'dealAbility.xiugai' })}</Button>
<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>
<AuthButton menuCode='priceManage.edit' urlCode='jiageguanl'>
<Button type='link' className="padLeft0" onClick={() => handleModify(record)}>{intl.formatMessage({ id: 'dealAbility.xiugai' })}</Button>
</AuthButton>
<AuthButton menuCode='priceManage.del' urlCode='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>
</AuthButton>
</>
)
}
......@@ -178,12 +187,14 @@ const PriceManage: React.FC<{}> = () => {
const controllerBtns = (
<Space>
<Button
type='primary'
onClick={() => history.push('/memberCenter/commodityAbility/priceManage/priceStrategy/setStrategy/add')}
>
<PlusOutlined />{intl.formatMessage({ id: 'priceManage.priceStrategy.controllerBtns' })}
</Button>
<AuthButton menuCode='priceManage.add' urlCode='jiageguanl'>
<Button
type='primary'
onClick={() => history.push('/memberCenter/commodityAbility/priceManage/priceStrategy/setStrategy/add')}
>
<PlusOutlined />{intl.formatMessage({ id: 'priceManage.priceStrategy.controllerBtns' })}
</Button>
</AuthButton>
</Space>
)
......
......@@ -54,15 +54,15 @@ const SetStrategy: React.FC<{}> = () => {
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'priceManage.priceStrategy.setStrategy.description' })} />}
className="setStrategy"
title={pageStatus === PageStatus.PREVIEW ? intl.formatMessage({ id: 'priceManage.priceStrategy.setStrategy.title1' }) : (pageStatus === PageStatus.ADD ? intl.formatMessage({ id: 'priceManage.priceStrategy.setStrategy.title2' }) : intl.formatMessage({ id: 'priceManage.priceStrategy.setStrategy.title3' }))}
extra={(
pageStatus !== PageStatus.PREVIEW
? (
<Button key="1" loading={btnLoading} onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
{intl.formatMessage({ id: 'priceManage.priceStrategy.setStrategy.extra' })}
</Button>
)
: null
)}
// extra={(
// pageStatus !== PageStatus.PREVIEW
// ? (
// <Button key="1" loading={btnLoading} onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
// {intl.formatMessage({ id: 'priceManage.priceStrategy.setStrategy.extra' })}
// </Button>
// )
// : null
// )}
>
<Card>
<PriceSetting addSchemaAction={addSchemaAction} schema={setPriceSchema} formSubmit={formSubmit} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment