demand.jsx 17 KB

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