techDemand.jsx 26 KB

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