techDemand.jsx 21 KB

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