techDemand.jsx 26 KB

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