AccountManagement.jsx 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import React, { useState, useEffect } from 'react';
  2. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  3. import { Form, Pagination, Card, Button, Icon, Tooltip, message, notification, Modal, Table, Select, Input, DatePicker } from 'antd';
  4. import router from 'umi/router';
  5. import moment from 'moment';
  6. import className from 'classnames';
  7. import Cell from '../../components/Cell';
  8. import styles from './style.less';
  9. import { fetch, apis } from '../../utils/request';
  10. import request from '../../utils/request';
  11. import AuthButton from '@/components/AuthButton';
  12. import Recharge from './components/Recharge'
  13. import Refund from './components/Refund'
  14. import { regFenToYuan } from '@/utils/money';
  15. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
  16. function header(props) {
  17. // 获取初始化数据
  18. const [data, setData] = useState({})
  19. const [demandIdList, setDemandIdList] = useState([])
  20. useEffect(() => {
  21. getList({ pageNum: 1, pageSize: 10 });
  22. }, [])
  23. // 查询列表
  24. const getList = (params) => {
  25. request({ ...apis.fund.account, params: { ...params } }).then((data) => {
  26. console.log(data)
  27. setData(data)
  28. })
  29. }
  30. // 提交事件
  31. const handleSubmit = (e, props) => {
  32. e.preventDefault();
  33. props.form.validateFields((err, values) => {
  34. if (!err) {
  35. let { miniAppName } = values
  36. getList({ pageNum: 1, pageSize: 10, miniAppName, })
  37. }
  38. });
  39. }
  40. const changePageNum = (pageNumber) => {
  41. let { miniAppName } = props.form.getFieldsValue()
  42. getList({ pageNum: pageNumber, pageSize: 10, miniAppName, })
  43. }
  44. /**
  45. *
  46. *
  47. * @param {*} props
  48. * @returns
  49. */
  50. const columns = [
  51. {
  52. title: '账户',
  53. dataIndex: 'miniappName',
  54. key: 'miniappName',
  55. align: 'center',
  56. render: (x, row) => (
  57. <>
  58. <span style={{ color: '#FF925C', cursor: 'pointer', marginRight: '16px' }} onClick={() => toDeatil(row)} >
  59. {row.miniappName}
  60. </span>
  61. </>
  62. ),
  63. },
  64. {
  65. title: '总充值金额',
  66. dataIndex: 'totalRechargeAmount',
  67. key: 'totalRechargeAmount',
  68. align: 'center',
  69. render: (x, row) => <span>{regFenToYuan(x)}</span>
  70. },
  71. {
  72. title: '已消费金额',
  73. dataIndex: 'purchaseAmount',
  74. key: 'purchaseAmount',
  75. align: 'center',
  76. render: (x, row) => <span>{regFenToYuan(x)}</span>
  77. },
  78. {
  79. title: '已退款金额',
  80. dataIndex: 'totalRefund',
  81. key: 'totalRefund',
  82. align: 'center',
  83. render: (x, row) => <span>{regFenToYuan(x)}</span>
  84. },
  85. {
  86. title: '余额',
  87. dataIndex: 'realBalance',
  88. key: 'realBalance',
  89. align: 'center',
  90. render: (x, row) => <span>{regFenToYuan(x)}</span>
  91. },
  92. {
  93. title: '操作',
  94. dataIndex: 'handle',
  95. key: 'handle',
  96. align: 'center',
  97. width: '120px',
  98. render: (x, row) => (
  99. <>
  100. <span style={{ color: '#FF925C', cursor: 'pointer', marginRight: '16px', display: 'inline-block' }}><Recharge onClick={handleReset} orgId={row.orgId} accountId={row.accountId} /></span>
  101. <span style={{ color: '#FF925C', cursor: 'pointer', display: 'inline-block' }} >
  102. <Refund orgId={row.orgId} accountId={row.accountId} onClick={handleReset} realBalance={row.realBalance || '0'} />
  103. </span>
  104. </>
  105. ),
  106. },
  107. ];
  108. function handleReset() {
  109. props.form.resetFields();
  110. getList({ pageNum: 1, pageSize: 10 })
  111. }
  112. const toDeatil = (row) => {
  113. router.push({
  114. pathname: '/fundManagement/AccountDetail',
  115. query: {
  116. id: row.orgId
  117. },
  118. });
  119. }
  120. const { getFieldDecorator } = props.form
  121. return (
  122. <>
  123. <Form layout="inline" onSubmit={e => handleSubmit(e, props)} style={{ marginBottom: '16px' }}>
  124. <Form.Item>
  125. {getFieldDecorator('miniAppName')(
  126. <Input
  127. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  128. placeholder="输入小程序名"
  129. />,
  130. )}
  131. </Form.Item>
  132. <Form.Item>
  133. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  134. 搜索
  135. </Button>
  136. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  137. 重置
  138. </Button>
  139. </Form.Item>
  140. </Form>
  141. <Table rowKey={r => r.accountId} dataSource={data.records} columns={columns} pagination={false} />
  142. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  143. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
  144. </div>
  145. </>
  146. )
  147. }
  148. const WrappedHeader = Form.create({ name: 'header' })(header);
  149. export default WrappedHeader