import React from 'react';
import {Button ,Input,Select,Spin,Table, Switch, message, DatePicker, Modal,Form ,Row,Col,TimePicker} from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import moment from 'moment';
import './myClient.less';
import { areaSelect} from '../../../NewDicProvinceList';
const { Column, ColumnGroup } = Table;
import {socialAttribute,newFollow,lvl, customerStatus,intentionalService} from '../../../dataDic.js';
import {getcustomerStatue,getprovince,getStatusFollow,getCompanyIntention,getfllowSituation,getContactType } from '../../../tools.js';
const ServiceQuery= Form.create()(React.createClass({	
    loadData(pageNo, apiUrl) {
        this.state.data = [];
        this.setState({
            loading: true
        });      
        $.ajax({
            method: "post",
            dataType: "json",
            crossDomain: false,          
            url:globalConfig.context + '/api/admin/customer/listAllBusiness',
            data: { 				
                pageNo: pageNo || 1,
                pageSize: this.state.pagination.pageSize,               
                businessGlossoryId: this.state.businessIdS, //业务意向  
                identifyName:this.state.identifyNameS,
                followSituation:this.state.followSituationS,
                customerStatus:this.state.customerStatusS,
			    adminName: this.state.adminNameS,
				startDate: this.state.releaseDate[0],
                endDate: this.state.releaseDate[1],   
            },
            success: function (data) {  
                let theArr = []; 
                if (data.error.length || data.data.list=="") {
                    if (data.error && data.error.length) {
                        message.warning(data.error[0].message);
                    };                   
                } else {  
                    for (let i = 0; i < data.data.list.length; i++) {
                        let thisdata = data.data.list[i];  
                        theArr.push({
                            key: i,                           
                            id: thisdata.id,                                                  
                            businessId:thisdata.businessId,
                            businessName:thisdata.businessName,
                            identifyName:thisdata.identifyName,
                            followSituation:thisdata.followSituation,
                            customerStatus:thisdata.customerStatus,
                            adminName:thisdata.adminName,
                   			createTime:thisdata.createTime,
                   			updateTime:thisdata.updateTime,
                        });
                    };
                    this.state.pagination.current = data.data.pageNo;
                    this.state.pagination.total = data.data.totalCount;
                };
               
                this.setState({
                    dataSource: theArr,
                    pagination: this.state.pagination
                });
            }.bind(this),
        }).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },    
  
    getInitialState() {
        return { 
        	dataSources:[],
        	customerName:[],
        	orgCodeUrl:[],
            companyLogoUrl:[],
        	visible: false ,
            searchMore: true,           
            releaseDate: [],            
            releaseDate: [],
            selectedRowKeys: [],
            selectedRowKey: [],
            selectedRows: [],
            loading: false,
            pagination: {
                defaultCurrent: 1,
                defaultPageSize: 10,
                showQuickJumper: true,
                pageSize: 10,
                onChange: function (page) {
                    this.loadData(page);
                }.bind(this),
                showTotal: function (total) {
                    return '共' + total + '条数据';
                }
            },
            paginations: {
                defaultCurrent: 1,
                defaultPageSize: 10,
                showQuickJumper: true,
                pageSize: 10,
                onChange: function (page) {
                    this.loadVisit(page);
                }.bind(this),
                showTotal: function (total) {
                    return '共' + total + '条数据';
                }
            },
	          businessFollowList: [               
                {
                    title: '跟进时间',
                    dataIndex: 'followTime',
                    key: 'followTime',                                        
                }, {
                    title: '营销员',
                    dataIndex: 'adminName',
                    key: 'adminName',
                }, {
                    title: '意向进度',
                    dataIndex: 'followSituation',
                    key: 'followSituation', 
                    render:text=>{return getfllowSituation(text)}
                }, {
                    title: '客户状态',
                    dataIndex: 'customerStatus',
                    key: 'customerStatus',  
                    render:text=>{return getcustomerStatue(text)}
                }, 
                {
                    title: '拜访方式',
                    dataIndex: 'contactType',
                    key:'contactType',
                    render:text=>{return getContactType(text)}
                }, {
                    title: '联系人',
                    dataIndex: 'contacts',
                    key: 'contacts',                    
                }, 
                {
                    title: '联系电话',
                    dataIndex: 'contactMobile',
                    key:'contactMobile',                   
                }, 
               ],
            columns: [               
                {
                    title: '业务名称',
                    dataIndex: 'businessName',
                    key: 'businessName',                                        
                }, {
                    title: '意向时间',
                    dataIndex: 'createTime',
                    key: 'createTime',
                }, {
                    title: '更新时间',
                    dataIndex: 'updateTime',
                    key: 'updateTime',
                }, {
                    title: '客户名称',
                    dataIndex: 'identifyName',
                    key: 'identifyName', 
                }, {
                    title: '营销员',
                    dataIndex: 'adminName',
                    key: 'adminName',                    
                }, 
                {
                    title: '意向进度',
                    dataIndex: 'followSituation',
                    key:'followSituation',  
                    render: text => { return getfllowSituation(text) }
                },
                 {
                    title: '客户状态',
                    dataIndex: 'customerStatus',
                    key: 'customerStatus',
                    render: text => { return getcustomerStatue(text) }
                },
            ],
            dataSource: [],
            searchTime: [,]
        };
    },    
    componentWillMount() {                     
         //意向服务
        let intentionalArr = [];
        newFollow.map(function (item) {
            intentionalArr.push(