| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 | import React from 'react';import { Icon,  Modal, message,  Spin, Input, Select, Button, Form } from 'antd';import './myClient.less';import ajax from 'jquery/src/ajax/xhr.js';import $ from 'jquery/src/ajax';import {socialAttribute} from '../../../dataDic.js';const AchievementDetailForm = Form.create()(React.createClass({    getInitialState() {        return {            loading: false,            data: {},                   };    },    handleSubmit(e) {    	if(this.state.companyNamet.length>64){    		message.warning('联系人字数不超过64个')    		return false;    	};    	if(this.state.telnum.length>13){    		message.warning('电话号码字数不超过13个')    		return false;    	};        e.preventDefault();        this.props.form.validateFields((err, values) => {                                             if (!err) {                this.setState({                    loading: true                });                $.ajax({                    method: "POST",                    dataType: "json",                    crossDomain: false,                    url: globalConfig.context + '/api/admin/customer/addCu',                    data: {                        name: values.companyNamet,                         contactMobile: values.telnum,                        depatrment:this.state.depatrments,                        position:this.state.positions,                        wechat:this.state.wechats,                        qq:this.state.qqs,                        email:this.state.emails,                        type:'0'                    }                }).done(function (data) {                     this.setState({                        loading: false                    });                    if (!data.error.length) {                        message.success('保存成功!');                        this.props.handleOk();                    } else {                        message.warning(data.error[0].message);                    }                }.bind(this));            }        });    },	//去完善    addContent(){    	let telnum=this.state.telnum;    	let companyName=this.state.companyNamet;    	let content=this.state.content;    	if(!telnum||!companyName||!content){    		message.warning('此3项都要填');    	}else{    		this.props.newmodal(true);    		this.props.closeDesc(false);    	}	    },    componentWillMount() {        this.state.companyNamet='';    	this.state.telnum='';    },    componentWillReceiveProps(nextProps) {        if (!this.props.visible && nextProps.visible) {            this.state.companyNamet='';	    	this.state.telnum='';            this.props.form.resetFields();         };    },        render() {        const theData = this.state.data || {};        const { getFieldDecorator } = this.props.form;        const FormItem = Form.Item        const formItemLayout = {            labelCol: { span: 8 },            wrapperCol: { span: 14 },        };          return (        <div>            <Form horizontal onSubmit={this.handleSubmit} id="demand-form">                <Spin spinning={this.state.loading}>                    <div className="clearfix">                    	<FormItem className="half-item"	                            {...formItemLayout}	                            label="客户姓名" >   	                           {getFieldDecorator('companyNamet', {	                                rules: [{ required: true, message: '此项为必填项!' }],	                                initialValue: this.state.companyNamet                                })(                                    <Input placeholder="客户姓名" />                                )} 	                    </FormItem>                    	<FormItem className="half-item"	                            {...formItemLayout}	                            label="联系电话" >	                    		{getFieldDecorator('telnum', {	                                rules: [{ required: true, message: '此项为必填项!' }],	                                initialValue: this.state.telnum                                })(                                    <Input placeholder="联系电话" />                                )} 	                    </FormItem>	                    <FormItem className="half-item"	                            {...formItemLayout}	                            label="联系人部门" >	                              <Input value={this.state.depatrments} placeholder="联系人部门"  	                                    onChange={(e) => { this.setState({ depatrments: e.target.value }); }} />	                    </FormItem>	                    <FormItem className="half-item"	                            {...formItemLayout}	                            label="联系人职务" >	                              <Input value={this.state.positions} placeholder="联系人职务"  	                                    onChange={(e) => { this.setState({ positions: e.target.value }); }} />	                    </FormItem>	                    <FormItem className="half-item"	                            {...formItemLayout}	                            label="微信" >	                              <Input value={this.state.wechats} placeholder="微信"  	                                    onChange={(e) => { this.setState({ wechats: e.target.value }); }} />	                    </FormItem>	                    <FormItem className="half-item"	                            {...formItemLayout}	                            label="联系人QQ" >	                              <Input value={this.state.qqs} placeholder="联系人QQ"  	                                    onChange={(e) => { this.setState({ qqs: e.target.value }); }} />	                    </FormItem>	                    <FormItem className="half-item"	                            {...formItemLayout}	                            label="电子邮箱" >	                              <Input value={this.state.emails} placeholder="电子邮箱"  	                                    onChange={(e) => { this.setState({ emails: e.target.value }); }} />	                    </FormItem>                    </div>                    <FormItem wrapperCol={{ span: 12, offset: 4 }}>                        <Button className="set-submit" type="primary" htmlType="submit">保存</Button>                          {/*<Button className="set-submit" type="primary"  onClick={(e)=>{this.addContent();this.props.closeDesc}}>去完善</Button>*/}                        <Button className="set-submit" type="ghost" onClick={this.props.closeDesc}>取消</Button>                    </FormItem>                 </Spin>            </Form >    	</div>        )    }}));const CustomerDetail = React.createClass({    getInitialState() {        return {            visible: false,            tabsKey: 1,            loading: false,                       dataSource: [],        };    },        handleCancel(e) {        this.setState({            visible: false,        });        this.props.closeDesc(false);    },    handleOk(e) {        this.setState({            visible: false,        });        this.props.closeDesc(false, true);    },        componentWillReceiveProps(nextProps) {        if (!this.state.visible && nextProps.showDesc) {            this.state.tabsKey = "1";        };        this.state.visible = nextProps.showDesc;     },    render() {                    return (                <div className="patent-desc">                    <Modal maskClosable={false} visible={this.state.visible}                        onOk={this.checkPatentProcess} onCancel={this.handleCancel}                        width='800px'                        title='新建客户'                                               footer=''                        className="admin-desc-content">                        <Spin spinning={this.state.loading}>                                           <AchievementDetailForm                                data={this.props.data}                                 newmodal={this.props.newmodal}                                closeDesc={this.handleCancel}                                visible={this.state.visible}                                handleOk={this.handleOk} />                        </Spin>                    </Modal>                </div>            );            },});export default CustomerDetail;
 |