RechargeOrder.jsx 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import React, { useState, useEffect } from 'react';
  2. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  3. import { Form, Pagination, Button, Icon, message, 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 { regFenToYuan } from '@/utils/money';
  13. import Swiper from './components/Swiper';
  14. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
  15. function header(props) {
  16. // 获取初始化数据
  17. const [data, setData] = useState({})
  18. const [demandIdList, setDemandIdList] = useState([])
  19. const [swiperList, setSwiperList] = useState([])
  20. const orgId = props.orgId || ''
  21. useEffect(() => {
  22. getList({ pageNum: 1, pageSize: 10, orderType: 'recharge' });
  23. }, [])
  24. // 查询列表
  25. const getList = (params) => {
  26. request({ ...apis.fund.taOrgOrder, params: { ...params, orgId } }).then((data) => {
  27. console.log(data)
  28. setData(data)
  29. })
  30. }
  31. // 提交事件
  32. const handleSubmit = (e, props) => {
  33. e.preventDefault();
  34. props.form.validateFields((err, values) => {
  35. if (!err) {
  36. let { LocalDate, ...submitValue } = values
  37. if (null != LocalDate && LocalDate.length > 0) {
  38. const [startDate, endDate] = LocalDate
  39. submitValue.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00')}Z`;
  40. submitValue.endDate = `${moment(endDate).format('YYYY-MM-DDT23:59:59')}Z`;
  41. } else {
  42. submitValue.startDate = null
  43. submitValue.endDate = null
  44. }
  45. getList({ pageNum: 1, pageSize: 10, orderType: 'recharge', ...submitValue })
  46. }
  47. });
  48. }
  49. const changePageNum = pageNumber => {
  50. const { LocalDate, ...submitValue } = props.form.getFieldsValue()
  51. if (LocalDate != null && LocalDate.length > 0) {
  52. const [startDate, endDate] = LocalDate
  53. submitValue.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00')}Z`;
  54. submitValue.endDate = `${moment(endDate).format('YYYY-MM-DDT23:59:59')}Z`;
  55. } else {
  56. submitValue.startDate = null
  57. submitValue.endDate = null
  58. }
  59. getList({ pageNum: pageNumber, pageSize: 10, orderType: 'recharge', ...submitValue })
  60. }
  61. const look = (list) => {
  62. // setSwiperList([
  63. // 'https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1591688474&di=85bb9a6a9736e51c63a7bac09601f1e7&src=http://a3.att.hudong.com/14/75/01300000164186121366756803686.jpg',
  64. // 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591698586868&di=f528c96c3004268843a070c342b905fa&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg',
  65. // 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591698586867&di=7865b3f07e4b6b050642a042fa30f07e&imgtype=0&src=http%3A%2F%2Fa0.att.hudong.com%2F64%2F76%2F20300001349415131407760417677.jpg'
  66. // ])
  67. setSwiperList(list)
  68. }
  69. /**
  70. *
  71. *
  72. * @param {*} props
  73. * @returns
  74. */
  75. const columns = [
  76. {
  77. title: '订单编号',
  78. dataIndex: 'tradeNo',
  79. key: 'tradeNo',
  80. align: 'center',
  81. },
  82. {
  83. title: '充值组织',
  84. dataIndex: 'miniAppName',
  85. key: 'miniAppName',
  86. align: 'center',
  87. },
  88. {
  89. title: '充值金额',
  90. dataIndex: 'amount',
  91. key: 'amount',
  92. align: 'center',
  93. render: (x, row) => <span>{regFenToYuan(x)}</span>
  94. },
  95. {
  96. title: '充值方式',
  97. dataIndex: 'isOffline',
  98. key: 'isOffline',
  99. align: 'center',
  100. render: (x, row) => <><span>{row.isOffline ? '运营手工充值' : '业务线上充值'}</span></>
  101. },
  102. {
  103. title: '下单时间',
  104. dataIndex: 'createDate',
  105. key: 'createDate',
  106. align: 'center',
  107. render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
  108. },
  109. {
  110. title: '充值凭证',
  111. dataIndex: 'certificateUrlList',
  112. key: 'certificateUrlList',
  113. align: 'center',
  114. render: (x, row) => (
  115. <>
  116. {
  117. (x || []).length > 0 &&
  118. <>
  119. <span className={styles.blue} onClick={() => look(row.certificateUrlList)}>
  120. 查看
  121. </span></>
  122. }
  123. </>
  124. ),
  125. },
  126. {
  127. title: '充值状态',
  128. dataIndex: 'tradingStatus',
  129. key: 'tradingStatus',
  130. align: 'center',
  131. render: (x, row) => <><span>{row.tradingStatus == 'processing' ? '待支付' : row.tradingStatus == 'success' ? '已支付' : '失败'}</span></>
  132. },
  133. {
  134. title: '支付时间',
  135. dataIndex: 'payDate',
  136. key: 'payDate',
  137. align: 'center',
  138. render: (x, row) => <><span>{row.payDate ? `${moment(row.payDate).format('YYYY-MM-DD HH:mm:ss')}` : ''}</span></>,
  139. },
  140. ];
  141. function handleReset() {
  142. props.form.resetFields();
  143. getList({ pageNum: 1, pageSize: 10, orderType: 'recharge' })
  144. }
  145. // 导出
  146. const exportList = () => {
  147. let { LocalDate, ...submitValue } = props.form.getFieldsValue()
  148. if (null != LocalDate && LocalDate.length > 0) {
  149. const [startDate, endDate] = LocalDate
  150. submitValue.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00')}Z`;
  151. submitValue.endDate = `${moment(endDate).format('YYYY-MM-DDT23:59:59')}Z`;
  152. } else {
  153. submitValue.startDate = null
  154. submitValue.endDate = null
  155. }
  156. request({ ...apis.fund.rechargeOrderExport, params: { orderType: 'recharge', orgId, ...submitValue } }).then(data => {
  157. if (!data) {
  158. return
  159. }
  160. const url = window.URL.createObjectURL(new Blob([data]))
  161. const link = document.createElement('a')
  162. link.style.display = 'none'
  163. link.href = url
  164. link.setAttribute('download', '充值订单表.xlsx')
  165. document.body.append(link)
  166. link.click()
  167. }).catch()
  168. }
  169. const { getFieldDecorator } = props.form
  170. return (
  171. <>
  172. < Swiper list={swiperList} onClose={() => setSwiperList([])} />
  173. <Form layout="inline" onSubmit={e => handleSubmit(e, props)} style={{ marginBottom: '16px' }}>
  174. <Form.Item>
  175. {getFieldDecorator('tradeNo')(
  176. <Input
  177. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  178. placeholder="订单编号"
  179. />,
  180. )}
  181. </Form.Item>
  182. <Form.Item>
  183. {getFieldDecorator('miniAppName')(
  184. <Input
  185. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  186. placeholder="充值组织"
  187. />,
  188. )}
  189. </Form.Item>
  190. <Form.Item>
  191. <span style={{ marginRight: '10px' }}>支付时间段:</span>
  192. {getFieldDecorator('LocalDate')(
  193. <RangePicker placeholder={['开始时间', '结束时间']} />
  194. )}
  195. </Form.Item>
  196. <Form.Item>
  197. {getFieldDecorator('isOffline')(
  198. <Select style={{ width: '180px' }} placeholder="充值方式">
  199. <Select.Option value="">全部</Select.Option>
  200. <Select.Option value="0">业务线上充值</Select.Option>
  201. <Select.Option value="1">运营手工充值</Select.Option>
  202. </Select>,
  203. )}
  204. </Form.Item>
  205. <Form.Item>
  206. {getFieldDecorator('tradingStatus')(
  207. <Select style={{ width: '180px' }} placeholder="充值状态">
  208. <Select.Option value="">全部</Select.Option>
  209. <Select.Option value="processing">待支付</Select.Option>
  210. <Select.Option value="success">已支付</Select.Option>
  211. <Select.Option value="fail">失败</Select.Option>
  212. </Select>,
  213. )}
  214. </Form.Item>
  215. <Form.Item>
  216. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  217. 搜索
  218. </Button>
  219. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  220. 重置
  221. </Button>
  222. </Form.Item>
  223. </Form>
  224. <div>
  225. <Button type="danger" style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} onClick={() => exportList()} >导出</Button>
  226. </div>
  227. <Table rowKey={r => r.tradeNo} dataSource={data.records} columns={columns} pagination={false} />
  228. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  229. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
  230. </div>
  231. </>
  232. )
  233. }
  234. const WrappedHeader = Form.create({ name: 'header' })(header);
  235. export default WrappedHeader