techDemandAudit.jsx 27 KB

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