import React, { PureComponent } from "react";
import { connect } from "dva";
import { Icon, Button, Table } from "antd";
import styles from "./index.less";
import { getCustomer } from '@/utils/request';
class Supplier extends PureComponent {
    componentDidMount() {
        const { dispatch } = this.props;
        // 01 ： 1级供应商
        const supplier = getCustomer().customerRankCode == '01' ? "myAccount/getsuppliersJurisdiction" : "myAccount/getsuppliersPsr";
        dispatch({
            type: supplier,
            payload: null
        });
    }

    render() {
        const { suppliersJurisdiction, suppliersPsr } = this.props;
        const supplierData = getCustomer().customerRankCode == '01' ? suppliersJurisdiction : suppliersPsr;
        const tabTitle = getCustomer().customerRankCode == '01' ? '上级销售组织' : '上级渠道商';
        const columns = [
            {
                title: '产品线/品牌',
                align: 'left',
                width: '200px',
                className: 'pl20',
                dataIndex: 'productLineName',
                key: 'productLineName'
            },
            {
                title: tabTitle,
                align: 'left',
                dataIndex: 'saleOrganizationName',
                key: 'saleOrganizationName'
            }
        ];
        return (
            <div className={styles.cartListBox}>
                {/* <div className={styles.classHead}>
                    <span className={styles.nameIndex}>首页</span>
                    <span className={styles.nameChild}>
                        <Icon type="right" className={styles.nameIcon} />账户中心
                    </span>
                    <span className={styles.nameChild}>
                        <Icon type="right" className={styles.nameIcon} />我的供应商
                    </span>
                </div> */}
                {/* 内容部分 */}
                {/* 客户联系人 */}
                <div className={styles.customerContent}>
                    <div className={styles.customerDataBox} style={{ paddingLeft: 0, borderBottom: 'none' }}>
                        <Table
                          className={styles.customerTable}
                          columns={columns}
                          dataSource={supplierData ? supplierData : []}
                          pagination={false}
                        />
                    </div>
                </div>
            </div>
        );
    }
}


export default connect(state => ({
    suppliersJurisdiction: state.myAccount.suppliersJurisdiction,
    suppliersPsr: state.myAccount.suppliersPsr
}))(Supplier);
