techDemandQuery.jsx 26 KB

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