techDemandAudit.jsx 27 KB

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