import React from 'react';
import { Icon, Modal, message, Spin, Input, Select, DatePicker, Button, Row, Col, Table, Form, Upload } from 'antd';
import './comprehensive.less';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import moment from 'moment';
import { copyrightStateList } from '../../../dataDic.js';
import { companySearch, getCopyrightState, getTime, copyrightDownloadFile, beforeUploadFile, getInUrgentTime, getVacations, getPreview } from '../../../tools.js';
const CopyrightDescForm = Form.create()(React.createClass({
    getInitialState() {
        return {
            visible: false,
            loading: false,
            stateOption: [],
            stateTable: [],
            contactsOption: [],
            vacations: [],
            stateColumns: [{
                title: '申请状态',
                dataIndex: 'status',
                key: 'status',
                render: (text) => { return getCopyrightState(text) }
            }, {
                title: '处理时间',
                dataIndex: 'recordTimeFormattedDate',
                key: 'recordTimeFormattedDate',
            }, {
                title: '负责人',
                dataIndex: 'principal',
                key: 'principal',
            }, {
                title: '操作人',
                dataIndex: 'operator',
                key: 'operator',
            }, {
                title: '备注',
                dataIndex: 'comment',
                key: 'comment',
            }]
        };
    },
    componentWillMount() {
        this.loadData();
        getVacations((data) => { this.setState({ vacations: data }); });
    },
    loadData(uid, id) {
        this.setState({
            loading: true
        });
        $.when($.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            cache: false,
            url: globalConfig.context + "/api/admin/copyright/logs",
            data: {
                id: id || this.props.data.id
            }
        }), $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            cache: false,
            url: globalConfig.context + "/api/admin/getContacts",
            data: {
                uid: uid || this.props.data.uid
            }
        }), $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            cache: false,
            url: globalConfig.context + "/api/admin/copyright/detail",
            data: {
                id: id || this.props.data.id
            }
        })).done((data1, data2, data3) => {
            let _me = this;
            //状态流转table
            this.state.stateTable = [];
            if (data1[0].error && data1[0].error.length) {
                message.warning(data1[0].error[0].message);
            } else {
                data1[0].data.map(function (item, i) {
                    _me.state.stateTable.push({
                        key: i,
                        recordTimeFormattedDate: item.recordTimeFormattedDate,
                        status: item.status,
                        principal: item.principal,
                        operator: item.operator,
                        comment: item.comment
                    });
                });
            };
            //获取联系人
            this.state.contactsOption = [];
            if (data2[0].error && data2[0].error.length) {
                message.warning(data2[0].error[0].message);
            } else {
                for (let item in data2[0].data) {
                    let theData = data2[0].data[item];
                    _me.state.contactsOption.push(