import React from 'react'; import { Icon, message, Row, Col, Radio, Checkbox, Input, InputNumber, Button, Table, Spin } from 'antd'; import '../portal.less'; 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'; import DemandDesc from './demandDesc'; 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 999: this.state.budgetCostLower = null; this.state.budgetCostUpper = null; 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, //技术领域(行业类别A) industryCategoryB: 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, dataCategory: thisdata.dataCategory, name: thisdata.name, 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.username || thisdata.unitName, 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) { 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: [], budgetCost: 999, pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 10, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, columns: [ { title: '编号', dataIndex: 'serialNumber', key: 'serialNumber', }, { title: '名称', dataIndex: 'name', key: 'name', }, { title: '关键字', dataIndex: 'keyword', key: 'keyword', }, { title: '数据类别', dataIndex: 'dataCategory', key: 'dataCategory', render: text => { switch (text) { case "0": return 个人需求; case "1": return 单位需求; } } }, { title: '需求类型', dataIndex: 'demandType', key: 'demandType', render: text => { return getDemandType(text); } }, { title: '行业分类', dataIndex: 'industryCategory', key: 'industryCategory', render: text => { return getIndustryCategory(text[0], text[1]); } }, { title: '雇主名称', dataIndex: 'employerName', key: 'employerName', }, { title: '预算价格', dataIndex: 'budgetCost', key: 'budgetCost', }, { title: '问题说明', dataIndex: 'problemDes', key: 'problemDes', width: 400 }, { title: '发布时间', dataIndex: 'releaseDateFormattedDate', key: 'releaseDateFormattedDate', } ], dataSource: [] }; }, componentWillMount() { let theArr = []; let demandArr = []; //行业分类单选项 theArr.push( 不限 ); IndustryObject.map(function (item) { theArr.push( {item.label} ); }); //技术类型单选项目 demandArr.push( 不限 ); demandTypeList.map(function (item) { demandArr.push( {item.key} ); }); this.state.industryRadioA = theArr; this.state.demandTypeRadio = demandArr; this.loadData(); }, industryChange(e) { let theArr = []; if (e.target.value !== 999) { theArr.push( 不限 ); IndustryObject.map(function (item1) { if (item1.value == e.target.value) { item1.children.map(function (item2) { theArr.push( {item2.label} ); }); } }); this.state.fieldA = e.target.value; } else { this.state.fieldA = null; }; this.loadData(); this.setState({ industryRadioB: theArr }); }, tableRowClick(record, index) { this.state.RowData = record; this.setState({ showDesc: true }); }, closeDesc(e) { this.setState({ showDesc: e }); }, render() { return (
行业分类 {this.state.industryRadioA} {this.state.industryRadioB.length > 1 ? 行业子分类 { this.state.fieldB = e.target.value; this.loadData() }}> {this.state.industryRadioB} :
} 预算价格 { this.setState({ budgetCost: e.target.value }); this.state.budgetCost = e.target.value; this.loadData(); }}> 不限 1-10万元 10-50万元 50-100万元 100-500万元 500-1000万元 { if (e.target.checked) { this.setState({ budgetCost: null }) } }}>自定义金额 { this.state.budgetCostLower = e.target.value; }} /> { this.state.budgetCostUpper = e.target.value; }} /> 万元 技术类型 { this.setState({ demandType: e.target.value }); this.state.demandType = e.target.value; this.loadData(); }}> {this.state.demandTypeRadio} 关键字 { this.state.keyword = e.target.value; }} /> ) } }); export default Content;