import React from 'react';
import {Form,Button,Spin,message,Modal} from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import {getCompanyIntention ,getfllowSituation,getcustomerStatue,getContactType} from '@/tools.js';
const FormItem =Form.Item;


const BusinFollow =React.createClass({
	getInitialState(){
		return {
			loading:false
		}
	},	
	businessFollowCancel(){
		this.setState({
			businessFollowModul:false
		})
		this.props.closeBusiness(false);
	},
	componentWillReceiveProps(nextProps) {
		if(nextProps.businessFollowModul){
			this.setState({
				businessFollowModul:true
			})
			this.listFollowUp(nextProps.data);
		}
	},
	listFollowUp(e) {
		$.ajax({
			method: "get",
			dataType: "json",
			crossDomain: false,
			url: globalConfig.context + "/api/admin/customer/toUpdateFollowOneBusiness",
			data: {
				ufbId: e.ufbId
			},
			success: function(data) {
				let thedata = data.data;
				if(!thedata) {
					if(data.error && data.error.length) {
						message.warning(data.error[0].message);
					};
					thedata = {};
				};
				this.setState({
					businessGlossoryIds: thedata.businessGlossoryId,
					followSituations: thedata.followSituation,
					customerStatuss: thedata.customerStatus,
					followTimes: thedata.followTime,
					createTimes: thedata.createTime,
					identifyNames: thedata.identifyName,
					contactTypes: parseInt(thedata.contactType),
					results: thedata.result,
					remarkss: thedata.remarks,
					adminNames: thedata.adminName,
					contactss: thedata.contacts,
					contactMobiles: thedata.contactMobile,
					ufbId: thedata.ufbId,
					followIds: thedata.followId,
				});
			}.bind(this),
		}).always(function() {
			this.setState({
				loading: false
			});
		}.bind(this));
	},
	render(){
		const formItemLayout = {
			labelCol: { span: 8 },
			wrapperCol: { span: 14 },
		};
		return(
			<Modal	
		      footer=''
	          title="业务跟进详情"
	          width='600px'
	          visible={this.state.businessFollowModul}
	          onOk={this.businessFollowCancel}
			  onCancel={this.businessFollowCancel}							          							          
	        >				    
			    <div className="clearfix">
	    			<Form layout="horizontal" id="demand-form">
	    				<Spin spinning={this.state.loading}>
	    					<div className="clearfix">
		    					<FormItem className="half-item"
			                            {...formItemLayout}
			                            label="意向业务名称" >
			                        <span>{getCompanyIntention(this.state.businessGlossoryIds)}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="意向时间" >
			                        <span>{this.state.createTimes}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="客户名称" >
			                        <span>{this.state.identifyNames}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="营销员" >
			                        <span>{this.state.adminNames}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="意向业务进度" >
			                        <span>{getfllowSituation(this.state.followSituations)}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="业务客户状态" >
			                        <span>{getcustomerStatue(this.state.customerStatuss)}</span>
			                    </FormItem>
			                </div>
		                    <div className="clearfix">
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="业务意向说明" >
			                        <span>{this.state.remarkss}</span>
			                    </FormItem>
	                        </div>
	                        <div className="clearfix">
	                        	<div style={{fontSize:'18px',lineHeight:'30px'}}>拜访情况</div>
	                        	<FormItem className="half-item"
			                            {...formItemLayout}
			                            label="拜访方式" >
			                        <span>{getContactType(this.state.contactTypes)}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="联系人" >
			                        <span>{this.state.contactss}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="联系电话" >
			                        <span>{this.state.contactMobiles}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="拜访时间" >
			                        <span>{this.state.followTimes}</span>
			                    </FormItem>
			                    <FormItem className="half-item"
			                            {...formItemLayout}
			                            label="拜访人" >
			                        <span>{this.state.adminNames}</span>
			                    </FormItem> 
			                    <div className="clearfix">
			                    	<FormItem className="half-item"
			                            {...formItemLayout}
			                            label="拜访备注" >
			                        <span>{this.state.results}</span>
			                    </FormItem>
			                    </div>
	                        </div>
		                </Spin>
					</Form>                  
				</div>	                    
		</Modal>
		)
	}
})
export default BusinFollow;