import React from 'react';
import { Rate, Icon, message, Row, Col, Radio, Checkbox, Input, InputNumber, Button, Pagination, Spin } from 'antd';
import '../portal.less';
import logoImg from '../../../../image/logo.png';
import searchImg from '../../../../image/search.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 achievement_ico_1 from '../../../../image/achievement_ico_1.png';
import achievement_ico_2 from '../../../../image/achievement_ico_2.png';
import uncertify from '../../../../image/demand_ico_6.png';
import certify from '../../../../image/demand_ico_6_atv.png';
import score_ioc from '../../../../image/score_ioc.png';
import { IndustryObject, getIndustryCategory } from '../../DicIndustryList';
import { achievementCategoryList, transferModeList, maturityList } from '../../dataDic';
import { getAchievementCategory, getTransferMode, getMaturity } 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.transferPrice) {
            case 1:
                this.state.transferPriceLower = 1;
                this.state.transferPriceUpper = 10;
                break;
            case 2:
                this.state.transferPriceLower = 10;
                this.state.transferPriceUpper = 50;
                break;
            case 3:
                this.state.transferPriceLower = 50;
                this.state.transferPriceUpper = 100;
                break;
            case 4:
                this.state.transferPriceLower = 100;
                this.state.transferPriceUpper = 500;
                break;
            case 5:
                this.state.transferPriceLower = 500;
                this.state.transferPriceUpper = 1000;
                break;
            case 6:
                this.state.bargainingMode = 0;
                break;
            case 999:
                this.state.transferPriceLower = null;
                this.state.transferPriceUpper = null;
                this.state.bargainingMode = null;
                break;
        }
        $.ajax({
            method: "get",
            dataType: "json",
            url: globalConfig.context + "/portal/search/achievementList",
            data: {
                pageNo: pageNo || 1,
                pageSize: this.state.pagination.pageSize,
                category: this.state.category == 999 ? null : this.state.category, //技术类型
                keyword: this.state.keyword,
                maturity: this.state.maturity == 999 ? null : this.state.maturity, //成熟度
                transferPriceLower: this.state.transferPriceLower, //交易金额下限
                transferPriceUpper: this.state.transferPriceUpper, //交易金额上限
                bargainingMode: this.state.bargainingMode,
                transferMode: this.state.transferMode == 999 ? null : this.state.transferMode, //交易方式
                fieldA: this.state.fieldA, //技术领域(行业类别A)
                fieldB: this.state.fieldB == 999 ? null : this.state.fieldB, //技术领域(行业类别B)
            },
            success: function (data) {
                let theArr = [];
                if (!data.data || !data.data.list) {
                    if (data.error && data.error.length) {
                        message.warning(data.error[0].message);
                    };
                } 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,
                            level: thisdata.level,
                            name: thisdata.name,
                            dataCategory: thisdata.dataCategory,
                            category: thisdata.category,
                            ownerName: thisdata.ownerName,
                            releaseDate: thisdata.releaseDate,
                            ownerType: thisdata.ownerType,
                            fieldA: thisdata.fieldA,
                            fieldB: thisdata.fieldB,
                            field: [thisdata.fieldA, thisdata.fieldB],
                            transferPrice: thisdata.transferPrice,
                            maturity: thisdata.maturity,
                            transferMode: thisdata.transferMode,
                            releaseDateFormattedDate: thisdata.releaseDateFormattedDate
                        });
                    };
                };
                this.state.pagination.pageNo = data.data.pageNo;
                this.state.pagination.total = data.data.totalCount;
                this.setState({
                    dataSource: theArr,
                    pagination: this.state.pagination
                });
            }.bind(this),
        }).done(function (data) {
            if (data.error && data.error.length) {
                message.warning(data.error[0].message);
            };
            this.setState({
                loading: false
            });
            this.state.bargainingMode = 1;
        }.bind(this));
    },
    getInitialState() {
        return {
            loading: false,
            showDesc: false,
            industryRadioB: [],
            transferPrice: 999,
            pagination: {
                pageNo: 1,
                pageSize: 12,
                total: 0
            },
            dataSource: []
        };
    },
    componentWillMount() {
        let theArr = [];
        let theCategoryArr = [], theTransferModeArr = [], theMaturityArr = [];
        //行业分类单选项
        theArr.push(
            
{item.name}
{item.ownerName}