intellectual.jsx 8.6 KB

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