techDemand.jsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. ispage:pageNo,
  21. });
  22. $.ajax({
  23. method: "get",
  24. dataType: "json",
  25. crossDomain: false,
  26. url: globalConfig.context + (apiUrl || this.props['data-listApiUrl']),
  27. data: {
  28. pageNo: pageNo || 1,
  29. pageSize: this.state.pagination.pageSize,
  30. serialNumber: this.state.serialNumber,
  31. name: this.state.name,
  32. recordPerson:this.state.recordPerson,//录入人
  33. employerName:this.state.employerName,//录入人
  34. keyword: this.state.keyword,
  35. infoSources: this.state.infoSources ? Number(this.state.infoSources) : undefined,
  36. demandType: this.state.demandType ? Number(this.state.demandType) : undefined,
  37. //username: this.state.username,
  38. status: this.state.status ? Number(this.state.status) : undefined,
  39. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined,
  40. validityPeriodStartDate: this.state.validityPeriodDate[0],
  41. validityPeriodEndDate: this.state.validityPeriodDate[1],
  42. releaseDateStartDate: this.state.releaseDate[0],
  43. releaseDateEndDate: this.state.releaseDate[1],
  44. createDateStartDate: this.state.releaseDateS[0],
  45. createDateEndDate: this.state.releaseDateS[1],
  46. auditStatus: this.state.auditStatus,
  47. boutique:this.state.boutique,
  48. hot:this.state.hot,
  49. dataCategory:this.state.dataCategory,
  50. //employerName: this.state.searchType == 1 ? this.state.searchName : undefined,
  51. username: this.state.searchType == 0 && this.props['data-listApiUrl'].indexOf('org') == -1 ? this.state.searchName : undefined,
  52. unitName: this.state.searchType == 0 && this.props['data-listApiUrl'].indexOf('user') == -1 ? this.state.searchName : undefined,
  53. },
  54. success: function (data) {
  55. let theArr = [];
  56. if (!data.data || !data.data.list) {
  57. if (data.error && data.error.length) {
  58. message.warning(data.error[0].message);
  59. };
  60. } else {
  61. for (let i = 0; i < data.data.list.length; i++) {
  62. let thisdata = data.data.list[i];
  63. theArr.push({
  64. key: i,
  65. id: thisdata.id,
  66. serialNumber: thisdata.serialNumber,
  67. dataCategory: thisdata.dataCategory,
  68. name: thisdata.name,
  69. keyword: thisdata.keyword,
  70. infoSources: thisdata.infoSources,
  71. username: thisdata.username,
  72. theName: thisdata.username || thisdata.employerName,
  73. demandType: thisdata.demandType,
  74. validityPeriod: thisdata.validityPeriod,
  75. employerName: thisdata.employerName,
  76. employerId: thisdata.employerId,
  77. province: thisdata.province,
  78. status: thisdata.status,
  79. releaseStatus: thisdata.releaseStatus,
  80. releaseDate: thisdata.releaseDate,
  81. principalId: thisdata.principalId,
  82. validityPeriodFormattedDate: thisdata.validityPeriodFormattedDate,
  83. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  84. auditStatus: thisdata.auditStatus,
  85. boutique: thisdata.boutique,
  86. urgentMoney:thisdata.urgentMoney,
  87. urgentDays:thisdata.urgentDays,
  88. hot: thisdata.hot,
  89. techBrokerId:thisdata.techBrokerId,
  90. createTimeFormattedDate: thisdata.createTimeFormattedDate,
  91. });
  92. };
  93. this.state.pagination.current = data.data.pageNo;
  94. this.state.pagination.total = data.data.totalCount;
  95. };
  96. this.setState({
  97. dataSource: theArr,
  98. pagination: this.state.pagination
  99. });
  100. }.bind(this),
  101. }).always(function () {
  102. this.setState({
  103. loading: false
  104. });
  105. }.bind(this));
  106. },
  107. getInitialState() {
  108. return {
  109. searchMore: true,
  110. searchType: 0,
  111. validityPeriodDate: [],
  112. releaseDate: [],
  113. releaseDateS: [],
  114. selectedRowKeys: [],
  115. selectedRows: [],
  116. loading: false,
  117. pagination: {
  118. defaultCurrent: 1,
  119. defaultPageSize: 10,
  120. showQuickJumper: true,
  121. pageSize: 10,
  122. onChange: function (page) {
  123. this.loadData(page);
  124. }.bind(this),
  125. showTotal: function (total) {
  126. return '共' + total + '条数据';
  127. }
  128. },
  129. columns: [
  130. {
  131. title: '编号',
  132. dataIndex: 'serialNumber',
  133. key: 'serialNumber',
  134. }, {
  135. title: '需求名称',
  136. dataIndex: 'name',
  137. key: 'name',
  138. },
  139. {
  140. title: '录入人',
  141. dataIndex: 'techBrokerId',
  142. key: 'techBrokerId',
  143. },
  144. {
  145. title: '是否精品',
  146. dataIndex: 'boutique',
  147. key: 'boutique',
  148. render: text => { return getboutique(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: 'auditStatus',
  178. key: 'auditStatus',
  179. render: text => {
  180. switch (text) {
  181. case 0:
  182. return <span>未提交审核(草稿)</span>;
  183. case 1:
  184. return <span>提交审核</span>;
  185. case 2:
  186. return <span>审核中</span>;
  187. case 3:
  188. return <span>审核通过</span>;
  189. case 4:
  190. return <span>审核未通过</span>;
  191. }
  192. }
  193. }, {
  194. title: '需求状态',
  195. dataIndex: 'status',
  196. key: 'status',
  197. render: text => {
  198. switch (text) {
  199. case "0":
  200. return <span>进行中</span>;
  201. case "1":
  202. return <span>未解决</span>;
  203. case "2":
  204. return <span>已解决</span>;
  205. }
  206. }
  207. }, {
  208. title: '有效期限',
  209. dataIndex: 'validityPeriodFormattedDate',
  210. key: 'validityPeriodFormattedDate',
  211. }, {
  212. title: '发布时间',
  213. dataIndex: 'releaseDateFormattedDate',
  214. key: 'releaseDateFormattedDate',
  215. },{
  216. title: '录入时间',
  217. dataIndex: 'createTimeFormattedDate',
  218. key: 'createTimeFormattedDate',
  219. }
  220. ],
  221. dataSource: [],
  222. searchTime: []
  223. };
  224. },
  225. getCompanyList() {
  226. this.setState({
  227. loading: true
  228. });
  229. $.ajax({
  230. method: "get",
  231. dataType: "json",
  232. crossDomain: false,
  233. url: globalConfig.context + "/api/admin/demand/unitNames",
  234. success: function (data) {
  235. let theArr = [];
  236. if (!data.data) {
  237. if (data.error && data.error.length) {
  238. message.warning(data.error[0].message);
  239. };
  240. } else {
  241. data.data.map(function (item) {
  242. theArr.push(
  243. <Select.Option value={item.uid} key={item.uid}>{item.unitName}</Select.Option>
  244. )
  245. });
  246. };
  247. this.setState({
  248. companyOption: theArr
  249. });
  250. }.bind(this),
  251. }).always(function () {
  252. this.setState({
  253. loading: false
  254. });
  255. }.bind(this));
  256. },
  257. getUserList() {
  258. this.setState({
  259. loading: true
  260. });
  261. $.ajax({
  262. method: "get",
  263. dataType: "json",
  264. crossDomain: false,
  265. url: globalConfig.context + "/api/admin/demand/userNames",
  266. success: function (data) {
  267. let theArr = [];
  268. if (!data.data) {
  269. if (data.error && data.error.length) {
  270. message.warning(data.error[0].message);
  271. };
  272. } else {
  273. data.data.map(function (item) {
  274. theArr.push(
  275. <Select.Option value={item.uid} key={item.uid}>{item.username}</Select.Option>
  276. )
  277. });
  278. };
  279. this.setState({
  280. userOption: theArr
  281. });
  282. }.bind(this),
  283. }).always(function () {
  284. this.setState({
  285. loading: false
  286. });
  287. }.bind(this));
  288. },
  289. componentWillMount() {
  290. let theArr = [];
  291. demandTypeList.map(function (item) {
  292. theArr.push(
  293. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  294. )
  295. });
  296. this.state.demandTypeOption = theArr;
  297. if (window.location.search) {
  298. let theObj = getSearchUrl(window.location.search);
  299. if (theObj.rid) {
  300. theObj.id = theObj.rid;
  301. theObj.employerId = theObj.uid;
  302. if (theObj.rid != 'null') {
  303. this.tableRowClick(theObj);
  304. };
  305. };
  306. };
  307. this.loadData();
  308. this.getCompanyList();
  309. this.getUserList();
  310. },
  311. componentWillReceiveProps(nextProps) {
  312. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  313. this.state.selectedRowKeys = [];
  314. this.state.selectedRows = [];
  315. this.state.serialNumber = undefined;
  316. this.state.name = undefined;
  317. this.state.keyword = undefined;
  318. this.state.infoSources = undefined;
  319. this.state.demandType = undefined;
  320. this.state.searchName = undefined;
  321. this.state.searchType = 0;
  322. this.state.status = undefined;
  323. this.state.releaseStatus = undefined;
  324. this.state.auditStatus = undefined;
  325. this.state.validityPeriodDate = [];
  326. this.state.releaseDate = [];
  327. this.state.releaseDateS = [];
  328. this.loadData(null, nextProps['data-listApiUrl']);
  329. };
  330. },
  331. tableRowClick(record, index) {
  332. this.state.RowData = record;
  333. if(index!=undefined){
  334. this.setState({
  335. showDesc: true
  336. });
  337. }
  338. },
  339. delectRow() {
  340. let deletedIds = [];
  341. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  342. let rowItem = this.state.selectedRows[idx];
  343. if (rowItem.id) {
  344. deletedIds.push(rowItem.id)
  345. };
  346. };
  347. this.setState({
  348. selectedRowKeys: [],
  349. loading: deletedIds.length > 0
  350. });
  351. $.ajax({
  352. method: "POST",
  353. dataType: "json",
  354. crossDomain: false,
  355. url: globalConfig.context + "/api/admin/demand/delete",
  356. data: {
  357. ids: deletedIds
  358. }
  359. }).done(function (data) {
  360. if (!data.error.length) {
  361. message.success('删除成功!');
  362. this.setState({
  363. loading: false,
  364. });
  365. } else {
  366. message.warning(data.error[0].message);
  367. };
  368. this.loadData(this.state.ispage);
  369. }.bind(this));
  370. },
  371. addClick() {
  372. this.state.RowData = {};
  373. this.setState({
  374. showDesc: true
  375. });
  376. },
  377. closeDesc(e, s) {
  378. this.state.showDesc = e;
  379. if (s) {
  380. this.loadData();
  381. };
  382. },
  383. search() {
  384. this.loadData();
  385. },
  386. reset() {
  387. this.state.serialNumber = undefined;
  388. this.state.name = undefined;
  389. this.state.recordPerson= undefined;
  390. this.state.employerName= 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.dataCategory = undefined;
  402. this.state.validityPeriodDate = [];
  403. this.state.releaseDate = [];
  404. this.state.releaseDateS = [];
  405. this.loadData();
  406. },
  407. searchSwitch() {
  408. this.setState({
  409. searchMore: !this.state.searchMore
  410. });
  411. },
  412. render() {
  413. const rowSelection = {
  414. selectedRowKeys: this.state.selectedRowKeys,
  415. onChange: (selectedRowKeys, selectedRows) => {
  416. this.setState({
  417. selectedRows: selectedRows.slice(-1),
  418. selectedRowKeys: selectedRowKeys.slice(-1)
  419. });
  420. }
  421. };
  422. const hasSelected = this.state.selectedRowKeys.length > 0;
  423. const { RangePicker } = DatePicker;
  424. return (
  425. <div className="user-content" >
  426. <div className="content-title">
  427. <span>科技需求管理</span>
  428. <div className="patent-addNew clearfix">
  429. <Upload
  430. action={globalConfig.context + "/api/admin/demand/uploadTemplate"}
  431. data={{ 'sign': 'demand_template' }}
  432. beforeUpload={beforeUploadFile}
  433. showUploadList={false}
  434. onChange={(info) => {
  435. if (info.file.status !== 'uploading') {
  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;