import React from 'react';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import { Form, Spin, message, Modal } from 'antd';
import {getTaskStatus,getProjectName,getLiquidationStatus,getJsyPaymentType,getBonusState} from '@/tools.js';

const BonusDetail=React.createClass({
    getInitialState() {
        return {
            loading: false,
            visible:false,
            showDesc:false,
        };
    },
    onCancel(){
    	this.setState({
    		visible:false
        })
        this.props.closeDesc(false,false);
    },
    onShow() {
		this.setState({
			visible: false,
		});
		this.props.closeDesc(false, true);
	},
    componentWillMount() {
    },
    componentWillReceiveProps(nextProps) {
        if(nextProps.data.orderNo){
            this.setState({data:nextProps.data});
        }
        this.state.visible=nextProps.showDesc;
    },
    render() {
        const theData = this.state.data || {};
        const FormItem = Form.Item;
        const formItemLayout = {
            labelCol: { span: 10 },
            wrapperCol: { span: 12 },
		};
        return (
            <div className="user-content" >
	            <Modal maskClosable={false} visible={this.state.visible}
                        onOk={this.onShow} onCancel={this.onCancel}
                        width='800px'
                        title='任务详情'
                        footer=''
                        className="admin-desc-content">
			            <Form layout="horizontal" onSubmit={(e)=>{this.handleSubmit(e,0)}} >
			                <Spin spinning={this.state.loading}>
                                <div className="clearfix">
                                    <FormItem className="half-item" {...formItemLayout} label="任务编号">
                                        <span>{theData.tid}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="订单编号">
                                        <span>{theData.orderNo}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="任务名称">
                                        <span>{theData.commodityName}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="任务负责人">
                                        <span>{theData.targetName}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="任务状态">
                                        <span>{getTaskStatus(theData.taskStatus)}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="任务数量">
                                        <span>{theData.commodityQuantity}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="项目状态">
                                        <span>{getProjectName(theData.projectStatus)}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="受理日期">
							            <span>{theData.acceptTime}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="评审日期">
							            <span>{theData.reviewTime}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="下证日期">
							            <span>{theData.licenceTime}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="订单结算状态">
                                        <span>{getLiquidationStatus(theData.liquidationStatus)}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="发放类型">
                                        <span>{getJsyPaymentType(theData.bonusSubject)}</span>
                                    </FormItem>
                                    <FormItem className="half-item" {...formItemLayout} label="发放状态">
                                        <span>{getBonusState(theData.grantStatus)}</span>
                                    </FormItem>
                                </div>
			                </Spin>
			            </Form>
			    </Modal>
            </div>
        );
    }
});

export default Form.create()(BonusDetail);
