techAchievement.jsx 14 KB

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