demand.jsx 17 KB

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