Commit 5018e3c2 authored by xiexiuxing's avatar xiexiuxing

feat:商品货品按钮权限控制

parent d77c99b4
// 这里是处理比较特殊的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 (menuCode) {
if (btnCode) {
// 是否有页面标识
// 找到该页面标识的按钮权限数据,并匹配权限按钮是否勾选
if (AuthCode[i].buttonCode === menuCode) {
if (AuthCode[i].buttonCode === btnCode) {
return true
}
}
......
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 (menuCode) {
if (btnCode) {
// 是否有页面标识
// 找到该页面标识的按钮权限数据,并匹配权限按钮是否勾选
if (AuthCode[i].buttonCode === menuCode) {
if (AuthCode[i].buttonCode === btnCode) {
return true
}
}
......
// 价格策略
// 价格策略
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
......@@ -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}&nbsp;<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>
......
......@@ -138,10 +138,10 @@ const PriceManage: React.FC<{}> = () => {
render: (text: any, record: any) => {
return (
<>
<AuthButton menuCode='priceManage.edit' urlCode='jiageguanl'>
<AuthButton btnCode='priceManage.edit' menuCode='jiageguanl'>
<Button type='link' className="padLeft0" onClick={() => handleModify(record)}>{intl.formatMessage({ id: 'dealAbility.xiugai' })}</Button>
</AuthButton>
<AuthButton menuCode='priceManage.del' urlCode='jiageguanl'>
<AuthButton btnCode='priceManage.del' menuCode='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' urlCode='jiageguanl'>
<AuthButton btnCode='priceManage.add' menuCode='jiageguanl'>
<Button
type='primary'
onClick={() => history.push('/memberCenter/commodityAbility/priceManage/priceStrategy/setStrategy/add')}
......
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