techDemandRelease.jsx 26 KB

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