import React from 'react'; import { Icon, Modal, message, Spin, Input, Select, Button, Form ,Col,Cascader} from 'antd'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; import { citySelect, provinceList ,areaSelect} from '@/NewDicProvinceList'; import {socialAttribute,customerSource} from '@/dataDic.js'; const AchievementDetailForm = Form.create()(React.createClass({ getInitialState() { return { loading: false, data: {}, detailApi:'' }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { console.log(values.ProvinceCity) if(values.name.length>64){ message.warning('客户名称字数不超过64个') return false; }; if(!values.ProvinceCity[1]) { message.warning('请选择地区'); return false; }; if(values.content.length>32){ message.warning('联系人字数不超过32个') return false; }; if(values.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: { name: values.name, contacts:values.content, contactMobile:values.telnum, societyTag:values.societyTagt, source:values.customerSource, province:(values.ProvinceCity)[0],//省 city:(values.ProvinceCity)[1],//市 area:(values.ProvinceCity)[2],//区 type:'1' } }).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)); } }); }, componentWillMount() { this.state.name=''; this.state.content=''; this.state.telnum=''; this.state.societyTagt='0'; this.state.customerSource='0' }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.state.name=''; this.state.content=''; this.state.telnum=''; this.state.societyTagt='0'; this.props.form.resetFields(); }; }, render() { const theData = this.state.data || {}; const { getFieldDecorator } = this.props.form; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; return (
注意:请录入真实有效的客户信息
{getFieldDecorator('name', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.name })( )}
{getFieldDecorator('ProvinceCity', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.ProvinceCity })( )}
{getFieldDecorator('content', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.content })( )}
{getFieldDecorator('telnum', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.telnum })( )}
{getFieldDecorator('societyTagt', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.societyTagt })( )}
{getFieldDecorator('customerSource', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.customerSource })( )}
) } })); const AddPerson = Form.create()(React.createClass({ getInitialState() { return { loading: false, data: {}, detailApi:'' }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if(values.companyNamet.length>64){ message.warning('联系人字数不超过64个') return false; }; if(!values.ProvinceCity[1]) { message.warning('请选择地区'); 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, source:values.customerSource, province:(values.ProvinceCity)[0],//省 city:(values.ProvinceCity)[1],//市 area:(values.ProvinceCity)[2],//区 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)); } }); }, componentWillMount() { this.state.companyNamet=''; this.state.telnum=''; this.state.societyTagt='0'; this.state.customerSource='0'; }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.state.companyNamet=''; this.state.telnum=''; this.state.societyTagt='0'; this.state.customerSource='0'; this.props.form.resetFields(); }; }, render() { const theData = this.state.data || {}; const { getFieldDecorator } = this.props.form; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 }, }; return (
注意:请录入真实有效的客户信息
{getFieldDecorator('companyNamet', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.companyNamet })( )}
{getFieldDecorator('ProvinceCity', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.ProvinceCity })( )}
{getFieldDecorator('telnums', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.telnums })( )}
{getFieldDecorator('societyTagt', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.societyTagt })( )}
{getFieldDecorator('customerSource', { rules: [{ required: true, message: '此项为必填项!' }], initialValue: this.state.customerSource })( )}
) } })); const AddIntention = 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 (
{this.props.api.indexOf('Personal')<0?:}
); }, }); export default AddIntention;