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) { e.preventDefault(); this.props.form.validateFields((err, values) => { if(values.companyNamet.length>64){ message.warning('联系人字数不超过64个') return false; }; if(values.telnums.length>13){ message.warning('电话号码字数不超过13个') return false; }; if (!err) { this.setState({ loading: true }); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/customer/addCustomer', data: { contacts:values.companyNamet, societyTag:values.societyTagt, name: values.companyNamet, contactMobile: values.telnums, 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=''; this.state.depatrments=''; this.state.positions=''; this.state.wechats=''; this.state.qqs=''; this.state.emails=''; }, 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 (