techDemand.jsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. import React from 'react';
  2. import { Icon, Button, Input, Select, Spin, Table, Switch, message, DatePicker, Modal } 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 './demandDesc.jsx';
  8. import { demandTypeList } from '../../dataDic.js';
  9. import { getDemandType,getReleaseStateList } from '../../tools.js';
  10. const DemandList = React.createClass({
  11. loadData(pageNo) {
  12. this.state.data = [];
  13. this.setState({
  14. loading: true
  15. });
  16. $.ajax({
  17. method: "get",
  18. dataType: "json",
  19. crossDomain: false,
  20. url: globalConfig.context + "/api/user/demand/list",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. name: this.state.name, //需求名称
  25. startDate: this.state.releaseDate[0],
  26. endDate: this.state.releaseDate[1],
  27. },
  28. success: function (data) {
  29. let theArr = [];
  30. if (!data.data || !data.data.list) {
  31. if (data.error && data.error.length) {
  32. message.warning(data.error[0].message);
  33. };
  34. } else {
  35. for (let i = 0; i < data.data.list.length; i++) {
  36. let thisdata = data.data.list[i];
  37. theArr.push({
  38. key: i,
  39. id: thisdata.id,
  40. serialNumber: thisdata.serialNumber, //编号
  41. name: thisdata.name,
  42. demandType: thisdata.demandType,
  43. auditStatus: thisdata.auditStatus, //审核状态
  44. createDate:thisdata.createDate,
  45. status:thisdata.status //需求状态
  46. });
  47. };
  48. }
  49. this.state.pagination.current = data.data.pageNo;
  50. this.state.pagination.total = data.data.totalCount;
  51. this.setState({
  52. dataSource: theArr,
  53. pagination: this.state.pagination
  54. });
  55. }.bind(this),
  56. }).always(function () {
  57. this.setState({
  58. loading: false
  59. });
  60. }.bind(this));
  61. },
  62. getInitialState() {
  63. return {
  64. searchMore: true,
  65. validityPeriodDate: [],
  66. releaseDate: [],
  67. selectedRowKeys: [],
  68. selectedRows: [],
  69. loading: false,
  70. pagination: {
  71. defaultCurrent: 1,
  72. defaultPageSize: 10,
  73. showQuickJumper: true,
  74. pageSize: 10,
  75. onChange: function (page) {
  76. this.loadData(page);
  77. }.bind(this),
  78. showTotal: function (total) {
  79. return '共' + total + '条数据';
  80. }
  81. },
  82. columns: [
  83. {
  84. title: '编号',
  85. dataIndex: 'serialNumber',
  86. key: 'serialNumber',
  87. }, {
  88. title: '需求名称',
  89. dataIndex: 'name',
  90. key: 'name',
  91. }, {
  92. title: '需求类型',
  93. dataIndex: 'demandType',
  94. key: 'demandType',
  95. render: text => { return getDemandType(text); }
  96. },
  97. {
  98. title: '发布状态',
  99. dataIndex: 'auditStatus',
  100. key: 'auditStatus',
  101. render: text => { return getReleaseStateList(text) }
  102. }, {
  103. title: '发布时间',
  104. dataIndex: 'createDate',
  105. key: 'createDate'
  106. },
  107. {
  108. title: '解决状态',
  109. dataIndex: 'status',
  110. key: 'status'
  111. },
  112. {
  113. title: '审核',
  114. dataIndex: 'caozuo',
  115. key: 'caozuo',
  116. render:(text,recard) => {
  117. return <div className="btnRight">
  118. <Button type="primary" onClick={(e)=>{e.stopPropagation;this.tableRowClick(recard)}}>{recard.auditStatus=='1'||recard.auditStatus=='2'?'查看':'编辑'}</Button>
  119. {recard.auditStatus!='1'&&recard.auditStatus!='2'&&<Button type="primary" style={{ background: "#3fcf9e", border: "none", color: "#fff" }} onClick={(e)=>{e.stopPropagation;this.submission(recard)}}>提交</Button>}
  120. {recard.auditStatus!='1'&&recard.auditStatus!='2'&&<Button type="danger" onClick={(e)=>{e.stopPropagation;this.delectRow(recard)}}>删除</Button>}
  121. {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="success" onClick={(e)=>{e.stopPropagation;this.release(recard,1)}}>刷新发布</Button>}
  122. {recard.auditStatus!='1'&&recard.auditStatus=='2'&&<Button type="danger" onClick={(e)=>{e.stopPropagation;this.release(recard,0)}}>撤销发布</Button>}
  123. </div>
  124. }
  125. }
  126. ],
  127. dataSource: [],
  128. searchTime: [,]
  129. };
  130. },
  131. //提交审核
  132. submission(record){
  133. this.setState({
  134. loading:true
  135. });
  136. $.ajax({
  137. method: "POST",
  138. dataType: "json",
  139. crossDomain: false,
  140. url: globalConfig.context + "/api/user/demand/deletet",
  141. data: {
  142. ids: deletedIds
  143. }
  144. }).done(function (data) {
  145. if (!data.error.length) {
  146. message.success('成功提交审核.');
  147. this.setState({
  148. loading: false,
  149. });
  150. } else {
  151. message.warning(data.error[0].message);
  152. };
  153. this.loadData();
  154. }.bind(this));
  155. },
  156. //刷新发布
  157. release(recard,index){
  158. let api = index?'/api/shuaxin':'/api/chexiao';
  159. this.setState({
  160. loading:true
  161. });
  162. $.ajax({
  163. method: "POST",
  164. dataType: "json",
  165. crossDomain: false,
  166. url: globalConfig.context + api,
  167. data: {
  168. id: recard.id
  169. }
  170. }).done(function (data) {
  171. if (!data.error.length) {
  172. message.success('操作成功');
  173. this.setState({
  174. loading: false,
  175. });
  176. } else {
  177. message.warning(data.error[0].message);
  178. };
  179. this.loadData();
  180. }.bind(this));
  181. },
  182. componentWillMount() {
  183. let theArr = [];
  184. demandTypeList.map(function (item) {
  185. theArr.push(
  186. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  187. )
  188. });
  189. this.state.demandTypeOption = theArr;
  190. this.loadData();
  191. },
  192. tableRowClick(record, index) {
  193. this.state.RowData = record;
  194. this.setState({
  195. showDesc: true
  196. });
  197. },
  198. delectRow(recard) {
  199. this.setState({
  200. loading:true
  201. })
  202. $.ajax({
  203. method: "POST",
  204. dataType: "json",
  205. crossDomain: false,
  206. url: globalConfig.context + "/api/user/demand/delete",
  207. data: {
  208. ids: recard.id
  209. }
  210. }).done(function (data) {
  211. if (!data.error.length) {
  212. message.success('删除成功!');
  213. this.setState({
  214. loading: false,
  215. });
  216. } else {
  217. message.warning(data.error[0].message);
  218. };
  219. this.loadData();
  220. }.bind(this));
  221. },
  222. addClick() {
  223. this.state.RowData = {};
  224. this.setState({
  225. showDesc: true
  226. });
  227. },
  228. closeDesc(e, s) {
  229. this.state.showDesc = e;
  230. if (s) {
  231. this.loadData();
  232. };
  233. },
  234. search() {
  235. this.loadData();
  236. },
  237. reset() {
  238. this.state.name = '';
  239. this.state.releaseDate = [];
  240. this.loadData();
  241. },
  242. searchSwitch() {
  243. this.setState({
  244. searchMore: !this.state.searchMore
  245. });
  246. },
  247. render() {
  248. const rowSelection = {
  249. selectedRowKeys: this.state.selectedRowKeys,
  250. onChange: (selectedRowKeys, selectedRows) => {
  251. this.setState({
  252. selectedRows: selectedRows.slice(-1),
  253. selectedRowKeys: selectedRowKeys.slice(-1)
  254. });
  255. }
  256. };
  257. const hasSelected = this.state.selectedRowKeys.length > 0;
  258. const { RangePicker } = DatePicker;
  259. this.state.dataSource=[
  260. {key:1,serialNumber:1,id:1,auditStatus:'0'},
  261. {key:2,serialNumber:2,id:24,auditStatus:'1'},
  262. {key:3,serialNumber:3,id:23,auditStatus:'2'},
  263. {key:4,serialNumber:4,id:22,auditStatus:'3'},
  264. {key:5,serialNumber:5,id:21,auditStatus:'4'},
  265. ]
  266. return (
  267. <div className="user-content" >
  268. <div className="content-title">
  269. <span>我的科技需求</span>
  270. <div className="patent-addNew">
  271. <Button type="primary" onClick={this.addClick}>发布需求<Icon type="plus" /></Button>
  272. </div>
  273. </div>
  274. <div className="user-search">
  275. <Input placeholder="需求名称"
  276. value={this.state.name}
  277. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  278. <Button type="primary" onClick={this.search}>搜索</Button>
  279. <Button onClick={this.reset}>重置</Button>
  280. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  281. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  282. <span>发布时间 :</span>
  283. <RangePicker
  284. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  285. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  286. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  287. </div>
  288. </div>
  289. <div className="patent-table">
  290. <Spin spinning={this.state.loading}>
  291. <Table columns={this.state.columns}
  292. dataSource={this.state.dataSource}
  293. rowSelection={rowSelection}
  294. pagination={this.state.pagination}
  295. />
  296. </Spin>
  297. </div>
  298. <TechDemandDesc
  299. data={this.state.RowData}
  300. demandTypeOption={this.state.demandTypeOption}
  301. showDesc={this.state.showDesc}
  302. closeDesc={this.closeDesc} />
  303. </div >
  304. );
  305. }
  306. });
  307. export default DemandList;