techDemand.jsx 23 KB

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