import React from 'react';
import { Pagination, Icon, message, Row, Col, Radio, Checkbox, Input, InputNumber, Button, Table, Spin } from 'antd';
import '../portal.less';
import logoImg from '../../../../image/logo.png';
import searchImg from '../../../../image/search.png';
import demand_sup from '../../../../image/demand_sup.png';
import demand_ico_5 from '../../../../image/demand_ico_5.png';
import demand_ico_3 from '../../../../image/demand_ico_3.png';
import demand_ico_2 from '../../../../image/demand_ico_2.png';
import demand_ico_1 from '../../../../image/demand_ico_1.png';
import uncertify from '../../../../image/demand_ico_6.png';
import certify from '../../../../image/demand_ico_6_atv.png';
import { IndustryObject, getIndustryCategory } from '../../DicIndustryList';
import { demandTypeList } from '../../dataDic';
import { getDemandType } from '../../tools';
import ajax from 'jquery/src/ajax/xhr.js'
import $ from 'jquery/src/ajax';
const Content = React.createClass({
    loadData(pageNo) {
        this.setState({
            loading: true
        });
        switch (this.state.budgetCost) {
            case 1:
                this.state.budgetCostLower = 1;
                this.state.budgetCostUpper = 10;
                break;
            case 2:
                this.state.budgetCostLower = 10;
                this.state.budgetCostUpper = 50;
                break;
            case 3:
                this.state.budgetCostLower = 50;
                this.state.budgetCostUpper = 100;
                break;
            case 4:
                this.state.budgetCostLower = 100;
                this.state.budgetCostUpper = 500;
                break;
            case 5:
                this.state.budgetCostLower = 500;
                this.state.budgetCostUpper = 1000;
                break;
            case 6:
                this.state.budgetCostLower = null;
                this.state.budgetCostUpper = null;
                this.state.sign = 1;
                break;
            case 999:
                this.state.budgetCostLower = null;
                this.state.budgetCostUpper = null;
                this.state.sign = 0;
                break;
        };
        $.ajax({
            method: "get",
            dataType: "json",
            url: globalConfig.context + "/portal/search/demandList",
            data: {
                pageNo: pageNo || 1,
                pageSize: this.state.pagination.pageSize,
                keyword: this.state.keyword,
                demandType: this.state.demandType == 999 ? null : this.state.demandType,
                budgetCostLower: this.state.budgetCostLower, //交易金额下限
                budgetCostUpper: this.state.budgetCostUpper, //交易金额上限
                industryCategoryA: this.state.fieldA || null, //技术领域(行业类别A)
                industryCategoryB: this.state.fieldB == 999 ? null : this.state.fieldB, //技术领域(行业类别B)
                sign: this.state.sign
            },
            success: function (data) {
                let theArr = [];
                if (!data.data || !data.data.list) {
                    if (data.error && data.error.length) {
                        message.warning(data.error[0].message);
                    };
                    data.data = {};
                } else {
                    for (let i = 0; i < data.data.list.length; i++) {
                        let thisdata = data.data.list[i];
                        theArr.push({
                            key: i,
                            id: thisdata.id,
                            serialNumber: thisdata.serialNumber,
                            keyword: thisdata.keyword,
                            dataCategory: thisdata.dataCategory,
                            name: thisdata.name,
                            level: thisdata.level,
                            industryCategory: [thisdata.industryCategoryA, thisdata.industryCategoryB],
                            industryCategoryA: thisdata.industryCategoryA,
                            industryCategoryB: thisdata.industryCategoryB,
                            demandType: thisdata.demandType,
                            budgetCost: thisdata.budgetCost,
                            problemDes: thisdata.problemDes,
                            releaseDate: thisdata.releaseDate,
                            employerName: thisdata.employerName,
                            releaseDateFormattedDate: thisdata.releaseDateFormattedDate
                        });
                    };
                };
                this.state.pagination.defaultCurrent = data.data.pageNo;
                this.state.pagination.total = data.data.totalCount;
                this.setState({
                    dataSource: theArr,
                    pagination: this.state.pagination
                });
            }.bind(this),
        }).done(function (data) {
            this.state.sign = 0;
            if (data.error && data.error.length) {
                message.warning(data.error[0].message);
            };
            this.setState({
                loading: false
            });
        }.bind(this));
    },
    getInitialState() {
        return {
            loading: false,
            showDesc: false,
            industryRadioB: [],
            sign: 0,
            budgetCost: 999,
            budgetCostLower: null,
            budgetCostUpper: null,
            pagination: {
                pageNo: 1,
                pageSize: 15,
                total: 0
            },
            dataSource: []
        };
    },
    componentWillMount() {
        let theArr = [];
        let demandArr = [];
        //行业分类单选项
        theArr.push(
            
{item.employerName}