Commit eeb906ed authored by 李腾's avatar 李腾

feat: 权限控制优化

parent 09d30b28
/** @name 商品管理 */ /** @name 商品管理 */
// 商品库 // 商品库
export const GOOD_MANAGE = { export const GOOD_MANAGE = {
LIST: '020101', LIST: '020101', // 商品列表
EDITABLE: '020102', EDITABLE: '020102', // 新增/修改
ADD_SERVICE_GOODS: '020103', // 新增服务商品
ADD_NORMAL_GOODS: '020104', // 新增实物商品
}; };
// 配送区域 // 配送区域
...@@ -43,8 +45,6 @@ export const AFTER_SALE_ADDRESS = { ...@@ -43,8 +45,6 @@ export const AFTER_SALE_ADDRESS = {
EDITABLE: '030102', // 新增/修改 EDITABLE: '030102', // 新增/修改
}; };
/** @name 货款结算 */
/** @name 售后管理 */ /** @name 售后管理 */
export const AFTER_SALE_ORDER = { export const AFTER_SALE_ORDER = {
LIST: '050101', // 售后订单列表 LIST: '050101', // 售后订单列表
......
...@@ -78,6 +78,11 @@ const BasicLayout = props => { ...@@ -78,6 +78,11 @@ const BasicLayout = props => {
setSiderCollapsed(payload); setSiderCollapsed(payload);
}; // get children authority }; // get children authority
// 跳转到首页
const toIndex = () => {
props.history.push('/');
};
const authorized = getAuthorityFromRouter(props.route.routes, location.pathname || '/'); const authorized = getAuthorityFromRouter(props.route.routes, location.pathname || '/');
const _menu = param => const _menu = param =>
param.map(v => param.map(v =>
...@@ -154,7 +159,7 @@ const BasicLayout = props => { ...@@ -154,7 +159,7 @@ const BasicLayout = props => {
rightContentRender={rightProps => <RightContent {...rightProps} />} rightContentRender={rightProps => <RightContent {...rightProps} />}
pageTitleRender={() => ''} pageTitleRender={() => ''}
menuHeaderRender={() => ( menuHeaderRender={() => (
<div className={style['custom-title-box']}> <div className={style['custom-title-box']} onClick={toIndex}>
<div className={style['custom-title-box-logo']}> <div className={style['custom-title-box-logo']}>
<div> <div>
<img className={style['custom-title-box-logoImg']} alt="量星球" src={logo} /> <img className={style['custom-title-box-logoImg']} alt="量星球" src={logo} />
......
...@@ -33,11 +33,7 @@ class goodsManage extends Component { ...@@ -33,11 +33,7 @@ class goodsManage extends Component {
loading: false, loading: false,
}; };
canEditable = false;
componentDidMount() { componentDidMount() {
this.canEditable = this.props.permissions[GOOD_MANAGE.EDITABLE];
console.log(111, this.props.permissions, this.canEditable);
this.props.onRef(this); this.props.onRef(this);
this.handleSearch(); this.handleSearch();
} }
...@@ -101,10 +97,11 @@ class goodsManage extends Component { ...@@ -101,10 +97,11 @@ class goodsManage extends Component {
}; };
render() { render() {
const { treeData } = this.props; const { treeData, permissions } = this.props;
const selectW = { width: 250 }; const selectW = { width: 250 };
const iptNumWidth = { width: 118 }; const iptNumWidth = { width: 118 };
const that = this; const that = this;
const canEditable = permissions[GOOD_MANAGE.EDITABLE];
const content = ( const content = (
<div> <div>
<Button style={{ border: 'none' }} onClick={() => this.setArea(1, 'distribution')}> <Button style={{ border: 'none' }} onClick={() => this.setArea(1, 'distribution')}>
...@@ -226,7 +223,7 @@ class goodsManage extends Component { ...@@ -226,7 +223,7 @@ class goodsManage extends Component {
导出 导出
</Button> </Button>
</FormItem> </FormItem>
{this.canEditable ? ( {canEditable ? (
<FormItem style={{ float: 'right' }}> <FormItem style={{ float: 'right' }}>
<Popover content={content} onVisibleChange={this.handleVisibleChange}> <Popover content={content} onVisibleChange={this.handleVisibleChange}>
<Button type="primary" className={styles.button}> <Button type="primary" className={styles.button}>
......
...@@ -66,11 +66,8 @@ class goodsManage extends Component { ...@@ -66,11 +66,8 @@ class goodsManage extends Component {
shopList = []; shopList = [];
canEditable = false;
componentDidMount() { componentDidMount() {
this.props.goodsManage.tableData = {}; this.props.goodsManage.tableData = {};
this.canEditable = this.props.permissions[GOOD_MANAGE.EDITABLE];
this.categoryList(); this.categoryList();
this.getVirtualCategory(); this.getVirtualCategory();
this.specList(); this.specList();
...@@ -391,35 +388,42 @@ class goodsManage extends Component { ...@@ -391,35 +388,42 @@ class goodsManage extends Component {
render() { render() {
const { const {
goodsManage: { tableData = {} }, goodsManage: { tableData = {} },
permissions,
} = this.props; } = this.props;
const rowSelection = { const rowSelection = {
selectedRowKeys: this.state.selectedRowKeys, selectedRowKeys: this.state.selectedRowKeys,
onChange: this.onSelectChange, onChange: this.onSelectChange,
}; };
const { pageNo, pageSize, selectedRowKeys } = this.state; const { pageNo, pageSize, selectedRowKeys } = this.state;
const canAddService = permissions[GOOD_MANAGE.ADD_SERVICE_GOODS];
const canAddNormal = permissions[GOOD_MANAGE.ADD_NORMAL_GOODS];
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<Spin spinning={this.state.createloading}> <Spin spinning={this.state.createloading}>
{this.canEditable ? ( {canAddNormal ? (
<> <Button
<Button type="primary"
type="primary" className={styles.button}
className={styles.button} onClick={() => this.setState({ createVisible: true, initData: {} })}
onClick={() => this.setState({ createVisible: true, initData: {} })} >
> 新增商品
新增商品 </Button>
</Button> ) : (
<Button ''
type="primary" )}
className={styles.button} {canAddService ? (
onClick={() => this.serviceVisbleClose(true)} <Button
> type="primary"
新增服务类商品 className={styles.button}
</Button> onClick={() => this.serviceVisbleClose(true)}
</> >
新增服务类商品
</Button>
) : ( ) : (
'' ''
)} )}
<Card> <Card>
<SearchForm <SearchForm
handleSearch={this.handleSearch} handleSearch={this.handleSearch}
......
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