myTechDemand.jsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. console.log(record);
  344. this.state.RowData = record;
  345. if(index!=undefined){
  346. this.setState({
  347. showDesc: true
  348. });
  349. }
  350. },
  351. delectRow() {
  352. let deletedIds = [];
  353. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  354. let rowItem = this.state.selectedRows[idx];
  355. if (rowItem.id) {
  356. deletedIds.push(rowItem.id)
  357. };
  358. };
  359. this.setState({
  360. selectedRowKeys: [],
  361. loading: deletedIds.length > 0
  362. });
  363. $.ajax({
  364. method: "POST",
  365. dataType: "json",
  366. crossDomain: false,
  367. url: globalConfig.context + "/api/admin/demand/delete",
  368. data: {
  369. ids: deletedIds
  370. }
  371. }).done(function (data) {
  372. if (!data.error.length) {
  373. message.success('删除成功!');
  374. this.setState({
  375. loading: false,
  376. });
  377. } else {
  378. message.warning(data.error[0].message);
  379. };
  380. this.loadData();
  381. }.bind(this));
  382. },
  383. addClick() {
  384. this.state.RowData = {};
  385. this.setState({
  386. showDesc: true
  387. });
  388. },
  389. closeDesc(e, s) {
  390. this.state.showDesc = e;
  391. if (s) {
  392. this.loadData();
  393. };
  394. },
  395. search() {
  396. this.loadData();
  397. },
  398. reset() {
  399. this.state.serialNumber = undefined;
  400. this.state.name = undefined;
  401. this.state.keyword = undefined;
  402. this.state.infoSources = undefined;
  403. this.state.demandType = undefined;
  404. this.state.searchName = undefined;
  405. this.state.searchType = 0;
  406. this.state.boutique = '';
  407. this.state.hot='' ;
  408. this.state.status = undefined;
  409. this.state.releaseStatus = undefined;
  410. this.state.auditStatus = undefined;
  411. this.state.dataCategory = undefined;
  412. this.state.validityPeriodDate = [];
  413. this.state.releaseDate = [];
  414. this.state.releaseDateS = [];
  415. this.loadData();
  416. },
  417. searchSwitch() {
  418. this.setState({
  419. searchMore: !this.state.searchMore
  420. });
  421. },
  422. render() {
  423. const rowSelection = {
  424. selectedRowKeys: this.state.selectedRowKeys,
  425. onChange: (selectedRowKeys, selectedRows) => {
  426. this.setState({
  427. selectedRows: selectedRows.slice(-1),
  428. selectedRowKeys: selectedRowKeys.slice(-1)
  429. });
  430. }
  431. };
  432. const hasSelected = this.state.selectedRowKeys.length > 0;
  433. const { RangePicker } = DatePicker;
  434. return (
  435. <div className="user-content" >
  436. <div className="content-title">
  437. <span>我的科技需求</span>
  438. <div className="patent-addNew clearfix">
  439. <Upload
  440. action={globalConfig.context + "/api/admin/demand/uploadTemplate"}
  441. data={{ 'sign': 'demand_template' }}
  442. beforeUpload={beforeUploadFile}
  443. showUploadList={false}
  444. onChange={(info) => {
  445. if (info.file.status !== 'uploading') {
  446. console.log(info.file, info.fileList);
  447. }
  448. if (info.file.status === 'done') {
  449. if (!info.file.response.error.length) {
  450. message.success(`${info.file.name} 文件上传成功!`);
  451. } else {
  452. message.warning(info.file.response.error[0].message);
  453. return;
  454. };
  455. } else if (info.file.status === 'error') {
  456. message.error(`${info.file.name} 文件上传失败。`);
  457. };
  458. }} >
  459. <Button>上传批量导入模板</Button>
  460. </Upload>
  461. <Button onClick={() => { window.open(globalConfig.context + '/api/admin/demand/downloadTemplate?sign=demand_template') }}>下载批量导入模板</Button>
  462. <Button type="primary" className="addButton" onClick={this.addClick}>新增需求<Icon type="plus" /></Button>
  463. <BatchImport closeDesc={this.closeDesc} />
  464. </div>
  465. </div>
  466. <div className="user-search">
  467. <Input placeholder="需求编号"
  468. value={this.state.serialNumber}
  469. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  470. <Input placeholder="需求名称"
  471. value={this.state.name}
  472. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  473. <Input placeholder="关键字"
  474. value={this.state.keyword}
  475. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  476. <Input placeholder="雇主名称"
  477. value={this.state.searchName}
  478. onChange={(e) => { this.setState({ searchName: e.target.value }); }} />
  479. <Radio.Group value={this.state.searchType} onChange={(e) => {
  480. this.setState({ searchType: e.target.value })
  481. }}>
  482. <Radio value={0}>认证用户</Radio>
  483. <Radio value={1}>非认证用户</Radio>
  484. </Radio.Group>
  485. <Button type="primary" onClick={this.search}>搜索</Button>
  486. <Button onClick={this.reset}>重置</Button>
  487. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  488. disabled={!hasSelected}
  489. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  490. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  491. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  492. <Radio.Group value={this.state.boutique} onChange={(e) => {
  493. this.setState({ boutique: e.target.value })
  494. }}>
  495. <Radio value={1}>精品</Radio>
  496. <Radio value={0}>非精品</Radio>
  497. </Radio.Group>
  498. <Radio.Group value={this.state.hot} onChange={(e) => {
  499. this.setState({ hot: e.target.value })
  500. }}>
  501. <Radio value={1}>首页展示</Radio>
  502. <Radio value={0}>首页不展示</Radio>
  503. </Radio.Group>
  504. <Select placeholder="选择信息来源" style={{ width: 120 }}
  505. value={this.state.infoSources}
  506. onChange={(e) => { this.setState({ infoSources: e }) }}>
  507. <Select.Option value="0" >平台采集</Select.Option>
  508. <Select.Option value="1" >客户发布</Select.Option>
  509. <Select.Option value="2" >批量导入</Select.Option>
  510. <Select.Option value="3" >三方对接</Select.Option>
  511. </Select>
  512. <Select placeholder="选择需求类型"
  513. style={{ width: 120 }}
  514. value={this.state.demandType}
  515. onChange={(e) => { this.setState({ demandType: e }) }}>
  516. {this.state.demandTypeOption}
  517. </Select>
  518. <Select placeholder="选择需求状态" style={{ width: 120 }}
  519. value={this.state.status}
  520. onChange={(e) => { this.setState({ status: e }) }}>
  521. <Select.Option value="0" >进行中</Select.Option>
  522. <Select.Option value="1" >未解决</Select.Option>
  523. <Select.Option value="2" >已解决</Select.Option>
  524. </Select>
  525. <Select placeholder="选择审核状态" style={{ width: 160 }}
  526. value={this.state.auditStatus}
  527. onChange={(e) => { this.setState({ auditStatus: e }) }}>
  528. <Select.Option value="0" >未提交审核(草稿)</Select.Option>
  529. <Select.Option value="1" >提交审核</Select.Option>
  530. <Select.Option value="2" >审核中</Select.Option>
  531. <Select.Option value="3" >审核通过</Select.Option>
  532. <Select.Option value="4" >审核未通过</Select.Option>
  533. </Select>
  534. <Select placeholder="选择是否发布" style={{ width: 120 }}
  535. value={this.state.releaseStatus}
  536. onChange={(e) => { this.setState({ releaseStatus: e }) }}>
  537. <Select.Option value="0" >未发布</Select.Option>
  538. <Select.Option value="1" >已发布</Select.Option>
  539. </Select>
  540. <Select placeholder="选择需求类别" style={{ width: 120 }}
  541. value={this.state.dataCategory}
  542. onChange={(e) => { this.setState({ dataCategory: e }) }}>
  543. <Select.Option value="0" >个人</Select.Option>
  544. <Select.Option value="1" >组织</Select.Option>
  545. </Select>
  546. <div style={{ marginTop: '10px' }}>
  547. <span style={{ marginLeft: '10px' }}>有效期限 : </span>
  548. <RangePicker
  549. value={[this.state.validityPeriodDate[0] ? moment(this.state.validityPeriodDate[0]) : null,
  550. this.state.validityPeriodDate[1] ? moment(this.state.validityPeriodDate[1]) : null]}
  551. onChange={(data, dataString) => { this.setState({ validityPeriodDate: dataString }); }} />
  552. <span style={{ marginLeft: '10px' }}>发布时间 : </span>
  553. <RangePicker
  554. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  555. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  556. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  557. <span style={{ marginLeft: '10px' }}>录入时间 : </span>
  558. <RangePicker
  559. value={[this.state.releaseDateS[0] ? moment(this.state.releaseDateS[0]) : null,
  560. this.state.releaseDateS[1] ? moment(this.state.releaseDateS[1]) : null]}
  561. onChange={(data, dataString) => { this.setState({ releaseDateS: dataString }); }} />
  562. </div>
  563. </div>
  564. </div>
  565. <div className="patent-table">
  566. <Spin spinning={this.state.loading}>
  567. <Table columns={this.state.columns}
  568. dataSource={this.state.dataSource}
  569. rowSelection={rowSelection}
  570. pagination={this.state.pagination}
  571. onRowClick={this.tableRowClick} />
  572. </Spin>
  573. </div>
  574. <TechDemandDesc
  575. data={this.state.RowData}
  576. detailApiUrl={this.props['data-detailApiUrl']}
  577. companyOption={this.state.companyOption}
  578. userOption={this.state.userOption}
  579. demandTypeOption={this.state.demandTypeOption}
  580. showDesc={this.state.showDesc}
  581. closeDesc={this.closeDesc} />
  582. </div >
  583. );
  584. }
  585. });
  586. export default DemandList;