techDemand.jsx 25 KB

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