Commit eeb906ed authored by 李腾's avatar 李腾

feat: 权限控制优化

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