techDemand.jsx 24 KB

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