techDemandQuery.jsx 27 KB

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