import React from 'react'; import $ from 'jquery/src/ajax'; import { message, Spin, Input, Button, Form, } from 'antd'; const NewDetailForm = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, textFileList: [], videoFileList: [], }; }, handleSubmit(e,index) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", url: globalConfig.context +"/api/admin/message/mobileMessage", data: { messageCode: values.messageCode, } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('推送成功!'); this.setState({ visible: false }); this.props.handOk(); } else { message.warning(data.error[0].message); } }.bind(this)); } }); }, cancelFun(){ this.props.closeDesc(false,false); }, componentWillMount() { if (this.props.data.id) { } else { this.state.visible=true; this.state.data = {}; }; }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { this.state.textFileList = []; this.state.videoFileList = []; if (nextProps.data.id) { } else { this.state.visible=true; this.state.data = {}; }; this.props.form.resetFields(); }; }, render() { const theData = this.props.data || {}; const { getFieldDecorator } = this.props.form; const FormItem = Form.Item; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; return (
{this.handleSubmit(e,1)}} id="demand-form">
所有用户
{theData.admin?theData.admin:'管理员'}
{getFieldDecorator('messageCode', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.messageCode })()}
) } })); export default NewDetailForm;