import React, { useState, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Steps, Pagination, Modal, Breadcrumb } from 'antd';
import router from 'umi/router';
import moment from 'moment';
import styles from '../style.less';
import { fetch, apis } from '../../../../utils/request';
import request from '../../../../utils/request';
import AuthButton from '@/components/AuthButton';




function header(props, ref) {

    console.log(props, 'ent')
    console.log(props, 'ref')

    const [data, setData] = useState({})

    useEffect(() => {
        getList({ pageNum: 1, pageSize: 10 });
    }, [])
    // 查询列表

    const getList = params => {
        // certifiedStatus: true,
        request({ ...apis.relatedOrganization.listCompany, params: { ...params } }).then(data => {
            setData(data)
        })
    }
    function handleReset() {
        props.form.resetFields();
        getList({ pageNum: 1, pageSize: 10 });
    }

    const changePageNum = pageNumber => {
        getList({ pageNum: pageNumber, pageSize: 10, ...props.form.getFieldsValue() })
    }

    const choiceent = value => {
        console.log(value, 'value')

        // Modal.confirm({
        //     title: '确认将所选数据删除？',
        //     okText: '确定',
        //     cancelText: '取消',
        //     onOk() {

        //     },
        // });
        props.onChoiceEnt(value)
    }


    const handleSubmit = (e, props) => {
        e.preventDefault();



        getList({ pageNum: 1, pageSize: 10, ...props.form.getFieldsValue() });


    }


    const columns = [
        {
            title: '企业名称',
            dataIndex: 'companyName',
            key: 'companyName',
            align: 'center',

        },
        {
            title: '企业编号',
            dataIndex: 'companyCode',
            key: 'companyCode',
            align: 'center',

        },
        {
            title: '法大大客户编号',
            dataIndex: 'fadadaCode',
            key: 'fadadaCode',
            align: 'center',

        },
        {
            title: '操作',
            dataIndex: 'handle',
            key: 'handle',
            align: 'center',
            render: (x, row) => (
                <>


                    <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={e => choiceent(row)}>
                        选择<Icon type="form" className={styles.edit} />
                    </span>

                </>
            ),
        }
    ]

    const { getFieldDecorator } = props.form
    return (<>
        <div>
            <Form layout="inline" style={{ marginTop: '30px' }} onSubmit={e => handleSubmit(e, props)}>
                <Form.Item>
                    {getFieldDecorator('companyName')(
                        <Input
                            prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
                            placeholder="企业名称 "
                        />,
                    )}
                </Form.Item>
                <Form.Item>
                    {getFieldDecorator('companyCode')(
                        <Input
                            prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
                            placeholder="企业编号 "
                        />,
                    )}
                </Form.Item>
                <Form.Item>
                    <span style={{color:'#999'}}>列表仅显示实名认证状态为审核通过的企业。</span>
                </Form.Item>
                <Form.Item>
                    <Button type="primary" htmlType="submit" className={styles.searchBtn}>搜索</Button>
                    <Button style={{ marginLeft: 8 }} onClick={handleReset}>重置</Button>
                </Form.Item>
            </Form>



            <Table id='noticeTable' style={{ marginTop: '30px' }} dataSource={data.records} columns={columns} pagination={false} />

            <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
                <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={e => changePageNum(e)} current={data.current} />
            </div>


        </div>
    </>)
}

const WrappedHeader = Form.create({ name: 'header' })(header);

export default WrappedHeader