intellectual.jsx 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import React from 'react';
  2. import { Switch, Icon, Button, Input, Spin, Table, message, Select, Modal, DatePicker } from 'antd';
  3. import { technicalSourceList } from '../../../../dataDic.js';
  4. import { getCatagory, getIntellectualObtainWay, getProportion, saveProportion } 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. let _me = this;
  64. getProportion(this.props.data.uid, function (data) { _me.setState({ proportion: data }); });
  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/admin/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. <span className="proportion"> 是否已完成:</span>
  190. <Switch
  191. checked={this.state.proportion && this.state.proportion.intellectualProperty == 1 ? true : false}
  192. checkedChildren={'已完成'}
  193. unCheckedChildren={'未完成'}
  194. onChange={(e) => {
  195. e ? this.state.proportion.intellectualProperty = 1 : this.state.proportion.intellectualProperty = 0;
  196. saveProportion(this.state.proportion.id, this.props.data.uid, 'intellectualProperty', this.state.proportion.intellectualProperty);
  197. this.setState({ proportion: this.state.proportion });
  198. }} />
  199. <span className="link">
  200. <a href="http://www2.soopat.com/Home/IIndex" target="_blank">SOOPAT</a>
  201. <a href="http://www.baiten.cn/" target="_blank">佰腾网</a>
  202. <a href="http://www.sipo.gov.cn/" target="_blank">国家知识产权局</a>
  203. <a href="http://www.ccopyright.com.cn/" target="_blank">中国版权保护中心</a>
  204. </span>
  205. </div>
  206. <div className="user-search">
  207. <span>开始日期:</span>
  208. <DatePicker
  209. value={this.state.startDateFormattedDate ? moment(this.state.startDateFormattedDate) : null}
  210. onChange={(data, dataString) => { this.setState({ startDateFormattedDate: dataString }); }} />
  211. <span>结束日期:</span>
  212. <DatePicker
  213. value={this.state.endDateFormattedDate ? moment(this.state.endDateFormattedDate) : null}
  214. onChange={(data, dataString) => { this.setState({ endDateFormattedDate: dataString }); }} />
  215. <Button type="primary" onClick={this.search}>搜索</Button>
  216. <Button onClick={this.reset}>重置</Button>
  217. <p>
  218. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  219. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  220. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  221. disabled={!hasSelected}
  222. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  223. </p>
  224. </div>
  225. <div className="patent-table">
  226. <Spin spinning={this.state.loading}>
  227. <Table columns={this.state.columns}
  228. dataSource={this.state.dataSource}
  229. pagination={this.state.pagination}
  230. rowSelection={rowSelection}
  231. onRowClick={this.tableRowClick} />
  232. </Spin>
  233. </div>
  234. <IntellectualDesc uid={this.props.data.uid} data={this.state.RowData} showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  235. </div >
  236. );
  237. }
  238. });
  239. export default Intellectual;