import React from 'react'
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import { Radio, Form, Modal, message, layout, Spin, Button } from 'antd';

const BusName = React.createClass({
	loadData(ids) {
		console.log(ids)
		return ;
		this.setState({
			loading: true
		})
		$.ajax({
			method: "get",
			dataType: "json",
			url: globalConfig.context + '/api/admin/customer/toAddFollow',
			data: {
				uid: e,
			},
			success: function(data) {
				let listArr = [];
				let thedata = data.data;
				if(!thedata) {
					if(data.error && data.error.length) {
						message.warning(data.error[0].message);
					};
					thedata = {};
				};
				for(let i = 0; i < data.data.userBusinessList.length; i++) {
					let thisdata = data.data.userBusinessList[i];
					listArr.push({
						id: thisdata.id,
						businessName: thisdata.businessName,
						businessGlossoryId: String(thisdata.businessGlossoryId),
						followSituation: String(thisdata.followSituation),
						customerStatus: String(thisdata.customerStatus),
						remarks: thisdata.remarks,
					});
				};
				this.setState({
					contacts: thedata.contacts,
					uid: thedata.uid,
					data: listArr,
					identifyName: thedata.identifyName,
					followTime: thedata.followTime,
					businessGlossoryId: thedata.businessGlossoryId,
					followSituation: thedata.followSituation,
					customerStatus: thedata.customerStatus,
					remarks: thedata.remarks,
				});
			}.bind(this),
		}).always(function() {
			this.setState({
				loading: false
			});
		}.bind(this));
	},

	getInitialState() {
		return {
			busModul: false
		}
	},
	visitCancel() {
		this.setState({
			busModul: false
		})
		this.props.closeBus(null,false,false)
	},
	selFn() {
		this.setState({
			busModul: false
		});
		this.props.closeBus(this.state.contactType, false, true);
	},
	componentWillReceiveProps(nextProps) {
		if(nextProps.busModul) {
			this.setState({
				busModul: true,
				loading: false
			})
			this.loadData(nextProps.businessId)
		};
	},
	render() {
		const formItemLayout = {
			labelCol: {
				span: 4
			},
			wrapperCol: {
				span: 18
			},
		};
		return(
			<Modal	
			      className="customeDetails"
			      footer=''
		          title="项目名称"
		          width='600px'
		          visible={this.state.busModul}
		          onOk={this.visitCancel}
				  onCancel={this.visitCancel}							          							          
		        >	
			        <Form layout="horizontal" id="demand-form" >
		    			<Spin spinning={this.state.loading}>
		    			   	<div className="clearfix">
		    			   		<Form.Item 
		                            {...formItemLayout}
		                            label="已签单业务" >
		    			   			<span>好东东.</span>
				           		</Form.Item>
		    			   		<Form.Item 
		                            {...formItemLayout}
		                            label="项目名称" >
		    			   			<Radio.Group value={this.state.contactType} onChange={(e) => {
									        this.setState({ contactType: e.target.value }) 
					                    }}>
					                        <Radio value={'外出'}>外出</Radio>
					                        <Radio value={'电话电话电话电话电话电话'}>电话</Radio>
					                        <Radio value={'QQ'}>QQ</Radio>
					                        <Radio value={'微信'}>微信</Radio>
					                        <Radio value={'邮箱'}>邮箱</Radio>
					                </Radio.Group>
				           		</Form.Item>
				           		<Form.Item wrapperCol={{ span: 12, offset: 4 }}>
		    			   			<Button onClick={this.selFn} type='primary'>选定</Button>
		    			   			<Button onClick={this.visitCancel} style={{marginLeft:'40px'}}>取消</Button>
				           		</Form.Item>
				            </div>
				        </Spin>
					</Form>
			</Modal>
		)
	}
})
export default BusName;