techAchievement.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 './techAchievement.less';
  7. import TechAchievementDesc from './techAchievementDesc.jsx';
  8. import { achievementCategoryList, techAuditStatusList } from '../../dataDic.js';
  9. import { getAchievementCategory, getTechAuditStatus } from '../../tools.js';
  10. const AchievementList = 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/achievement/list',
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. serialNumber: this.state.serialNumber, //编号
  25. name: this.state.name, //名称
  26. keyword: this.state.keyword, // 关键词
  27. category: this.state.category, //类型(0--专利, 2--软著, 3--项目, 4--版权, 5--工业设计, 6--配方, 7--非标)
  28. releaseDateStartDate: this.state.releaseDate[0],
  29. releaseDateEndDate: this.state.releaseDate[1],
  30. releaseStatus: this.state.releaseStatus ? Number(this.state.releaseStatus) : undefined, //是否发布(0--未发布,1--已发布)
  31. auditStatus: this.state.auditStatus
  32. },
  33. success: function (data) {
  34. let theArr = [];
  35. if (!data.data || !data.data.list) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. };
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. theArr.push({
  43. key: i,
  44. id: thisdata.id,
  45. serialNumber: thisdata.serialNumber,
  46. dataCategory: thisdata.dataCategory,
  47. name: thisdata.name,
  48. keyword: thisdata.keyword,
  49. category: thisdata.category,
  50. ownerName: thisdata.ownerName,
  51. ownerType: thisdata.ownerType,
  52. ownerMobile: thisdata.ownerMobile,
  53. status: thisdata.status,
  54. releaseDate: thisdata.releaseDate,
  55. releaseDateFormattedDate: thisdata.releaseDateFormattedDate,
  56. auditStatus: thisdata.auditStatus
  57. });
  58. };
  59. }
  60. this.state.pagination.current = data.data.pageNo;
  61. this.state.pagination.total = data.data.totalCount;
  62. this.setState({
  63. dataSource: theArr,
  64. pagination: this.state.pagination
  65. });
  66. }.bind(this),
  67. }).always(function () {
  68. this.setState({
  69. loading: false
  70. });
  71. }.bind(this));
  72. },
  73. getInitialState() {
  74. return {
  75. searchMore: true,
  76. validityPeriodDate: [],
  77. releaseDate: [],
  78. selectedRowKeys: [],
  79. selectedRows: [],
  80. loading: false,
  81. pagination: {
  82. defaultCurrent: 1,
  83. defaultPageSize: 10,
  84. showQuickJumper: true,
  85. pageSize: 10,
  86. onChange: function (page) {
  87. this.loadData(page);
  88. }.bind(this),
  89. showTotal: function (total) {
  90. return '共' + total + '条数据';
  91. }
  92. },
  93. columns: [
  94. {
  95. title: '编号',
  96. dataIndex: 'serialNumber',
  97. key: 'serialNumber',
  98. }, {
  99. title: '名称',
  100. dataIndex: 'name',
  101. key: 'name',
  102. }, {
  103. title: '关键字',
  104. dataIndex: 'keyword',
  105. key: 'keyword',
  106. }, {
  107. title: '类型',
  108. dataIndex: 'category',
  109. key: 'category',
  110. render: text => { return getAchievementCategory(text); }
  111. }, {
  112. title: '审核状态',
  113. dataIndex: 'auditStatus',
  114. key: 'auditStatus',
  115. render: text => { return getTechAuditStatus(text) }
  116. }, {
  117. title: '发布时间',
  118. dataIndex: 'releaseDateFormattedDate',
  119. key: 'releaseDateFormattedDate',
  120. }
  121. ],
  122. dataSource: [],
  123. searchTime: [,]
  124. };
  125. },
  126. componentWillMount() {
  127. let theArr = [];
  128. achievementCategoryList.map(function (item) {
  129. theArr.push(
  130. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  131. )
  132. });
  133. let auditArr = [];
  134. techAuditStatusList.map(function (item) {
  135. auditArr.push(
  136. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  137. )
  138. });
  139. this.state.achievementCategoryOption = theArr;
  140. this.state.auditStatusOption = auditArr;
  141. this.loadData();
  142. },
  143. tableRowClick(record, index) {
  144. this.state.RowData = record;
  145. this.setState({
  146. showDesc: true
  147. });
  148. },
  149. delectRow() {
  150. let deletedIds = [];
  151. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  152. let rowItem = this.state.selectedRows[idx];
  153. if (rowItem.id) {
  154. deletedIds.push(rowItem.id)
  155. };
  156. };
  157. this.setState({
  158. selectedRowKeys: [],
  159. loading: deletedIds.length > 0
  160. });
  161. $.ajax({
  162. method: "POST",
  163. dataType: "json",
  164. crossDomain: false,
  165. url: globalConfig.context + "/api/user/achievement/delete",
  166. data: {
  167. ids: deletedIds
  168. }
  169. }).done(function (data) {
  170. if (!data.error.length) {
  171. message.success('删除成功!');
  172. this.setState({
  173. loading: false,
  174. });
  175. } else {
  176. message.warning(data.error[0].message);
  177. };
  178. this.loadData();
  179. }.bind(this));
  180. },
  181. addClick() {
  182. this.state.RowData = {};
  183. this.setState({
  184. showDesc: true
  185. });
  186. },
  187. closeDesc(e, s) {
  188. this.state.showDesc = e;
  189. if (s) {
  190. this.loadData();
  191. };
  192. },
  193. search() {
  194. this.loadData();
  195. },
  196. reset() {
  197. this.state.serialNumber = undefined;
  198. this.state.name = undefined;
  199. this.state.keyword = undefined;
  200. this.state.category = undefined;
  201. this.state.ownerType = undefined;
  202. this.state.releaseStatus = undefined;
  203. this.state.releaseDate = [];
  204. this.state.auditStatus = undefined;
  205. this.loadData();
  206. },
  207. searchSwitch() {
  208. this.setState({
  209. searchMore: !this.state.searchMore
  210. });
  211. },
  212. downLoadFile() {
  213. window.open(globalConfig.context + '/api/user/achievement/downloadTemplate?sign=achievement_template')
  214. },
  215. render() {
  216. const rowSelection = {
  217. selectedRowKeys: this.state.selectedRowKeys,
  218. onChange: (selectedRowKeys, selectedRows) => {
  219. this.setState({
  220. selectedRows: selectedRows.slice(-1),
  221. selectedRowKeys: selectedRowKeys.slice(-1)
  222. });
  223. }
  224. };
  225. const hasSelected = this.state.selectedRowKeys.length > 0;
  226. const { RangePicker } = DatePicker;
  227. return (
  228. <div className="user-content" >
  229. <div className="content-title">
  230. <span>科技成果管理</span>
  231. <div className="patent-addNew">
  232. <Button onClick={this.downLoadFile}>下载批量导入模板</Button>
  233. <Button className="addButton" type="primary" onClick={this.addClick}>发布成果<Icon type="plus" /></Button>
  234. </div>
  235. </div>
  236. <div className="user-search">
  237. <Input placeholder="编号"
  238. value={this.state.serialNumber}
  239. onChange={(e) => { this.setState({ serialNumber: e.target.value }); }} />
  240. <Input placeholder="名称"
  241. value={this.state.name}
  242. onChange={(e) => { this.setState({ name: e.target.value }); }} />
  243. <Input placeholder="关键字"
  244. value={this.state.keyword}
  245. onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
  246. <Select placeholder="选择类型" style={{ width: 160 }}
  247. value={this.state.category}
  248. onChange={(e) => { this.setState({ category: e }) }}>
  249. {this.state.achievementCategoryOption}
  250. </Select>
  251. <Select placeholder="选择审核状态"
  252. style={{ width: 160 }}
  253. value={this.state.auditStatus}
  254. onChange={(e) => { this.setState({ auditStatus: e }) }}>
  255. {this.state.auditStatusOption}
  256. </Select>
  257. <Select placeholder="选择是否发布" style={{ width: 120 }}
  258. value={this.state.releaseStatus}
  259. onChange={(e) => { this.setState({ releaseStatus: e }) }}>
  260. <Select.Option value="0" >未发布</Select.Option>
  261. <Select.Option value="1" >已发布</Select.Option>
  262. </Select>
  263. <Button type="primary" onClick={this.search}>搜索</Button>
  264. <Button onClick={this.reset}>重置</Button>
  265. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  266. disabled={!hasSelected}
  267. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  268. <span>更多搜索<Switch defaultChecked={false} onChange={this.searchSwitch} /></span>
  269. <div className="search-more" style={this.state.searchMore ? { display: 'none' } : {}}>
  270. <span>发布时间 :</span>
  271. <RangePicker
  272. value={[this.state.releaseDate[0] ? moment(this.state.releaseDate[0]) : null,
  273. this.state.releaseDate[1] ? moment(this.state.releaseDate[1]) : null]}
  274. onChange={(data, dataString) => { this.setState({ releaseDate: dataString }); }} />
  275. </div>
  276. </div>
  277. <div className="patent-table">
  278. <Spin spinning={this.state.loading}>
  279. <Table size="middle" columns={this.state.columns}
  280. dataSource={this.state.dataSource}
  281. rowSelection={rowSelection}
  282. pagination={this.state.pagination}
  283. style={{
  284. cursor: 'pointer',
  285. }}
  286. onRowClick={this.tableRowClick} />
  287. </Spin>
  288. </div>
  289. <TechAchievementDesc
  290. data={this.state.RowData}
  291. achievementCategoryOption={this.state.achievementCategoryOption}
  292. showDesc={this.state.showDesc}
  293. closeDesc={this.closeDesc} />
  294. </div >
  295. );
  296. }
  297. });
  298. export default AchievementList;