intellectual.jsx 8.6 KB

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