techDemandRelease.jsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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. employerName: this.state.employerName,
  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:3,
  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: 'auditStatus',
  176. key: 'auditStatus',
  177. render: text => {
  178. switch (text) {
  179. case 0:
  180. return <span>未提交审核(草稿)</span>;
  181. case 1:
  182. return <span>提交审核</span>;
  183. case 2:
  184. return <span>审核中</span>;
  185. case 3:
  186. return <span>审核通过</span>;
  187. case 4:
  188. return <span>审核未通过</span>;
  189. }
  190. }
  191. },{
  192. title: '发布状态',
  193. dataIndex: 'releaseStatus',
  194. key: 'releaseStatus',
  195. render: text => { return (text)?'已发布':'未发布' }
  196. },
  197. {
  198. title: '需求状态',
  199. dataIndex: 'status',
  200. key: 'status',
  201. render: text => {
  202. switch (text) {
  203. case "0":
  204. return <span>进行中</span>;
  205. case "1":
  206. return <span>未解决</span>;
  207. case "2":
  208. return <span>已解决</span>;
  209. }
  210. }
  211. }, {
  212. title: '有效期限',
  213. dataIndex: 'validityPeriodFormattedDate',
  214. key: 'validityPeriodFormattedDate',
  215. },{
  216. title: '录入时间',
  217. dataIndex: 'createTimeFormattedDate',
  218. key: 'createTimeFormattedDate',
  219. },{
  220. title: '发布操作',
  221. dataIndex: 'ee',
  222. key: 'ee',
  223. render: (text, record, index) => {
  224. return <div>
  225. {(record.releaseStatus=="0")?<Popconfirm title={'请确认发布需求【'+record.name+'】'} onConfirm={(e)=>{this.examineOK(record)}} okText="确认" cancelText="取消">
  226. <Button style={{marginRight:'5px'}} onClick={(e) =>{ e.stopPropagation()}} type="primary">发布</Button>
  227. </Popconfirm>:
  228. <Popconfirm title={'请确认撤销发布需求【'+record.name+'】'} onConfirm={(e)=>{this.examineCancel(record)}} okText="确认" cancelText="取消">
  229. <Button style={{marginRight:'5px'}} onClick={(e) =>{ e.stopPropagation()}} type="danger">撤销发布</Button>
  230. </Popconfirm>}
  231. </div>
  232. }
  233. }
  234. ],
  235. dataSource: [],
  236. searchTime: []
  237. };
  238. },
  239. getCompanyList() {
  240. this.setState({
  241. loading: true
  242. });
  243. $.ajax({
  244. method: "get",
  245. dataType: "json",
  246. crossDomain: false,
  247. url: globalConfig.context + "/api/admin/demand/unitNames",
  248. success: function (data) {
  249. let theArr = [];
  250. if (!data.data) {
  251. if (data.error && data.error.length) {
  252. message.warning(data.error[0].message);
  253. };
  254. } else {
  255. data.data.map(function (item) {
  256. theArr.push(
  257. <Select.Option value={item.uid} key={item.uid}>{item.unitName}</Select.Option>
  258. )
  259. });
  260. };
  261. this.setState({
  262. companyOption: theArr
  263. });
  264. }.bind(this),
  265. }).always(function () {
  266. this.setState({
  267. loading: false
  268. });
  269. }.bind(this));
  270. },
  271. getUserList() {
  272. this.setState({
  273. loading: true
  274. });
  275. $.ajax({
  276. method: "get",
  277. dataType: "json",
  278. crossDomain: false,
  279. url: globalConfig.context + "/api/admin/demand/userNames",
  280. success: function (data) {
  281. let theArr = [];
  282. if (!data.data) {
  283. if (data.error && data.error.length) {
  284. message.warning(data.error[0].message);
  285. };
  286. } else {
  287. data.data.map(function (item) {
  288. theArr.push(
  289. <Select.Option value={item.uid} key={item.uid}>{item.username}</Select.Option>
  290. )
  291. });
  292. };
  293. this.setState({
  294. userOption: theArr
  295. });
  296. }.bind(this),
  297. }).always(function () {
  298. this.setState({
  299. loading: false
  300. });
  301. }.bind(this));
  302. },
  303. //撤销发布
  304. examineCancel(record){
  305. let api=0;
  306. this.examine(api,record);
  307. },
  308. //发布
  309. examineOK(record){
  310. let api=1;
  311. this.examine(api,record);
  312. },
  313. examine(nub,record) {
  314. this.setState({
  315. selectedRowKeys: [],
  316. });
  317. $.ajax({
  318. method: "POST",
  319. dataType: "json",
  320. crossDomain: false,
  321. url: globalConfig.context + '/api/admin/demand/offShelf',
  322. data: {
  323. id: record.id,
  324. releaseStatus:nub,
  325. auditStatus:3
  326. }
  327. }).done(function (data) {
  328. if (!data.error.length) {
  329. message.success('操作成功');
  330. this.setState({
  331. loading: false,
  332. });
  333. } else {
  334. message.warning(data.error[0].message);
  335. };
  336. this.loadData(this.state.ispage);
  337. }.bind(this));
  338. },
  339. componentWillMount() {
  340. let theArr = [];
  341. demandTypeList.map(function (item) {
  342. theArr.push(
  343. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  344. )
  345. });
  346. this.state.demandTypeOption = theArr;
  347. let data=localStorage.getItem('newData');
  348. if(data!='{}'&&data){
  349. var newData = JSON.parse(data);
  350. this.tableRowClick(newData);
  351. };
  352. this.loadData();
  353. this.getCompanyList();
  354. this.getUserList();
  355. },
  356. componentWillReceiveProps(nextProps) {
  357. if (this.props['data-listApiUrl'] != nextProps['data-listApiUrl']) {
  358. this.state.selectedRowKeys = [];
  359. this.state.selectedRows = [];
  360. this.state.serialNumber = undefined;
  361. this.state.name = undefined;
  362. this.state.keyword = undefined;
  363. this.state.infoSources = undefined;
  364. this.state.demandType = undefined;
  365. this.state.searchName = undefined;
  366. this.state.searchType = 0;
  367. this.state.status = undefined;
  368. this.state.releaseStatus = undefined;
  369. this.state.auditStatus = undefined;
  370. this.state.validityPeriodDate = [];
  371. this.state.releaseDate = [];
  372. this.state.releaseDateS = [];
  373. this.loadData(null, nextProps['data-listApiUrl']);
  374. };
  375. },
  376. tableRowClick(record, index) {
  377. this.state.RowData = record;
  378. this.setState({
  379. showDesc: true
  380. });
  381. localStorage.setItem('newData','{}');
  382. },
  383. // delectRow() {
  384. // let deletedIds = [];
  385. // for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  386. // let rowItem = this.state.selectedRows[idx];
  387. // if (rowItem.id) {
  388. // deletedIds.push(rowItem.id)
  389. // };
  390. // };
  391. // this.setState({
  392. // selectedRowKeys: [],
  393. // loading: deletedIds.length > 0
  394. // });
  395. // $.ajax({
  396. // method: "POST",
  397. // dataType: "json",
  398. // crossDomain: false,
  399. // url: globalConfig.context + "/api/admin/demand/delete",
  400. // data: {
  401. // ids: deletedIds
  402. // }
  403. // }).done(function (data) {
  404. // if (!data.error.length) {
  405. // message.success('删除成功!');
  406. // this.setState({
  407. // loading: false,
  408. // });
  409. // } else {
  410. // message.warning(data.error[0].message);
  411. // };
  412. // this.loadData();
  413. // }.bind(this));
  414. // },
  415. addClick() {
  416. this.state.RowData = {};
  417. this.setState({
  418. showDesc: true
  419. });
  420. },
  421. closeDesc(e, s) {
  422. this.state.showDesc = e;
  423. if (s) {
  424. this.loadData(this.state.ispage);
  425. };
  426. },
  427. search() {
  428. this.loadData();
  429. },
  430. reset() {
  431. this.state.serialNumber = undefined;
  432. this.state.name = undefined;
  433. this.state.keyword = undefined;
  434. this.state.employerName= undefined;
  435. this.state.infoSources = undefined;
  436. this.state.demandType = undefined;
  437. this.state.searchName = undefined;
  438. this.state.searchType = 0;
  439. this.state.boutique = '';
  440. this.state.hot='' ;
  441. this.state.status = undefined;
  442. this.state.releaseStatus = undefined;
  443. this.state.auditStatus = undefined;
  444. this.state.dataCategory = undefined;
  445. this.state.validityPeriodDate = [];
  446. this.state.releaseDate = [];
  447. this.state.releaseDateS = [];
  448. this.loadData();
  449. },
  450. searchSwitch() {
  451. this.setState({
  452. searchMore: !this.state.searchMore
  453. });
  454. },
  455. render() {
  456. const rowSelection = {
  457. selectedRowKeys: this.state.selectedRowKeys,
  458. onChange: (selectedRowKeys, selectedRows) => {
  459. this.setState({
  460. selectedRows: selectedRows.slice(-1),
  461. selectedRowKeys: selectedRowKeys.slice(-1)
  462. });
  463. }
  464. };
  465. const hasSelected = this.state.selectedRowKeys.length > 0;
  466. const { RangePicker } = DatePicker;
  467. return (
  468. <div className="user-content" >
  469. <div className="content-title">
  470. <span>科技需求发布管理</span>
  471. <div className="patent-addNew clearfix">
  472. <Upload
  473. action={globalConfig.context + "/api/admin/demand/uploadTemplate"}
  474. data={{ 'sign': 'demand_template' }}
  475. beforeUpload={beforeUploadFile}
  476. showUploadList={false}
  477. onChange={(info) => {
  478. if (info.file.status !== 'uploading') {
  479. // console.log(info.file, info.fileList);
  480. }
  481. if (info.file.status === 'done') {
  482. if (!info.file.response.error.length) {
  483. message.success(`${info.file.name} 文件上传成功!`);
  484. } else {
  485. message.warning(info.file.response.error[0].message);
  486. return;
  487. };
  488. } else if (info.file.status === 'error') {
  489. message.error(`${info.file.name} 文件上传失败。`);
  490. };
  491. }} >
  492. <Button style={{"display":"none"}}>上传批量导入模板</Button>
  493. </Upload>
  494. <Button onClick={() => { window.open(globalConfig.context + '/api/admin/demand/downloadTemplate?sign=demand_template') }} style={{"display":"none"}}>下载批量导入模板</Button>
  495. <Button type="primary" className="addButton" onClick={this.addClick} style={{"display":"none"}}>新增需求<Icon type="plus" /></Button>
  496. </div>
  497. </div>
  498. <div className="user-search">
  499. <Input placeholder="需求编号"
  500. value={this.state.serialNumber}
  501. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  502. <Input placeholder="需求名称"
  503. value={this.state.name}
  504. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  505. <Input placeholder="关键字"
  506. value={this.state.keyword}
  507. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  508. <Input placeholder="需求雇主名称"
  509. value={this.state.employerName}
  510. onChange={(e) => { this.setState({ employerName: e.target.value }); }} />
  511. <Radio.Group value={this.state.searchType} onChange={(e) => {
  512. this.setState({ searchType: e.target.value })
  513. }}>
  514. <Radio value={0}>认证用户</Radio>
  515. <Radio value={1}>非认证用户</Radio>
  516. </Radio.Group>
  517. <Button type="primary" onClick={this.search}>搜索</Button>
  518. <Button onClick={this.reset}>重置</Button>
  519. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  520. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  521. <Radio.Group value={this.state.boutique} onChange={(e) => {
  522. this.setState({ boutique: e.target.value })
  523. }}>
  524. <Radio value={1}>精品</Radio>
  525. <Radio value={0}>非精品</Radio>
  526. </Radio.Group>
  527. <Select placeholder="选择信息来源" style={{ width: 120 }}
  528. value={this.state.infoSources}
  529. onChange={(e) => { this.setState({ infoSources: e }) }}>
  530. <Select.Option value="0" >平台采集</Select.Option>
  531. <Select.Option value="1" >客户发布</Select.Option>
  532. <Select.Option value="2" >批量导入</Select.Option>
  533. <Select.Option value="3" >三方对接</Select.Option>
  534. </Select>
  535. <Select placeholder="选择需求类型"
  536. style={{ width: 120 }}
  537. value={this.state.demandType}
  538. onChange={(e) => { this.setState({ demandType: e }) }}>
  539. {this.state.demandTypeOption}
  540. </Select>
  541. <Select placeholder="选择需求状态" style={{ width: 120 }}
  542. value={this.state.status}
  543. onChange={(e) => { this.setState({ status: e }) }}>
  544. <Select.Option value="0" >进行中</Select.Option>
  545. <Select.Option value="1" >未解决</Select.Option>
  546. <Select.Option value="2" >已解决</Select.Option>
  547. </Select>
  548. <Select placeholder="选择需求类别" style={{ width: 120 }}
  549. value={this.state.dataCategory}
  550. onChange={(e) => { this.setState({ dataCategory: e }) }}>
  551. <Select.Option value="0" >个人</Select.Option>
  552. <Select.Option value="1" >组织</Select.Option>
  553. </Select>
  554. <div style={{ marginTop: '10px' }}>
  555. <span style={{ marginLeft: '10px' }}>有效期限 : </span>
  556. <RangePicker
  557. value={[this.state.validityPeriodDate[0] ? moment(this.state.validityPeriodDate[0]) : null,
  558. this.state.validityPeriodDate[1] ? moment(this.state.validityPeriodDate[1]) : null]}
  559. onChange={(data, dataString) => { this.setState({ validityPeriodDate: dataString }); }} />
  560. <span style={{ marginLeft: '10px' }}>发布时间 : </span>
  561. <RangePicker
  562. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  563. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  564. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  565. <span style={{ marginLeft: '10px' }}>录入时间 : </span>
  566. <RangePicker
  567. value={[this.state.releaseDateS[0] ? moment(this.state.releaseDateS[0]) : null,
  568. this.state.releaseDateS[1] ? moment(this.state.releaseDateS[1]) : null]}
  569. onChange={(data, dataString) => { this.setState({ releaseDateS: dataString }); }} />
  570. </div>
  571. </div>
  572. </div>
  573. <div className="patent-table">
  574. <Spin spinning={this.state.loading}>
  575. <Table columns={this.state.columns}
  576. dataSource={this.state.dataSource}
  577. rowSelection={rowSelection}
  578. style={{
  579. cursor: 'pointer',
  580. }}
  581. pagination={this.state.pagination}
  582. onRowClick={this.tableRowClick} />
  583. </Spin>
  584. </div>
  585. <DemandDetail
  586. data={this.state.RowData}
  587. detailApiUrl={this.props['data-detailApiUrl']}
  588. companyOption={this.state.companyOption}
  589. userOption={this.state.userOption}
  590. demandTypeOption={this.state.demandTypeOption}
  591. showDesc={this.state.showDesc}
  592. closeDesc={this.closeDesc} />
  593. </div >
  594. );
  595. }
  596. });
  597. export default TechDemandPublish;