import React,{ Component } from 'react';
import {
    Modal,
    Select,
} from "antd";
import { provinceList} from '@/NewDicProvinceList';
import './index.less';
import TabelContent from "../../../../common/tabelContent";

class DetailedList extends Component{
    constructor(props) {
        super(props);
        this.state= {
            columns: [
                {
                    title: "编号",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "排名",
                    dataIndex: "p",
                    key: "p",
                },
                {
                    title: "订单部门",
                    dataIndex: "b",
                    key: "b",
                },
                {
                    title: "签单人",
                    dataIndex: "r",
                    key: "r",
                },
                {
                    title: "总单量（个）",
                    dataIndex: "nickname",
                    key: "nickname",
                    className: 'projectTable',
                    width: 150,
                    onCellClick: (record, event) => {
                        event.stopPropagation();
                        this.setState({
                            status: 0,
                            visible1: true,
                            aid: record.aid
                        })
                    },
                },
                {
                    title: "总签单额（万元）",
                    dataIndex: "nickname",
                    key: "nickname",
                    className: 'projectTable',
                    width: 150,
                    onCellClick: (record, event) => {
                        event.stopPropagation();
                        this.setState({
                            status: 1,
                            visible1: true,
                            aid: record.aid
                        })
                    },
                },
                {
                    title: "年度完成率",
                    dataIndex: "l",
                    key: "l",
                    className: 'projectTable',
                    width: 150,
                    onCellClick: (record, event) => {
                        event.stopPropagation();
                        this.setState({
                            status: 2,
                            visible1: true,
                            aid: record.aid
                        })
                    },
                },
            ],
            columns1: [
                {
                    title: "合同编号",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "订单编号",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "客户名称",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "订单部门",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "下单时间",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "合同签订时间",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "流程状态",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "签单金额（万元）",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "开票金额（万元）",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "已收款（万元）",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "结算状态",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "是否特批",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "订单状态",
                    dataIndex: "key",
                    key: "key",
                },
                {
                    title: "财务负责人",
                    dataIndex: "key",
                    key: "key",
                },
            ],
        }
    }

    searchList(){
        let arr = [
            {
                type:'departmentSelect',
                dataKey:'departmentId',
                placeholder:'请选择部门'
            },
            {
                type:'text',
                dataKey:'super',
                placeholder:'请输入订单编号'
            },
            {
                type:'times',
                title:'下单时间',
                dataKey:['startTime','endTime'],
            },
            {
                type:'times',
                title:'合同时间',
                dataKey:['startTime1','endTime1'],
            },
            {
                type:'select',
                dataKey:'superId',
                placeholder:'请选择排序',
                selectList:[
                    {
                        value:'1',
                        label:'按总签单排序'
                    },
                    {
                        value:'0',
                        label:'否'
                    }
                ]
            },
            {
                type:'select',
                dataKey:'province',
                placeholder:'请选择省份',
                selectOptionList:()=>{
                    let Province = [];
                    provinceList.map(function(item) {
                        let id = String(item.id)
                        Province.push(
                            <Select.Option value={id} key={item.name}>{item.name}</Select.Option>
                        )
                    });
                    return Province
                },
            }
        ]
        return arr;
    }

    searchList1(){
        let arr = [
            {
                type:'text',
                dataKey:'super',
                placeholder:'请输入订单编号'
            },
            {
                type:'text',
                dataKey:'name',
                placeholder:'请输入客户名称'
            },
            {
                type:'departmentSelect',
                dataKey:'departmentId',
                placeholder:'请选择部门'
            },
            {
                type:'text',
                dataKey:'bianhao',
                placeholder:'请输入合同编号'
            },
            {
                type:'select',
                dataKey:'2',
                placeholder:'请选择结算状态',
                selectList:[
                    {
                        value:'1',
                        label:'按总签单排序'
                    },
                    {
                        value:'0',
                        label:'否'
                    }
                ]
            },
            {
                type:'select',
                dataKey:'1',
                placeholder:'请选择特批状态',
                selectList:[
                    {
                        value:'1',
                        label:'按总签单排序'
                    },
                    {
                        value:'0',
                        label:'否'
                    }
                ]
            },
            {
                type:'select',
                dataKey:'1',
                placeholder:'请选择签单金额',
                selectList:[
                    {
                        value:'1',
                        label:'按总签单排序'
                    },
                    {
                        value:'0',
                        label:'否'
                    }
                ]
            },
            {
                type:'times',
                title:'下单时间',
                dataKey:['startTime','endTime'],
            },
        ]
        return arr;
    }

    render() {
        return (
            <div>
                <Modal
                    maskClosable={false}
                    visible={this.props.visible}
                    onOk={this.props.onCancel}
                    onCancel={this.props.onCancel}
                    width='1200px'
                    title='内蒙签单统计表'
                    footer=''
                    className="admin-desc-content">
                    <div className="user-content">
                        <TabelContent
                            searchList={this.searchList()}
                            columns={this.state.columns}
                            tabelApi={'/api/admin/newOrder/provinceStatisticsList'}
                            exportApi={'/api/admin/release/publicReleaseDtails/export'}
                            dataProcessing={(data)=>{
                                let theArr = [];
                                for (let i = 0; i < data.data.list.length; i++) {
                                    let thisdata = data.data.list[i];
                                    thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
                                    theArr.push(thisdata);
                                }
                                return theArr;
                            }}
                        />
                    </div>
                    <Modal
                        maskClosable={false}
                        visible={this.state.visible1}
                        onOk={()=>{
                            this.setState({
                                visible1:false
                            })
                        }}
                        onCancel={()=>{
                            this.setState({
                                visible1:false
                            })
                        }}
                        width='1200px'
                        title='部门订单'
                        footer=''
                        className="admin-desc-content">
                        <div className="user-content">
                            <TabelContent
                                searchList={this.searchList1()}
                                columns={this.state.columns1}
                                tabelApi={'/api/admin/newOrder/orderNewList'}
                                exportApi={'/api/admin/newOrder/statisticsListExprot'}
                                dataProcessing={(data)=>{
                                    let theArr = [];
                                    for (let i = 0; i < data.data.list.length; i++) {
                                        let thisdata = data.data.list[i];
                                        thisdata.key=(data.data.pageNo - 1) * data.data.pageSize + i + 1;
                                        theArr.push(thisdata);
                                    }
                                    return theArr;
                                }}
                            />
                        </div>
                    </Modal>
                </Modal>
            </div>
        )
    }
}

export default DetailedList;
