intellectual.jsx 8.4 KB

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