techDemand.jsx 26 KB

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