index.jsx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import React from 'react';
  2. import { Icon, message, Button, Spin, Table } from 'antd';
  3. import Moment from 'moment';
  4. import './index.less';
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. import money from '@/money.js';
  8. import CreateDes from './createDes'
  9. const Evaluate = React.createClass({
  10. getInitialState() {
  11. return {
  12. loading: false,
  13. dataSource: [],
  14. pagination: {
  15. defaultCurrent: 1,
  16. current: 1,
  17. defaultPageSize: 10,
  18. showQuickJumper: true,
  19. pageSize: 10,
  20. onChange: function (page) {
  21. this.loadData(page);
  22. }.bind(this),
  23. showTotal: function (total) {
  24. return '共' + (total || 0) + '条数据';
  25. }
  26. },
  27. selectedRowKeys: []
  28. };
  29. },
  30. componentWillMount() {
  31. this.loadData(1);
  32. },
  33. showCreate() {
  34. if (this.props.handlekey) {
  35. this.props.handlekey('createEvaluate');
  36. }
  37. },
  38. loadData(pageNo) {
  39. if (this.state.loading) {
  40. return;
  41. }
  42. this.setState({
  43. loading: true
  44. });
  45. let { pagination } = this.state;
  46. $.ajax({
  47. url: globalConfig.context + '/api/user/evaluate/list',
  48. data: {
  49. pageNo: pageNo || 1,
  50. pageSize: pagination.pageSize,
  51. },
  52. success: function (data) {
  53. if (!data.data || !data.data.list) {
  54. return;
  55. }
  56. pagination.current = data.data.pageNo;
  57. pagination.total = data.data.totalCount;
  58. this.setState({
  59. dataSource: data.data.list,
  60. pagination: pagination
  61. });
  62. }.bind(this),
  63. }).always(function () {
  64. this.setState({
  65. loading: false
  66. });
  67. }.bind(this));
  68. },
  69. addClick() {
  70. this.state.RowData = {};
  71. this.setState({
  72. showDesc: true
  73. });
  74. },
  75. closeDesc(e, s) {
  76. this.state.showDesc = e;
  77. if (s) {
  78. this.loadData(this.state.page);
  79. };
  80. },
  81. tableRowClick(record, index) {
  82. this.state.RowData = record;
  83. this.setState({
  84. showDesc: true
  85. });
  86. },
  87. remove() {
  88. if (this.state.loading || !this.state.selectedRowKeys.length) {
  89. return;
  90. }
  91. this.setState({
  92. loading: true
  93. });
  94. $.ajax({
  95. url: globalConfig.context + '/api/user/evaluate/remove',
  96. data: {
  97. ids: this.state.selectedRowKeys.join(',')
  98. },
  99. method: 'post',
  100. success: function (res) {
  101. if (res.error && res.error.length) {
  102. message.error(res.error[0].message);
  103. } else {
  104. message.info("删除" + (res.data || 0) + '条记录。',0.1, () => {
  105. this.loadData(this.state.pagination.current);
  106. })
  107. }
  108. }.bind(this),
  109. }).always(function () {
  110. this.setState({
  111. loading: false
  112. });
  113. }.bind(this));
  114. },
  115. preview(e, it) {
  116. e.stopPropagation();
  117. e.preventDefault();
  118. window.open(globalConfig.context + '/user/account/evaluateInfo?id=' + it.id);
  119. },
  120. render() {
  121. const rowSelection = {
  122. onChange: (selectedRowKeys, selectedRows) => {
  123. this.setState({
  124. selectedRowKeys
  125. });
  126. },
  127. getCheckboxProps: record => ({
  128. disabled: record.step === 7
  129. })
  130. }, columns = [
  131. {
  132. title: '编号',
  133. dataIndex: 'id',
  134. key: 'id',
  135. }, {
  136. title: '技术名称',
  137. dataIndex: 'name',
  138. key: 'name',
  139. }, {
  140. title: '价值',
  141. dataIndex: 'value',
  142. key: 'value',
  143. render: (text, it) => { return it.value ? money(it.value) : ''; }
  144. }, {
  145. title: '预览',
  146. dataIndex: 'preview',
  147. key: 'preview',
  148. render: (text, record) => {
  149. return record.value ?
  150. <Icon type="eye-o" style={{ fontSize: 18,cursor:"pointer" }} onClick={(e) => {
  151. this.preview(e, record)
  152. }}></Icon> : <div />
  153. }
  154. }, {
  155. title: '日期',
  156. dataIndex: 'createTime',
  157. key: 'createTime',
  158. render: (text, it) => { return Moment(it.createTime).format('YYYY/MM/DD') }
  159. }
  160. ];
  161. const hasSelected = this.state.selectedRowKeys.length > 0;
  162. return (
  163. <Spin spinning={this.state.loading}>
  164. <div className="content-container">
  165. <div className="content-title">
  166. 科技评估管理列表
  167. <div className="content-actions"><Button type="primary" onClick={this.addClick}>开始新评估<Icon type="plus" /></Button></div>
  168. </div>
  169. <div className="content-search">
  170. <Button type="danger" onClick={this.remove} disabled={!hasSelected}>删除</Button>
  171. </div>
  172. <div className="content-body">
  173. <Table rowKey="id" columns={columns}
  174. dataSource={this.state.dataSource}
  175. pagination={this.state.pagination}
  176. onRowClick={this.tableRowClick}
  177. rowSelection={rowSelection} />
  178. </div>
  179. <CreateDes
  180. data={this.state.RowData}
  181. showDesc={this.state.showDesc}
  182. closeDesc={this.closeDesc} />
  183. </div>
  184. </Spin>
  185. )
  186. },
  187. });
  188. export default Evaluate;