techDemandAudit.jsx 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. techBrokerIdd:thisdata.techBrokerIdd,
  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: 'hot',
  150. key: 'hot',
  151. render: text => { return gethot(text) }
  152. },
  153. {
  154. title: '关键字',
  155. dataIndex: 'keyword',
  156. key: 'keyword',
  157. }, {
  158. title: '需求类型',
  159. dataIndex: 'demandType',
  160. key: 'demandType',
  161. render: text => { return getDemandType(text); }
  162. }, {
  163. title: '信息来源',
  164. dataIndex: 'infoSources',
  165. key: 'infoSources',
  166. render: text => {
  167. switch (text) {
  168. case "0":
  169. return <span>平台采集</span>;
  170. case "1":
  171. return <span>客户发布</span>;
  172. case "2":
  173. return <span>批量导入</span>
  174. case "3":
  175. return <span>三方对接</span>
  176. }
  177. }
  178. }, {
  179. title: '加急天数',
  180. dataIndex: 'urgentDays',
  181. key: 'urgentDays',
  182. }, {
  183. title: '加急报酬(万)',
  184. dataIndex: 'urgentMoney',
  185. key: 'urgentMoney',
  186. }, {
  187. title: '审核状态',
  188. dataIndex: 'auditStatus',
  189. key: 'auditStatus',
  190. render: text => {
  191. switch (text) {
  192. case 0:
  193. return <span>未提交审核(草稿)</span>;
  194. case 1:
  195. return <span>提交审核</span>;
  196. case 2:
  197. return <span>审核中</span>;
  198. case 3:
  199. return <span>审核通过</span>;
  200. case 4:
  201. return <span>审核未通过</span>;
  202. }
  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. ],
  228. dataSource: [],
  229. searchTime: []
  230. };
  231. },
  232. getCompanyList() {
  233. this.setState({
  234. loading: true
  235. });
  236. $.ajax({
  237. method: "get",
  238. dataType: "json",
  239. crossDomain: false,
  240. url: globalConfig.context + "/api/admin/demand/unitNames",
  241. success: function (data) {
  242. let theArr = [];
  243. if (!data.data) {
  244. if (data.error && data.error.length) {
  245. message.warning(data.error[0].message);
  246. };
  247. } else {
  248. data.data.map(function (item) {
  249. theArr.push(
  250. <Select.Option value={item.uid} key={item.uid}>{item.unitName}</Select.Option>
  251. )
  252. });
  253. };
  254. this.setState({
  255. companyOption: theArr
  256. });
  257. }.bind(this),
  258. }).always(function () {
  259. this.setState({
  260. loading: false
  261. });
  262. }.bind(this));
  263. },
  264. getUserList() {
  265. this.setState({
  266. loading: true
  267. });
  268. $.ajax({
  269. method: "get",
  270. dataType: "json",
  271. crossDomain: false,
  272. url: globalConfig.context + "/api/admin/demand/userNames",
  273. success: function (data) {
  274. let theArr = [];
  275. if (!data.data) {
  276. if (data.error && data.error.length) {
  277. message.warning(data.error[0].message);
  278. };
  279. } else {
  280. data.data.map(function (item) {
  281. theArr.push(
  282. <Select.Option value={item.uid} key={item.uid}>{item.username}</Select.Option>
  283. )
  284. });
  285. };
  286. this.setState({
  287. userOption: theArr
  288. });
  289. }.bind(this),
  290. }).always(function () {
  291. this.setState({
  292. loading: false
  293. });
  294. }.bind(this));
  295. },
  296. //审核不通过
  297. examineCancel(){
  298. let nub=4;
  299. this.examine(nub)
  300. },
  301. //审核通过
  302. examineOK(){
  303. let nub=3;
  304. this.examine(nub)
  305. },
  306. examine(nub) {
  307. let deletedIds = [];
  308. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  309. let rowItem = this.state.selectedRows[idx];
  310. if (rowItem.id) {
  311. deletedIds.push(rowItem.id,rowItem.techBrokerIdd)
  312. };
  313. };
  314. console.log(deletedIds);
  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();
  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();
  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}>审核通过</Button>
  525. <Button type='primary' onClick={this.examineCancel} disabled={!hasSelected}>审核不通过</Button>
  526. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  527. disabled={!hasSelected}
  528. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  529. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  530. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  531. <Radio.Group value={this.state.boutique} onChange={(e) => {
  532. this.setState({ boutique: e.target.value })
  533. }}>
  534. <Radio value={1}>精品</Radio>
  535. <Radio value={0}>非精品</Radio>
  536. </Radio.Group>
  537. <Radio.Group value={this.state.hot} onChange={(e) => {
  538. this.setState({ hot: e.target.value })
  539. }}>
  540. <Radio value={1}>首页展示</Radio>
  541. <Radio value={0}>首页不展示</Radio>
  542. </Radio.Group>
  543. <Select placeholder="选择信息来源" style={{ width: 120 }}
  544. value={this.state.infoSources}
  545. onChange={(e) => { this.setState({ infoSources: e }) }}>
  546. <Select.Option value="0" >平台采集</Select.Option>
  547. <Select.Option value="1" >客户发布</Select.Option>
  548. <Select.Option value="2" >批量导入</Select.Option>
  549. <Select.Option value="3" >三方对接</Select.Option>
  550. </Select>
  551. <Select placeholder="选择需求类型"
  552. style={{ width: 120 }}
  553. value={this.state.demandType}
  554. onChange={(e) => { this.setState({ demandType: e }) }}>
  555. {this.state.demandTypeOption}
  556. </Select>
  557. <Select placeholder="选择需求状态" style={{ width: 120 }}
  558. value={this.state.status}
  559. onChange={(e) => { this.setState({ status: e }) }}>
  560. <Select.Option value="0" >进行中</Select.Option>
  561. <Select.Option value="1" >未解决</Select.Option>
  562. <Select.Option value="2" >已解决</Select.Option>
  563. </Select>
  564. <Select placeholder="选择审核状态" style={{ width: 160 }}
  565. value={this.state.auditStatus}
  566. onChange={(e) => { this.setState({ auditStatus: e }) }}>
  567. <Select.Option value="0" >未提交审核(草稿)</Select.Option>
  568. <Select.Option value="1" >提交审核</Select.Option>
  569. <Select.Option value="2" >审核中</Select.Option>
  570. <Select.Option value="3" >审核通过</Select.Option>
  571. <Select.Option value="4" >审核未通过</Select.Option>
  572. </Select>
  573. <Select placeholder="选择需求类别" style={{ width: 120 }}
  574. value={this.state.dataCategory}
  575. onChange={(e) => { this.setState({ dataCategory: e }) }}>
  576. <Select.Option value="0" >个人</Select.Option>
  577. <Select.Option value="1" >组织</Select.Option>
  578. </Select>
  579. <div style={{ marginTop: '10px' }}>
  580. <span style={{ marginLeft: '10px' }}>有效期限 : </span>
  581. <RangePicker
  582. value={[this.state.validityPeriodDate[0] ? moment(this.state.validityPeriodDate[0]) : null,
  583. this.state.validityPeriodDate[1] ? moment(this.state.validityPeriodDate[1]) : null]}
  584. onChange={(data, dataString) => { this.setState({ validityPeriodDate: dataString }); }} />
  585. <span style={{ marginLeft: '10px' }}>发布时间 : </span>
  586. <RangePicker
  587. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  588. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  589. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  590. <span style={{ marginLeft: '10px' }}>录入时间 : </span>
  591. <RangePicker
  592. value={[this.state.releaseDateS[0] ? moment(this.state.releaseDateS[0]) : null,
  593. this.state.releaseDateS[1] ? moment(this.state.releaseDateS[1]) : null]}
  594. onChange={(data, dataString) => { this.setState({ releaseDateS: dataString }); }} />
  595. </div>
  596. </div>
  597. </div>
  598. <div className="patent-table">
  599. <Spin spinning={this.state.loading}>
  600. <Table columns={this.state.columns}
  601. dataSource={this.state.dataSource}
  602. rowSelection={rowSelection}
  603. pagination={this.state.pagination}
  604. onRowClick={this.tableRowClick} />
  605. </Spin>
  606. </div>
  607. <TechDemandDesc
  608. data={this.state.RowData}
  609. detailApiUrl={this.props['data-detailApiUrl']}
  610. companyOption={this.state.companyOption}
  611. userOption={this.state.userOption}
  612. demandTypeOption={this.state.demandTypeOption}
  613. showDesc={this.state.showDesc}
  614. closeDesc={this.closeDesc} />
  615. </div >
  616. );
  617. }
  618. });
  619. export default TechDemandPublish;