import React from 'react';
import { Icon, Button, Input, Select, Spin, Table, Switch, DatePicker, message, Upload, Modal } from 'antd';
import { patentTypeList, patentStateList, provinceArr } from '../../../dataDic.js';
import { getTime, getPatentState, beforeUploadFile, companySearch, getSearchUrl, getPatentType } from '../../../tools.js';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import moment from 'moment';
import './comprehensive.less';
import PatentAdd from './comPatentAdd.jsx';
import PatentDesc from './comPatentDesc.jsx';
const Patent = React.createClass({
    loadData(pageNo) {
        this.state.data = [];
        this.setState({
            loading: true
        });
        $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + "/api/admin/patent/patentList",
            data: {
                page: pageNo || 1,
                pageSize: this.state.pagination.pageSize || null,
                serialNumber: this.state.number || null,
                patentNumber: this.state.patentNumber || null,
                patentName: this.state.patentName || null,
                locationProvince: this.state.province || null,
                uid: this.state.unitId || null,
                contractId: this.state.contractId,
                patentCatagory: this.state.patentType || null,
                patentState: this.state.patentState || null,
                createTime: this.state.createTime || null,
                patentApplicationDate: this.state.acceptTime || null,
                authorizedDate: this.state.authTime || null,
            },
            success: function (data) {
                if (data.error.length || !data.data || !data.data.list) {
                    message.warning(data.error[0].message);
                    return;
                }
                for (let i = 0; i < data.data.list.length; i++) {
                    let thisdata = data.data.list[i];
                    this.state.data.push({
                        key: i,
                        id: thisdata.id,
                        oid: thisdata.oid,
                        uid: thisdata.uid,
                        number: thisdata.serialNumber || '',
                        patentNumber: thisdata.patentNumber || '',
                        unitName: thisdata.unitName || '',
                        patentName: thisdata.patentName || '',
                        patentCatagory: thisdata.patentCatagory ? getPatentType(thisdata.patentCatagory) : '',
                        patentState: thisdata.patentState || '0',
                        patentField: thisdata.patentField || '0',
                        patentDes: thisdata.patentDes || '',
                        patentProryStatementUrl: thisdata.patentProryStatementUrl, //专利代理委托书
                        patentWritingUrl: thisdata.patentWritingUrl, //专利稿件
                        authorizationNoticeUrl: thisdata.authorizationNoticeUrl, //授权通知书
                        patentCertificateUrl: thisdata.patentCertificateUrl, //专利证书
                        lastYearTaxReportUrl: thisdata.lastYearTaxReportUrl, //上年度纳税表
                        patentProryStatementDownloadFileName: thisdata.patentProryStatementDownloadFileName, //专利代理委托书
                        patentWritingDownloadFileName: thisdata.patentWritingDownloadFileName, //专利稿件
                        authorizationNoticeDownloadFileName: thisdata.authorizationNoticeDownloadFileName, //授权通知书
                        patentCertificateDownloadFileName: thisdata.patentCertificateDownloadFileName, //专利证书
                        lastYearTaxReportDownloadFileName: thisdata.lastYearTaxReportDownloadFileName, //上年度纳税表
                        startTime: thisdata.patentApplicationDate,
                        endTime: thisdata.authorizedDate,
                        orgCode: thisdata.orgCode,
                        province: thisdata.locationProvince,
                        companyAddress: thisdata.locationProvince || thisdata.locationCity || thisdata.locationArea ? thisdata.locationProvince + '/' + thisdata.locationCity + '/' + thisdata.locationArea : '',
                        companyContacts: thisdata.contacts, //联系人
                        firstInventorName: thisdata.firstInventorName,
                        firstInventorNationality: thisdata.firstInventorNationality, //国籍
                        firstInventorIdNumber: thisdata.firstInventorIdNumber,   //id
                        firstInventorIsPublish: thisdata.firstInventorIsPublish, //是否公布
                        secondInventorName: thisdata.secondInventorName,
                        secondInventorNationality: thisdata.secondInventorNationality,
                        secondInventorIsPublish: thisdata.secondInventorIsPublish,
                        thirdInventorName: thisdata.thirdInventorName,
                        thirdInventorNationality: thisdata.thirdInventorNationality,
                        thirdInventorIsPublish: thisdata.thirdInventorIsPublish,
                        createTime: thisdata.createTime,   //派单日
                        author: thisdata.author, //撰写人
                        office: thisdata.office, //事务所
                        principal: thisdata.principal, //负责人
                        founder: thisdata.founder, //创建人
                        techPrincipal: thisdata.techPrincipal //技术员
                    });
                };
                this.state.pagination.current = data.data.pageNo;
                this.state.pagination.total = data.data.totalCount;
                this.setState({
                    dataSource: this.state.data,
                    pagination: this.state.pagination
                });
            }.bind(this),
        }).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },
    getOptionList() {
        this.setState({
            loading: true
        });
        $.when($.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + "/api/admin/getUnitNames",
            data: { "pid": this.state.data.id },
        }), $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + "/api/admin/patent/getPrincipal"
        }), $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + "/api/admin/patent/patentStatus"
        })).done((data1, data2, data3) => {
            let _me = this;
            if (!data1[0].data) {
                if (data1[0].error.length) {
                    message.warning(data1[0].error[0].message);
                };
            } else {
                for (var item in data1[0].data) {
                    _me.state.companyOption.push(
                        
                            处理时间: