import React from 'react';
import $ from 'jquery/src/ajax';
import {
	Modal,
	message,
	Spin,
	Upload,
	Button,
	Form,
} from 'antd';
import {getProvince} from '@/NewDicProvinceList';
import '../policy/policy.less';
import {getReleaseStateList,getNewPosition,splitUrl,getNewType} from '@/tools';
const NewDetail = Form.create()(React.createClass({
    getInitialState() {
        return {
            visible: false,
            loading: false,
        };
    },
    loadData(id) {
        this.setState({
            loading: true
        });
        $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context +  '/api/admin/news/detail' ,
            data: {
                id: id
            },
            success: function (data) {
                let thisData = data.data;
                if (!thisData) {
                    if (data.error && data.error.length) {
                        message.warning(data.error[0].message);
                    };
                    thisData = {};
                };
               
                this.setState({
                    id:thisData.id,
                    data: thisData,
                });
            }.bind(this),
        }).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },
   
	cancelFun(){
		this.props.closeDesc();
    },
   
    componentWillMount() {
        if (this.props.data.id) {
            this.loadData(this.props.data.id);
        } else {
            this.state.data = {};
        };
    },
    componentWillReceiveProps(nextProps) {
        if (!this.props.visible && nextProps.visible) {
            this.state.textFileList = [];
            this.state.videoFileList = [];
            if (nextProps.data.id) {
                this.loadData(nextProps.data.id);
            } else {
				this.state.data = {};
            };
            this.props.form.resetFields();
        };
    },
    render() {
        const theData = this.state.data || {};
        const FormItem = Form.Item
        const formItemLayout = {
            labelCol: { span: 6 },
            wrapperCol: { span: 12 },
        };
        return (
			<div className='login'>
			<Form layout="horizontal" id="demand-form">
				<Spin spinning={this.state.loading}>
                    <div className="clearfix">
                        <FormItem className="half-item" {...formItemLayout} label="编号">
                            <span>{theData.biahao}</span>
                        </FormItem>	
                        <FormItem className="half-item" {...formItemLayout} label="创建人">
                            <span>{theData.biahao}</span>
                        </FormItem>	
                    </div>
                    <div>
						<FormItem className="half-item" {...formItemLayout} label="标题">
							<span>{theData.name}</span>
						</FormItem>
					</div>
					<div className="clearfix">
						<FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="消息内容">
							<span>{thisData.dads}</span>
						</FormItem>
					</div>
                    <div className="clearfix">
                        <FormItem labelCol={{ span: 3 }} wrapperCol={{ span: 18 }} label="推送时间">
                            <span>{theData.releaseStatus?'已推送':'未推送'}</span>
                        </FormItem>
                    </div>
				</Spin>
			</Form>    
		</div>
        )
    }
}));
export default NewDetail;




