demand.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. import React from 'react';
  2. import { Carousel, Pagination, Icon, message, Row, Col, Radio, Checkbox, Input, InputNumber, Button, Table, Spin } from 'antd';
  3. import '../portal.less';
  4. import logoImg from '../../../../image/logo.png';
  5. import searchImg from '../../../../image/search.png';
  6. import demand_sup from '../../../../image/demand_sup.png';
  7. import demand_ico_5 from '../../../../image/demand_ico_5.png';
  8. import demand_ico_3 from '../../../../image/demand_ico_3.png';
  9. import demand_ico_2 from '../../../../image/demand_ico_2.png';
  10. import demand_ico_1 from '../../../../image/demand_ico_1.png';
  11. import uncertify from '../../../../image/demand_ico_6.png';
  12. import certify from '../../../../image/demand_ico_6_atv.png';
  13. import { IndustryObject, getIndustryCategory } from '../../DicIndustryList';
  14. import { demandTypeList } from '../../dataDic';
  15. import { getDemandType } from '../../tools';
  16. import ajax from 'jquery/src/ajax/xhr.js'
  17. import $ from 'jquery/src/ajax';
  18. const Content = React.createClass({
  19. loadData(pageNo) {
  20. this.setState({
  21. loading: true
  22. });
  23. switch (this.state.budgetCost) {
  24. case 1:
  25. this.state.budgetCostLower = 1;
  26. this.state.budgetCostUpper = 10;
  27. break;
  28. case 2:
  29. this.state.budgetCostLower = 10;
  30. this.state.budgetCostUpper = 50;
  31. break;
  32. case 3:
  33. this.state.budgetCostLower = 50;
  34. this.state.budgetCostUpper = 100;
  35. break;
  36. case 4:
  37. this.state.budgetCostLower = 100;
  38. this.state.budgetCostUpper = 500;
  39. break;
  40. case 5:
  41. this.state.budgetCostLower = 500;
  42. this.state.budgetCostUpper = 1000;
  43. break;
  44. case 999:
  45. this.state.budgetCostLower = null;
  46. this.state.budgetCostUpper = null;
  47. break;
  48. }
  49. $.ajax({
  50. method: "get",
  51. dataType: "json",
  52. url: globalConfig.context + "/portal/search/demandList",
  53. data: {
  54. pageNo: pageNo || 1,
  55. pageSize: this.state.pagination.pageSize,
  56. keyword: this.state.keyword,
  57. demandType: this.state.demandType == 999 ? null : this.state.demandType,
  58. budgetCostLower: this.state.budgetCostLower, //交易金额下限
  59. budgetCostUpper: this.state.budgetCostUpper, //交易金额上限
  60. industryCategoryA: this.state.fieldA, //技术领域(行业类别A)
  61. industryCategoryB: this.state.fieldB == 999 ? null : this.state.fieldB, //技术领域(行业类别B)
  62. },
  63. success: function (data) {
  64. let theArr = [];
  65. if (!data.data || !data.data.list) {
  66. if (data.error && data.error.length) {
  67. message.warning(data.error[0].message);
  68. };
  69. } else {
  70. for (let i = 0; i < data.data.list.length; i++) {
  71. let thisdata = data.data.list[i];
  72. theArr.push({
  73. key: i,
  74. id: thisdata.id,
  75. serialNumber: thisdata.serialNumber,
  76. keyword: thisdata.keyword,
  77. dataCategory: thisdata.dataCategory,
  78. name: thisdata.name,
  79. level: thisdata.level,
  80. industryCategory: [thisdata.industryCategoryA, thisdata.industryCategoryB],
  81. industryCategoryA: thisdata.industryCategoryA,
  82. industryCategoryB: thisdata.industryCategoryB,
  83. demandType: thisdata.demandType,
  84. budgetCost: thisdata.budgetCost,
  85. problemDes: thisdata.problemDes,
  86. releaseDate: thisdata.releaseDate,
  87. employerName: thisdata.username || thisdata.unitName,
  88. releaseDateFormattedDate: thisdata.releaseDateFormattedDate
  89. });
  90. };
  91. };
  92. this.state.pagination.defaultCurrent = data.data.pageNo;
  93. this.state.pagination.total = data.data.totalCount;
  94. this.setState({
  95. dataSource: theArr,
  96. pagination: this.state.pagination
  97. });
  98. }.bind(this),
  99. }).done(function (data) {
  100. if (data.error && data.error.length) {
  101. message.warning(data.error[0].message);
  102. };
  103. this.setState({
  104. loading: false
  105. });
  106. }.bind(this));
  107. },
  108. getInitialState() {
  109. return {
  110. loading: false,
  111. showDesc: false,
  112. industryRadioB: [],
  113. budgetCost: 999,
  114. pagination: {
  115. pageNo: 1,
  116. pageSize: 15,
  117. total: 0
  118. },
  119. dataSource: []
  120. };
  121. },
  122. componentWillMount() {
  123. let theArr = [];
  124. let demandArr = [];
  125. //行业分类单选项
  126. theArr.push(
  127. <Radio.Button key={999} value={999}>不限</Radio.Button>
  128. );
  129. IndustryObject.map(function (item) {
  130. theArr.push(
  131. <Radio.Button key={item.value} value={item.value}>{item.label}</Radio.Button>
  132. );
  133. });
  134. //技术类型单选项目
  135. demandArr.push(
  136. <Radio.Button key={999} value={999}>不限</Radio.Button>
  137. );
  138. demandTypeList.map(function (item) {
  139. demandArr.push(
  140. <Radio.Button key={item.value} value={item.value}>{item.key}</Radio.Button>
  141. );
  142. });
  143. this.state.industryRadioA = theArr;
  144. this.state.demandTypeRadio = demandArr;
  145. this.loadData();
  146. },
  147. industryChange(e) {
  148. let theArr = [];
  149. if (e.target.value !== 999) {
  150. theArr.push(
  151. <Radio.Button key={999} value={999}>不限</Radio.Button>
  152. );
  153. IndustryObject.map(function (item1) {
  154. if (item1.value == e.target.value) {
  155. item1.children.map(function (item2) {
  156. theArr.push(
  157. <Radio.Button key={item2.value} value={item2.value}>{item2.label}</Radio.Button>
  158. );
  159. });
  160. }
  161. });
  162. this.state.fieldA = e.target.value;
  163. } else {
  164. this.state.fieldA = null;
  165. };
  166. this.loadData();
  167. this.setState({ industryRadioB: theArr });
  168. },
  169. tableRowClick(record, index) {
  170. window.open(globalConfig.context + '/portal/detail/demandDetail.html?id=' + record.id + '&type=' + record.dataCategory);
  171. },
  172. closeDesc(e) {
  173. this.setState({
  174. showDesc: e
  175. });
  176. },
  177. render() {
  178. const { pageNo, pageSize, total } = this.state.pagination;
  179. const _me = this;
  180. return (
  181. <div className="portal-body">
  182. <div className="portal-nav clearfix">
  183. <div className="nav-logoBox">
  184. <img src={logoImg} alt="" />
  185. </div>
  186. <ul className="nav-list clearfix">
  187. <li className={this.props.searchType == 'achievement' ? 'active' : ''}><a href={"/portal/search/achievement.html"}>科技成果</a></li>
  188. <li className={this.props.searchType == 'demand' ? 'active' : ''}><a href={"/portal/search/demand.html"}>科技需求</a></li>
  189. </ul>
  190. <div className="nav-search">
  191. <Input onChange={(e) => { this.state.keyword = e.target.value; }} />
  192. <Button onClick={() => { this.loadData() }}>
  193. <img src={searchImg} alt="" />
  194. </Button>
  195. </div>
  196. </div>
  197. <Carousel autoplay className="portal-carousel">
  198. <div className="slide-box"><img src={slideImg} alt="" /></div>
  199. <div className="slide-box"><img src={slideImg} alt="" /></div>
  200. <div className="slide-box"><img src={slideImg} alt="" /></div>
  201. <div className="slide-box"><img src={slideImg} alt="" /></div>
  202. </Carousel>
  203. <div className="portal-content">
  204. <Row className="search-criteria">
  205. <Col className="search-title" span={2}>
  206. <span>行业分类</span>
  207. </Col>
  208. <Col className="search-select" span={22}>
  209. <Radio.Group defaultValue={999} onChange={this.industryChange}>
  210. {this.state.industryRadioA}
  211. </Radio.Group>
  212. </Col>
  213. </Row>
  214. {this.state.industryRadioB.length > 1 ? <Row className="search-criteria">
  215. <Col className="search-title" span={2}>
  216. <span>行业子分类</span>
  217. </Col>
  218. <Col className="search-select" span={22}>
  219. <Radio.Group defaultValue={999} onChange={(e) => { this.state.fieldB = e.target.value; this.loadData() }}>
  220. {this.state.industryRadioB}
  221. </Radio.Group>
  222. </Col>
  223. </Row> : <div></div>}
  224. <Row className="search-criteria">
  225. <Col className="search-title" span={2}>
  226. <span>预算价格</span>
  227. </Col>
  228. <Col className="search-select" span={12}>
  229. <Radio.Group value={this.state.budgetCost}
  230. onChange={(e) => {
  231. this.setState({
  232. budgetCost: e.target.value
  233. });
  234. this.state.budgetCost = e.target.value;
  235. this.loadData();
  236. }}>
  237. <Radio.Button value={999}>不限</Radio.Button>
  238. <Radio.Button value={1}>1-10万元</Radio.Button>
  239. <Radio.Button value={2}>10-50万元</Radio.Button>
  240. <Radio.Button value={3}>50-100万元</Radio.Button>
  241. <Radio.Button value={4}>100-500万元</Radio.Button>
  242. <Radio.Button value={5}>500-1000万元</Radio.Button>
  243. </Radio.Group>
  244. </Col>
  245. <Col span={10}>
  246. <Checkbox checked={!this.state.budgetCost} onChange={(e) => { if (e.target.checked) { this.setState({ budgetCost: null }) } }}>自定义金额</Checkbox>
  247. <InputNumber style={{ width: 80 }} disabled={Boolean(this.state.budgetCost)} onChange={(e) => { this.state.budgetCostLower = e.target.value; }} />
  248. <span> 到 </span>
  249. <InputNumber style={{ width: 80 }} disabled={Boolean(this.state.budgetCost)} onChange={(e) => { this.state.budgetCostUpper = e.target.value; }} />
  250. <span> 万元</span>
  251. <Button style={{ marginLeft: '20px' }} disabled={Boolean(this.state.budgetCost)} onClick={this.loadData}>确定</Button>
  252. </Col>
  253. </Row>
  254. <Row className="search-criteria">
  255. <Col className="search-title" span={2}>
  256. <span>技术类型</span>
  257. </Col>
  258. <Col className="search-select" span={22}>
  259. <Radio.Group defaultValue={999} onChange={(e) => {
  260. this.setState({
  261. demandType: e.target.value
  262. });
  263. this.state.demandType = e.target.value;
  264. this.loadData();
  265. }}>
  266. {this.state.demandTypeRadio}
  267. </Radio.Group>
  268. </Col>
  269. </Row>
  270. <Spin spinning={this.state.loading} style={{ marginBottom: '40px' }}>
  271. <div className='detail_interest_sub'>
  272. {this.state.dataSource.map((item) => {
  273. return <li key={item.id}>
  274. <div className="interest_list_title">
  275. <img src={demand_sup} alt="" />
  276. <span>{item.name}</span>
  277. <div className="interest_list_confirm">
  278. <span>{item.level ? '身份已验证' : '身份未验证'}</span>
  279. <img src={item.level ? certify : uncertify} alt="" />
  280. </div>
  281. </div>
  282. <div className="detial_sub">
  283. <span className="detial_sub_icon">
  284. <img src={demand_ico_5} alt="需求" />
  285. </span>
  286. <span className="detial_sub_title">需求: </span>
  287. <span className="detial_sub_text">{item.problemDes}</span>
  288. </div>
  289. <div className="detial_sub">
  290. <span className="detial_sub_icon">
  291. <img src={demand_ico_3} alt="预算" />
  292. </span>
  293. <span className="detial_sub_title">预算: </span>
  294. <span className="money_text">{item.budgetCost ? item.budgetCost + ' 元' : '价格面议'}</span>
  295. </div>
  296. <div className="detial_sub">
  297. <span className="detial_sub_icon">
  298. <img src={demand_ico_2} alt="类型" />
  299. </span>
  300. <span className="detial_sub_title">类型: </span>
  301. <span className="detial_sub_text">{getDemandType(item.demandType)}</span>
  302. </div>
  303. <div className="detial_sub">
  304. <span className="detial_sub_icon">
  305. <img src={demand_ico_1} alt="行业" />
  306. </span>
  307. <span className="detial_sub_title">行业: </span>
  308. <span className="detial_sub_text">{getIndustryCategory(item.industryCategoryA, item.industryCategoryB)}</span>
  309. </div>
  310. </li>
  311. })}
  312. </div>
  313. <Pagination style={{ float: 'right' }}
  314. onChange={(e) => { this.loadData(e); }}
  315. total={total}
  316. showTotal={() => { return '共' + total + '条数据' }}
  317. current={pageNo}
  318. pageSize={pageSize} />
  319. </Spin>
  320. </div >
  321. </div>
  322. )
  323. }
  324. });
  325. export default Content;