intellectual.jsx 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import React from 'react';
  2. import { Icon, Button, Input, Spin, Table, message, Select, Modal, DatePicker } from 'antd';
  3. import { technicalSourceList } from '../../dataDic.js';
  4. import { getCatagory, getIntellectualObtainWay } from '../../tools.js';
  5. import './intellectual.less';
  6. import moment from 'moment';
  7. import ajax from 'jquery/src/ajax/xhr.js';
  8. import $ from 'jquery/src/ajax';
  9. import IntellectualDesc from './intellectualDesc.jsx';
  10. const Intellectual = 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/cognizance/intellectualList",
  21. data: {
  22. pageNo: pageNo || 1,
  23. pageSize: this.state.pagination.pageSize,
  24. startDate: this.state.startDateFormattedDate,
  25. endDate: this.state.endDateFormattedDate
  26. }
  27. }).done((data) => {
  28. if (!data.data) {
  29. if (data.error && data.error.length) {
  30. message.warning(data.error[0].message);
  31. this.state.ButtonDisabled = true;
  32. }
  33. return;
  34. };
  35. for (let i = 0; i < data.data.list.length; i++) {
  36. let thisdata = data.data.list[i];
  37. this.state.data.push({
  38. key: i,
  39. id: thisdata.id,
  40. uid: thisdata.uid,
  41. intellectualPropertyNumber: thisdata.intellectualPropertyNumber,
  42. intellectualPropertyName: thisdata.intellectualPropertyName,
  43. sortNumber: thisdata.sortNumber,
  44. catagory: thisdata.catagory,
  45. obtainWay: thisdata.obtainWay,
  46. authorizationNumber: thisdata.authorizationNumber,
  47. authorizationDate: thisdata.authorizationDate,
  48. evaluationCategory: thisdata.evaluationCategory,
  49. authorizationDateFormattedDate: thisdata.authorizationDateFormattedDate,
  50. propertyRightUrl: thisdata.propertyRightUrl,
  51. propertyRightDownloadFileName: thisdata.propertyRightDownloadFileName
  52. });
  53. };
  54. this.state.pagination.current = data.data.pageNo;
  55. this.state.pagination.total = data.data.totalCount;
  56. this.setState({
  57. dataSource: this.state.data,
  58. pagination: this.state.pagination
  59. });
  60. }).always(function () {
  61. this.setState({
  62. loading: false
  63. });
  64. }.bind(this));
  65. },
  66. getInitialState() {
  67. return {
  68. selectedRowKeys: [],
  69. selectedRows: [],
  70. loading: false,
  71. pagination: {
  72. defaultCurrent: 1,
  73. defaultPageSize: 10,
  74. showQuickJumper: true,
  75. pageSize: 10,
  76. onChange: function (page) {
  77. this.loadData(page);
  78. }.bind(this),
  79. showTotal: function (total) {
  80. return '共' + total + '条数据';
  81. }
  82. },
  83. columns: [
  84. {
  85. title: '知识产权编号',
  86. dataIndex: 'intellectualPropertyNumber',
  87. key: 'intellectualPropertyNumber'
  88. }, {
  89. title: '知识产权名称',
  90. dataIndex: 'intellectualPropertyName',
  91. key: 'intellectualPropertyName'
  92. }, {
  93. title: '排序号',
  94. dataIndex: 'sortNumber',
  95. key: 'sortNumber'
  96. }, {
  97. title: '知识产权类型',
  98. dataIndex: 'catagory',
  99. key: 'catagory',
  100. render: text => { return getCatagory(text) }
  101. }, {
  102. title: '获取方式',
  103. dataIndex: 'obtainWay',
  104. key: 'obtainWay',
  105. render: text => { return getIntellectualObtainWay(text) }
  106. }, {
  107. title: '授权号',
  108. dataIndex: 'authorizationNumber',
  109. key: 'authorizationNumber'
  110. }, {
  111. title: '授权时间',
  112. dataIndex: 'authorizationDateFormattedDate',
  113. key: 'authorizationDateFormattedDate'
  114. }
  115. ],
  116. dataSource: []
  117. };
  118. },
  119. componentWillMount() {
  120. this.loadData();
  121. },
  122. tableRowClick(record, index) {
  123. this.state.RowData = record;
  124. this.setState({
  125. showDesc: true
  126. });
  127. },
  128. delectRow() {
  129. let deletedIds = [];
  130. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  131. let rowItem = this.state.selectedRows[idx];
  132. if (rowItem.id) {
  133. deletedIds.push(rowItem.id)
  134. }
  135. }
  136. this.setState({
  137. selectedRowKeys: [],
  138. loading: deletedIds.length > 0
  139. });
  140. $.ajax({
  141. method: "POST",
  142. dataType: "json",
  143. crossDomain: false,
  144. url: globalConfig.context + "/api/user/cognizance/deleteIntellectual",
  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. closeDesc(e, s) {
  161. this.state.showDesc = e;
  162. if (s) {
  163. this.loadData();
  164. };
  165. },
  166. search() {
  167. this.loadData();
  168. },
  169. reset() {
  170. this.state.startDateFormattedDate = undefined;
  171. this.state.endDateFormattedDate = undefined;
  172. this.loadData();
  173. },
  174. render() {
  175. const rowSelection = {
  176. selectedRowKeys: this.state.selectedRowKeys,
  177. onChange: (selectedRowKeys, selectedRows) => {
  178. this.setState({
  179. selectedRows: selectedRows,
  180. selectedRowKeys: selectedRowKeys
  181. });
  182. }
  183. };
  184. const hasSelected = this.state.selectedRowKeys.length > 0;
  185. return (
  186. <div className="user-content" >
  187. <div className="content-title">
  188. <span>知识产权列表</span>
  189. <Button
  190. disabled={this.state.ButtonDisabled}
  191. style={{ background: "#ea0862", border: "none", color: "#fff", float: "right" }}
  192. onClick={this.tableRowClick}>添加知识产权<Icon type="plus" /></Button>
  193. </div>
  194. <div className="user-search">
  195. <span>开始日期:</span>
  196. <DatePicker
  197. value={this.state.startDateFormattedDate ? moment(this.state.startDateFormattedDate) : null}
  198. onChange={(data, dataString) => { this.setState({ startDateFormattedDate: dataString }); }} />
  199. <span>结束日期:</span>
  200. <DatePicker
  201. value={this.state.endDateFormattedDate ? moment(this.state.endDateFormattedDate) : null}
  202. onChange={(data, dataString) => { this.setState({ endDateFormattedDate: dataString }); }} />
  203. <Button type="primary" onClick={this.search}>搜索</Button>
  204. <Button onClick={this.reset}>重置</Button>
  205. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  206. disabled={!hasSelected}
  207. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  208. </div>
  209. <div className="patent-table">
  210. <Spin spinning={this.state.loading}>
  211. <Table columns={this.state.columns}
  212. dataSource={this.state.dataSource}
  213. pagination={this.state.pagination}
  214. rowSelection={rowSelection}
  215. onRowClick={this.tableRowClick} />
  216. </Spin>
  217. </div>
  218. <IntellectualDesc data={this.state.RowData} showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  219. </div >
  220. );
  221. }
  222. });
  223. export default Intellectual;