techDemand.jsx 21 KB

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