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, auditStatus: 0, textFileList: [], videoFileList: [], }; }, getPictureUrl(e) { this.setState({ pictureUrl: e }); }, handleSubmit(e,index) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }); let hours =new Date(), year = hours.getFullYear(), month = (hours.getMonth()+1)<10?'0'+(hours.getMonth()+1):(hours.getMonth()+1), day = hours.getDate()<10?'0'+hours.getDate():hours.getDate(), hour=hours.getHours()<10?'0'+hours.getHours():hours.getHours(), mins = hours.getMinutes()<10?'0'+hours.getMinutes():hours.getMinutes(), sec = hours.getSeconds()<10?'0'+hours.getSeconds():hours.getSeconds(); let times = year+'-'+month+'-'+day+' '+hour+':'+mins+':'+sec; $.ajax({ method: "post", dataType: "json", async:true, url: this.props.data.id?globalConfig.context +"/api/admin/message/updMessageById":globalConfig.context +"/api/admin/message/createMyMessage", data: { subject:0, id: this.props.data.id, title: values.title, subject:0, //消息类别 0-系统消息 isDraft:index=='1'?1:0, //是否草稿 0-否 1-是 deleteSign:0, //删除标识 0-否 ,1-是 isSend:index=='2'?1:0, //是否发送0-否 1-是 body:values.body, messageCreateTime:!(this.props.data.id)?times:'null' } }).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">
app站内消息 {this.props.data&&this.props.data.id?
{theData.admin?theData.admin:'管理员'}
:''}
{getFieldDecorator('title', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.title })()}
{getFieldDecorator('body', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.body })()}
{this.props.data&&this.props.data.id?
{theData.createTime}
:''}
{this.props.data&&this.props.data.id?:''}
) } })); export default NewDetailForm;