techDemandQuery.jsx 26 KB

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