techDemand.jsx 28 KB

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