techDemand.jsx 25 KB

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