import React, { Component } from 'react';
import { Form, Input, Modal, Select, Spin } from "antd";
import {
    getboutique,
} from "@/tools";

const formItemLayout = {
    labelCol: { span: 8 },
    wrapperCol: { span: 14 }
};

const FormItem = Form.Item;

class ProjectDetailsReadOnly extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: false,
            isIso: this.props.infor.commodityName.indexOf("贯标") !== -1,
        }
    }

    render() {
        const {
            commodityName,
            commodityQuantity,
            officialCost,
            costReduction,
            commodityPrice,
            main,
            taskComment,
            ifCertificationFee,//是否包含认证费
            certificationFee,//认证费
            certificationCorporate,//认证费公司
            declarationBatch,//批次
            type,//项目类型  0 正常 1专利 2软著 3审计 4双软 5高新 6商标,
            patentTypeName,//专利类型
            yearSum,//会员总服务年限
            serviceLife,//会员服务年限
            serviceYear,//本次派单
            cSort,//6会员项目
        } = this.props.infor;
        const { isIso } = this.state;
        return (
            <Modal
                maskClosable={false}
                visible={this.props.visible}
                onOk={this.props.onCancel}
                onCancel={this.props.onCancel}
                width="800px"
                title="项目任务详情"
                footer=""
                className="admin-desc-content"
            >
                <Form layout="horizontal" id="demand-form">
                    <div className="clearfix">
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="项目名称"
                        >
                            <span>{commodityName}</span>
                        </FormItem>
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="项目数量"
                        >
                            <span>{commodityQuantity}</span>
                        </FormItem>
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="专利类型"
                            style={{ display: type === 1 ? 'block' : 'none' }}
                        >
                            <span>{patentTypeName}</span>
                        </FormItem>
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="官费"
                            style={{ display: type === 1 ? 'block' : 'none' }}
                        >
                            <span>
                                {officialCost === 0 ? "无官费" : "有官费"}
                            </span>
                        </FormItem>
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="费减"
                            style={{ display: type === 1 ? 'block' : 'none' }}
                        >
                            <span>
                                {costReduction === 0 ? "无费减" : "有费减"}
                            </span>
                        </FormItem>
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="金额(万元)"
                        >
                            <span>{commodityPrice === -1 ? '***' : commodityPrice}</span>
                        </FormItem>
                        <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="主要项目"
                        >
                            <span>{getboutique(String(main))}</span>
                        </FormItem>
                        {type === 5 && <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="企业申报批次"
                        >
                            <span>
                                {
                                    declarationBatch === 1 ? '第一批' :
                                        declarationBatch === 2 ? '第二批' :
                                            declarationBatch === 3 ? '第三批' :
                                                declarationBatch === 4 ? '第四批' : '未知'
                                }
                            </span>
                        </FormItem>}
                        {isIso && <FormItem
                            className="half-item"
                            {...formItemLayout}
                            label="认证费"
                        >
                            <span>
                                {
                                    ifCertificationFee === 1 ? '包含' :
                                        ifCertificationFee === 0 ? '不包含' : '未知'
                                }
                            </span>
                        </FormItem>}
                        {/*{isIso && ifCertificationFee === 1 ?<FormItem*/}
                        {/*    className="half-item"*/}
                        {/*    {...formItemLayout}*/}
                        {/*    label="认证费(万元)"*/}
                        {/*>*/}
                        {/*   <span>{certificationFee || '暂无'}</span>*/}
                        {/*</FormItem> : null}*/}
                        {/*{isIso && ifCertificationFee === 1 ? <FormItem*/}
                        {/*    className="half-item"*/}
                        {/*    {...formItemLayout}*/}
                        {/*    label=""*/}
                        {/*/> : null}*/}
                        {/*{isIso && ifCertificationFee === 1 ? <FormItem*/}
                        {/*    className="half-item"*/}
                        {/*    {...formItemLayout}*/}
                        {/*    label="付款公司名称"*/}
                        {/*>*/}
                        {/*    <span>{certificationCorporate || '暂无'}</span>*/}
                        {/*</FormItem>:null}*/}
                        {
                            cSort == 6 &&
                            <FormItem
                                className="half-item"
                                {...formItemLayout}
                                label="会员总服务年限"
                            >
                                <span>
                                    {
                                        yearSum == null ? "" :
                                            [
                                                { value: 0, key: "" },
                                                { value: 1, key: "一年" },
                                                { value: 2, key: "二年" },
                                                { value: 3, key: "三年" },
                                                { value: 4, key: "四年" },
                                                { value: 5, key: "五年" },
                                            ][yearSum]["key"]
                                    }
                                </span>
                            </FormItem>
                        }
                        {
                            cSort == 6 &&
                            <FormItem
                                className="half-item"
                                {...formItemLayout}
                                label="会员服务年限"
                            >
                                <span>{!!serviceLife && JSON.parse(serviceLife).toString()}</span>
                            </FormItem>
                        }
                        {
                            cSort == 6 &&
                            <FormItem
                                className="half-item"
                                {...formItemLayout}
                                label="本次派单"
                            >
                                <span>{serviceYear}</span>
                            </FormItem>
                        }
                        <div className="clearfix">
                            <FormItem
                                labelCol={{ span: 4 }}
                                wrapperCol={{ span: 16 }}
                                label="项目说明"
                            >
                                <span>{taskComment}</span>
                            </FormItem>
                        </div>
                    </div>
                </Form>
            </Modal>
        );
    }
}

export default ProjectDetailsReadOnly;
