RecommendList.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import React, { Component } from 'react';
  2. import moment from 'moment';
  3. import { connect } from 'dva';
  4. import { routerRedux } from 'dva/router';
  5. import { Card, Button, message } from 'antd';
  6. import { StandardTableList } from '../../../components/AXList';
  7. import { renderStatus, renderCategory, addRowKey } from '../../../utils/utils';
  8. const Message = message;
  9. @connect(({ loading, merchant }) => ({
  10. merchant,
  11. loading: loading.models.merchant,
  12. }))
  13. export default class MerchantListPage extends Component {
  14. constructor(props) {
  15. super(props);
  16. const { state } = props.location;
  17. this.state = {
  18. UIParams: (state || {}).UIParams, // 组件的状态参数
  19. Queryers: (state || {}).Queryers, // 查询的条件参数
  20. };
  21. }
  22. componentDidMount() {
  23. this.props.dispatch({
  24. type: 'merchant/fetchMerchantList',
  25. payload: { ...this.state.Queryers },
  26. });
  27. }
  28. handleEditRecommend = ({ id }) => {
  29. this.props.dispatch(routerRedux.push({
  30. pathname: `/frontend/recommend/edit/${id}`,
  31. state: this.state,
  32. }));
  33. }
  34. handleFilterOperation = (params, states) => {
  35. this.props.dispatch({
  36. type: 'merchant/fetchMerchantList',
  37. payload: params,
  38. });
  39. this.setState({
  40. UIParams: states,
  41. Queryers: params,
  42. });
  43. }
  44. handleBatchOperation = () => {
  45. Message.info('暂不支持批量操作!');
  46. }
  47. render() {
  48. const { loading, merchant } = this.props;
  49. const { list, totalSize, pageSize, pageNo } = merchant;
  50. const renderOperation = (item) => {
  51. return (
  52. <div>
  53. <Button
  54. type="primary"
  55. size="small"
  56. onClick={() => this.handleEditRecommend(item)}
  57. >修改推荐位
  58. </Button>
  59. </div>
  60. );
  61. };
  62. const batchActions = [{
  63. key: 'modify',
  64. name: '批量修改',
  65. }];
  66. const basicSearch = {
  67. keys: [{
  68. name: '商户编号',
  69. field: 'code',
  70. }, {
  71. name: '商户名称',
  72. field: 'name',
  73. }],
  74. };
  75. const pagination = {
  76. pageNo,
  77. pageSize,
  78. totalSize,
  79. };
  80. const columns = [{
  81. title: '商户编号',
  82. key: 1,
  83. dataIndex: 'code',
  84. width: '16%',
  85. }, {
  86. title: '商户名称',
  87. key: 2,
  88. dataIndex: 'name',
  89. width: '18%',
  90. }, {
  91. title: '商户简称',
  92. key: 3,
  93. dataIndex: 'simple',
  94. width: '16%',
  95. }, {
  96. title: '商户类型',
  97. key: 4,
  98. dataIndex: 'domain',
  99. render: text => renderCategory(text),
  100. width: '12%',
  101. }, {
  102. title: '状态',
  103. key: 5,
  104. dataIndex: 'status',
  105. render: text => renderStatus(text),
  106. width: '12%',
  107. }, {
  108. title: '更新时间',
  109. key: 6,
  110. dataIndex: 'gmtModified',
  111. render: text => moment(text).format('YYYY-MM-DD HH:mm:ss'),
  112. width: '16%',
  113. }, {
  114. title: '操作',
  115. key: 7,
  116. dataIndex: 'operation',
  117. render: (_, record) => renderOperation(record),
  118. width: '10%',
  119. align: 'right',
  120. }];
  121. return (
  122. <Card>
  123. <StandardTableList
  124. columns={columns}
  125. loading={loading}
  126. dataSource={addRowKey(list)}
  127. header={{
  128. basicSearch,
  129. onFilterClick: this.handleFilterOperation,
  130. }}
  131. footer={{
  132. pagination,
  133. batchActions,
  134. onBatchClick: this.handleBatchOperation,
  135. }}
  136. keepUIState={{ ...this.state.UIParams }}
  137. />
  138. </Card>
  139. );
  140. }
  141. }