techDemandRelease.jsx 27 KB

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