intellectual.jsx 8.4 KB

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