techDemand.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js';
  4. import $ from 'jquery/src/ajax';
  5. import moment from 'moment';
  6. import './techDemand.less';
  7. import TechDemandDesc from './techDemandDesc.jsx';
  8. import { provinceArr, demandTypeList } from '../../dataDic.js';
  9. import { companySearch, getDemandType } from '../../tools.js';
  10. const DemandList = React.createClass({
  11. loadData(pageNo, apiUrl) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "get",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. serialNumber: this.state.serialNumber,
  25. name: this.state.name,
  26. keyword: this.state.keyword,
  27. infoSources: this.state.infoSources ? Number(this.state.infoSources) : undefined,
  28. demandType: this.state.demandType ? Number(this.state.demandType) : undefined,
  29. //username: this.state.username,
  30. status: this.state.status ? Number(this.state.status) : undefined,
  31. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined,
  32. validityPeriodStartDate: this.state.validityPeriodDate[0],
  33. validityPeriodEndDate: this.state.validityPeriodDate[1],
  34. releaseDateStartDate: this.state.releaseDate[0],
  35. releaseDateEndDate: this.state.releaseDate[1],
  36. },
  37. success: function (data) {
  38. let theArr = [];
  39. if (!data.data && !data.data.list) {
  40. if (data.error && data.error.length) {
  41. message.warning(data.error[0].message);
  42. };
  43. } else {
  44. for (let i = 0; i < data.data.list.length; i++) {
  45. let thisdata = data.data.list[i];
  46. theArr.push({
  47. key: i,
  48. id: thisdata.id,
  49. serialNumber: thisdata.serialNumber,
  50. dataCategory: thisdata.dataCategory,
  51. name: thisdata.name,
  52. keyword: thisdata.keyword,
  53. infoSources: thisdata.infoSources,
  54. username: thisdata.username,
  55. demandType: thisdata.demandType,
  56. validityPeriod: thisdata.validityPeriod,
  57. employerName: thisdata.employerName,
  58. employerId: thisdata.employerId,
  59. province: thisdata.province,
  60. status: thisdata.status,
  61. releaseStatus: thisdata.releaseStatus,
  62. releaseDate: thisdata.releaseDate,
  63. principalId: thisdata.principalId,
  64. validityPeriodFormattedDate: thisdata.validityPeriodFormattedDate,
  65. releaseDateFormattedDate: thisdata.releaseDateFormattedDate
  66. });
  67. };
  68. }
  69. this.state.pagination.current = data.data.pageNo;
  70. this.state.pagination.total = data.data.totalCount;
  71. this.setState({
  72. dataSource: theArr,
  73. pagination: this.state.pagination
  74. });
  75. }.bind(this),
  76. }).always(function () {
  77. this.setState({
  78. loading: false
  79. });
  80. }.bind(this));
  81. },
  82. getInitialState() {
  83. return {
  84. searchMore: true,
  85. validityPeriodDate: [],
  86. releaseDate: [],
  87. selectedRowKeys: [],
  88. selectedRows: [],
  89. loading: false,
  90. pagination: {
  91. defaultCurrent: 1,
  92. defaultPageSize: 10,
  93. showQuickJumper: true,
  94. pageSize: 10,
  95. onChange: function (page) {
  96. this.loadData(page);
  97. }.bind(this),
  98. showTotal: function (total) {
  99. return '共' + total + '条数据';
  100. }
  101. },
  102. columns: [
  103. {
  104. title: '编号',
  105. dataIndex: 'serialNumber',
  106. key: 'serialNumber',
  107. }, {
  108. title: '需求名称',
  109. dataIndex: 'name',
  110. key: 'name',
  111. }, {
  112. title: '关键字',
  113. dataIndex: 'keyword',
  114. key: 'keyword',
  115. }, {
  116. title: '需求类型',
  117. dataIndex: 'demandType',
  118. key: 'demandType',
  119. render: text => { return getDemandType(text); }
  120. }, {
  121. title: '信息来源',
  122. dataIndex: 'infoSources',
  123. key: 'infoSources',
  124. render: text => {
  125. switch (text) {
  126. case "0":
  127. return <span>平台采集</span>;
  128. case "1":
  129. return <span>客户发布</span>
  130. }
  131. }
  132. }, {
  133. title: '雇主名称',
  134. dataIndex: 'username',
  135. key: 'username',
  136. }, {
  137. title: '需求状态',
  138. dataIndex: 'status',
  139. key: 'status',
  140. render: text => {
  141. switch (text) {
  142. case "0":
  143. return <span>进行中</span>;
  144. case "1":
  145. return <span>未解决</span>;
  146. case "2":
  147. return <span>已解决</span>;
  148. }
  149. }
  150. }, {
  151. title: '有效期限',
  152. dataIndex: 'validityPeriodFormattedDate',
  153. key: 'validityPeriodFormattedDate',
  154. }, {
  155. title: '发布时间',
  156. dataIndex: 'releaseDateFormattedDate',
  157. key: 'releaseDateFormattedDate',
  158. }, {
  159. title: '管理员',
  160. dataIndex: 'principalId',
  161. key: 'principalId',
  162. }
  163. ],
  164. dataSource: [],
  165. searchTime: [,]
  166. };
  167. },
  168. getCompanyList() {
  169. this.setState({
  170. loading: true
  171. });
  172. $.ajax({
  173. method: "get",
  174. dataType: "json",
  175. crossDomain: false,
  176. url: globalConfig.context + "/api/admin/demand/unitNames",
  177. success: function (data) {
  178. let theArr = [];
  179. if (!data.data) {
  180. if (data.error && data.error.length) {
  181. message.warning(data.error[0].message);
  182. };
  183. } else {
  184. data.data.map(function (item) {
  185. theArr.push(
  186. <Select.Option value={item.uid} key={item.uid}>{item.unitName}</Select.Option>
  187. )
  188. });
  189. };
  190. this.setState({
  191. companyOption: theArr
  192. });
  193. }.bind(this),
  194. }).always(function () {
  195. this.setState({
  196. loading: false
  197. });
  198. }.bind(this));
  199. },
  200. getUserList() {
  201. this.setState({
  202. loading: true
  203. });
  204. $.ajax({
  205. method: "get",
  206. dataType: "json",
  207. crossDomain: false,
  208. url: globalConfig.context + "/api/admin/demand/userNames",
  209. success: function (data) {
  210. let theArr = [];
  211. if (!data.data) {
  212. if (data.error && data.error.length) {
  213. message.warning(data.error[0].message);
  214. };
  215. } else {
  216. data.data.map(function (item) {
  217. theArr.push(
  218. <Select.Option value={item.uid} key={item.uid}>{item.username}</Select.Option>
  219. )
  220. });
  221. };
  222. this.setState({
  223. userOption: theArr
  224. });
  225. }.bind(this),
  226. }).always(function () {
  227. this.setState({
  228. loading: false
  229. });
  230. }.bind(this));
  231. },
  232. componentWillMount() {
  233. let theArr = [];
  234. demandTypeList.map(function (item) {
  235. theArr.push(
  236. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  237. )
  238. });
  239. this.state.demandTypeOption = theArr;
  240. this.loadData();
  241. this.getCompanyList();
  242. this.getUserList();
  243. },
  244. componentWillReceiveProps(nextProps) {
  245. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  246. this.loadData(null, nextProps['data-listApiUrl']);
  247. this.state.selectedRowKeys = [];
  248. this.state.selectedRows = [];
  249. };
  250. },
  251. tableRowClick(record, index) {
  252. this.state.RowData = record;
  253. this.setState({
  254. showDesc: true
  255. });
  256. },
  257. delectRow() {
  258. let deletedIds = [];
  259. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  260. let rowItem = this.state.selectedRows[idx];
  261. if (rowItem.id) {
  262. deletedIds.push(rowItem.id)
  263. };
  264. };
  265. this.setState({
  266. selectedRowKeys: [],
  267. loading: deletedIds.length > 0
  268. });
  269. $.ajax({
  270. method: "POST",
  271. dataType: "json",
  272. crossDomain: false,
  273. url: globalConfig.context + "/api/admin/demand/delete",
  274. data: {
  275. ids: deletedIds
  276. }
  277. }).done(function (data) {
  278. if (!data.error.length) {
  279. message.success('删除成功!');
  280. this.setState({
  281. loading: false,
  282. });
  283. } else {
  284. message.warning(data.error[0].message);
  285. };
  286. this.loadData();
  287. }.bind(this));
  288. },
  289. addClick() {
  290. this.state.RowData = {};
  291. this.setState({
  292. showDesc: true
  293. });
  294. },
  295. closeDesc(e, s) {
  296. this.state.showDesc = e;
  297. if (s) {
  298. this.loadData();
  299. };
  300. },
  301. search() {
  302. this.loadData();
  303. },
  304. reset() {
  305. this.state.serialNumber = undefined;
  306. this.state.name = undefined;
  307. this.state.keyword = undefined;
  308. this.state.infoSources = undefined;
  309. this.state.demandType = undefined;
  310. this.state.username = undefined;
  311. this.state.status = undefined;
  312. this.state.releaseStatus = undefined;
  313. this.state.validityPeriodDate = [];
  314. this.state.releaseDate = [];
  315. this.loadData();
  316. },
  317. searchSwitch() {
  318. this.setState({
  319. searchMore: !this.state.searchMore
  320. });
  321. },
  322. render() {
  323. const rowSelection = {
  324. selectedRowKeys: this.state.selectedRowKeys,
  325. onChange: (selectedRowKeys, selectedRows) => {
  326. this.setState({
  327. selectedRows: selectedRows,
  328. selectedRowKeys: selectedRowKeys
  329. });
  330. }
  331. };
  332. const hasSelected = this.state.selectedRowKeys.length > 0;
  333. const { RangePicker } = DatePicker;
  334. return (
  335. <div className="user-content" >
  336. <div className="content-title">
  337. <span>科技需求管理</span>
  338. <div className="patent-addNew">
  339. <Button type="primary" onClick={this.addClick}>新增需求<Icon type="plus" /></Button>
  340. </div>
  341. </div>
  342. <div className="user-search">
  343. <Input placeholder="需求编号"
  344. value={this.state.serialNumber}
  345. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  346. <Input placeholder="需求名称"
  347. value={this.state.name}
  348. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  349. <Input placeholder="关键字"
  350. value={this.state.keyword}
  351. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  352. <Select placeholder="选择信息来源" style={{ width: 120 }}
  353. value={this.state.infoSources}
  354. onChange={(e) => { this.setState({ infoSources: e }) }}>
  355. <Select.Option value="0" >平台采集</Select.Option>
  356. <Select.Option value="1" >客户发布</Select.Option>
  357. </Select>
  358. <Select placeholder="选择需求类型"
  359. style={{ width: 120 }}
  360. value={this.state.demandType}
  361. onChange={(e) => { this.setState({ demandType: e }) }}>
  362. {this.state.demandTypeOption}
  363. </Select>
  364. <Select placeholder="选择需求状态" style={{ width: 120 }}
  365. value={this.state.status}
  366. onChange={(e) => { this.setState({ status: e }) }}>
  367. <Select.Option value="0" >进行中</Select.Option>
  368. <Select.Option value="1" >未解决</Select.Option>
  369. <Select.Option value="2" >已解决</Select.Option>
  370. </Select>
  371. <Select placeholder="选择是否发布" style={{ width: 120 }}
  372. value={this.state.releaseStatus}
  373. onChange={(e) => { this.setState({ releaseStatus: e }) }}>
  374. <Select.Option value="0" >未发布</Select.Option>
  375. <Select.Option value="1" >已发布</Select.Option>
  376. </Select>
  377. <Button type="primary" onClick={this.search}>搜索</Button>
  378. <Button onClick={this.reset}>重置</Button>
  379. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  380. disabled={!hasSelected}
  381. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  382. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  383. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  384. <p>
  385. <span>有效期限 :</span>
  386. <RangePicker
  387. value={[this.state.validityPeriodDate[0] ? moment(this.state.validityPeriodDate[0]) : null,
  388. this.state.validityPeriodDate[1] ? moment(this.state.validityPeriodDate[1]) : null]}
  389. onChange={(data, dataString) => { this.setState({ validityPeriodDate: dataString }); }} />
  390. <span>发布时间 :</span>
  391. <RangePicker
  392. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  393. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  394. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  395. </p>
  396. </div>
  397. </div>
  398. <div className="patent-table">
  399. <Spin spinning={this.state.loading}>
  400. <Table columns={this.state.columns}
  401. dataSource={this.state.dataSource}
  402. rowSelection={rowSelection}
  403. pagination={this.state.pagination}
  404. onRowClick={this.tableRowClick} />
  405. </Spin>
  406. </div>
  407. <TechDemandDesc
  408. data={this.state.RowData}
  409. detailApiUrl={this.props['data-detailApiUrl']}
  410. companyOption={this.state.companyOption}
  411. userOption={this.state.userOption}
  412. demandTypeOption={this.state.demandTypeOption}
  413. showDesc={this.state.showDesc}
  414. closeDesc={this.closeDesc} />
  415. </div >
  416. );
  417. }
  418. });
  419. export default DemandList;