techDemandRelease.jsx 27 KB

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