AccountsTerminals.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import React, { Component } from 'react';
  2. import moment from 'moment';
  3. import { connect } from 'dva';
  4. import { Card, Badge } from 'antd';
  5. import { StandardTableList } from '../../../components/AXList';
  6. import { addRowKey } from '../../../utils/utils';
  7. import styles from './AccountsTerminals.less';
  8. @connect(({ loading, accounts }) => ({
  9. accounts,
  10. loading: loading.models.accounts,
  11. }))
  12. export default class TerminalsAccountsPage extends Component {
  13. constructor(props) {
  14. super(props);
  15. const { state } = props.location;
  16. this.state = {
  17. UIParams: (state || {}).UIParams, // 组件的状态参数
  18. Queryers: (state || {}).Queryers, // 查询的条件参数
  19. };
  20. }
  21. componentWillMount() {
  22. this.props.dispatch({
  23. type: 'accounts/fetchTerminalsList',
  24. payload: { ...this.state.Queryers }
  25. })
  26. }
  27. // 下载
  28. handleDownloadOperation = () => {
  29. this.props.dispatch({
  30. type: 'accounts/fetchTerminalsExcel',
  31. })
  32. };
  33. handleFilterOperation = (params, states) => {
  34. this.setState({
  35. UIParams: states,
  36. Queryers: params,
  37. });
  38. this.props.dispatch({
  39. type: 'accounts/fetchTerminalsList',
  40. payload: {
  41. ...params,
  42. },
  43. });
  44. };
  45. render() {
  46. const { loading,accounts } = this.props;
  47. const { list, totalSize, pageSize, pageNo } = accounts;
  48. const basicSearch = {
  49. keys: [{
  50. name: '终端编号',
  51. field: 'code',
  52. }],
  53. };
  54. const pagination = {
  55. pageNo,
  56. pageSize,
  57. totalSize,
  58. };
  59. const columns = [{
  60. title: '终端编号',
  61. key: 1,
  62. dataIndex: 'ucode',
  63. width: '15%',
  64. }, {
  65. title: '课程包编号',
  66. key: 2,
  67. dataIndex: 'pcode',
  68. width: '10%',
  69. }, {
  70. title: '课程包名称',
  71. key: 3,
  72. dataIndex: 'pname',
  73. width: '15%',
  74. }, {
  75. title: '权限有效期',
  76. key: 4,
  77. render: (_, record) => {
  78. const { startTimeStr, endTimeStr } = record;
  79. return (
  80. <div className={styles.authDesc}>
  81. <p><span>起始时间:&nbsp;&nbsp;</span>{`${startTimeStr}`}</p>
  82. <p><span>到期时间:&nbsp;&nbsp;</span>{`${endTimeStr}`}</p>
  83. </div>
  84. );
  85. },
  86. dataIndex: 'cityName',
  87. width: '15%',
  88. align: 'center',
  89. }, {
  90. title: '权限有效时长',
  91. key: 5,
  92. dataIndex: 'endTime',
  93. render: (text) => {
  94. const day = moment(text).diff(moment(), 'days');
  95. if (day < 0) {
  96. return <Badge status="error" text="已到期" />;
  97. }
  98. return <span><span style={{ color: '#52c41a', fontWeight: 'bold' }}>{day}</span>天到期</span>;
  99. },
  100. width: '10%',
  101. }, {
  102. title: '校区名称',
  103. key: 6,
  104. dataIndex: 'campusName',
  105. width: '16%',
  106. }, {
  107. title: '联系电话',
  108. key: 7,
  109. dataIndex: 'campusContactWay',
  110. width: '12%',
  111. }, {
  112. title: '联系人',
  113. key: 8,
  114. dataIndex: 'campusContactName',
  115. width: '6%',
  116. }];
  117. return (
  118. <Card>
  119. <StandardTableList
  120. columns={columns}
  121. loading={loading}
  122. dataSource={addRowKey(list)}
  123. header={{
  124. basicSearch,
  125. onFilterClick: this.handleFilterOperation,
  126. onDownload: this.handleDownloadOperation,
  127. }}
  128. footer={{
  129. pagination,
  130. }}
  131. keepUIState={{ ...this.state.UIParams }}
  132. showStatusSelect={false}
  133. />
  134. </Card>
  135. );
  136. }
  137. }