import React from 'react'; import { Modal, message, layout, Spin, Input, Button, Form, Row, Col, Radio, Select } from 'antd'; import ajax from 'jquery/src/ajax/xhr.js'; import $ from 'jquery/src/ajax'; const FormItem = Form.Item; const AddContact = React.createClass({ getInitialState() { return { addcontactModul: false, major: 0, } }, addcontactModulOK() { this.setState({ addcontactModul: false }) this.props.closeFollow(true, true) }, addcontactModulcancel() { this.setState({ addcontactModul: false }) this.props.closeFollow(false, false) }, //新增联系人保存函数 submitcontactman(e) { e.preventDefault(); if (/.*[\u4e00-\u9fa5]+.*$/.test(this.state.newname)) { } else { message.error("请填写正确的姓名,且至少包含一个汉字"); return; }; // if (this.state.newmobile.length != 11) { // message.error('请填写正确的手机号码'); // return // } if (!(/^1[3-9]\d{9}$/.test(this.state.newmobile))) { message.error('请填写正确的手机号码'); return } if (/.*[\u4e00-\u9fa5]+.*$/.test(this.state.newdepatrment)) { } else { message.error("请填写正确的部门,且至少包含一个汉字"); return; }; if (/.*[\u4e00-\u9fa5]+.*$/.test(this.state.newposition)) { } else { message.error("请填写正确的职位,且至少包含一个汉字"); return; }; this.setState({ loading: true }) $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/addOneContact", data: { uid: this.state.uid, name: this.state.newname, mobile: this.state.newmobile, email: this.state.newemail, fixedTel: this.state.fixedTelModal, major: this.state.major, wechat: this.state.newwechat, department: this.state.newdepatrment, position: this.state.newposition, sex: this.state.newsex, qq: this.state.newqq }, success: function (data) { if (!data.error.length) { message.success('添加成功') this.addcontactModulOK() this.setState({ loading: false, }) } else { message.warning(data.error[0].message); }; }.bind(this) }); }, componentWillReceiveProps(nextProps) { if (nextProps.addcontactModul && nextProps.uids) { this.setState({ newsex: undefined, newname: '', newmobile: '', newwechat: '', newqq: '', newdepatrment: '', newposition: '', newemail: '', fixedTelModal: '', major: 0, addcontactModul: true, uid: nextProps.uids, loading: false }) }; }, render() { const maList = !this.props.isLimit ? [, ] : [] return (
*姓名: { this.setState({ newname: e.target.value }); }} /> *手机: { this.setState({ newmobile: e.target.value }); }} /> *部门: { this.setState({ newdepatrment: e.target.value }); }} /> *职位: { this.setState({ newposition: e.target.value }); }} /> 微信: { this.setState({ newwechat: e.target.value }); }} /> Q Q: { this.setState({ newqq: e.target.value }); }} /> 邮箱: { this.setState({ newemail: e.target.value }) }} /> 座机: { this.setState({ fixedTelModal: e.target.value }) }} /> 主要联系人: 性别: { this.setState({ newsex: e.target.value }); }} >
); } }) export default AddContact;