techDemand.jsx 11 KB

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