知与行后台管理端

RefundOrder.jsx 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, Breadcrumb, DatePicker } from 'antd';
  3. import router from 'umi/router';
  4. import moment from 'moment';
  5. import withActions from '@/components/ActionList';
  6. import EditIcon from '@/components/EditIcon';
  7. import apis from '../../../../services/apis';
  8. import request from '../../../../utils/request';
  9. import Navigate from '@/components/Navigate'
  10. import ShowVoucher from './ShowVoucher';
  11. const { Option } = Select
  12. function RechargeOrder(props) {
  13. // const [taNoticeList, setTaNoticeList] = useState([])
  14. const [data, setData] = useState({})
  15. const [showVoucher, setShowVoucher] = useState({})
  16. useEffect(() => {
  17. getList({ pageNum: 1, pageSize: 10 });
  18. }, [])
  19. // 查询列表
  20. const getList = params => {
  21. if (params.refundStartTime) {
  22. params.refundStartTime = `${moment(params.refundStartTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
  23. }
  24. if (params.refundEndTime) {
  25. params.refundEndTime = `${moment(params.refundEndTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
  26. }
  27. request({ ...apis.funds.refundlist, params: { ...params } }).then(data => {
  28. setData(data)
  29. })
  30. }
  31. function handleSubmit(e) {
  32. e.preventDefault();
  33. props.form.validateFields((err, values) => {
  34. if (!err) {
  35. // eslint-disable-next-line no-console
  36. console.log('提交数据: ', values)
  37. getList({ pageNum: 1, pageSize: 10, ...values })
  38. }
  39. });
  40. }
  41. const openImg = data => {
  42. setShowVoucher(
  43. {
  44. visible: true,
  45. bannerList: data,
  46. },
  47. )
  48. }
  49. function handleReset() {
  50. props.form.resetFields();
  51. getList({ pageNum: 1, pageSize: 10 })
  52. }
  53. const changePageNum = e => {
  54. props.form.validateFields((err, values) => {
  55. if (!err) {
  56. // eslint-disable-next-line no-console
  57. console.log('提交数据: ', values)
  58. getList({ pageNum: e, pageSize: 10, ...values })
  59. }
  60. });
  61. }
  62. const columns = [
  63. {
  64. title: '订单编号',
  65. dataIndex: 'tradeNo',
  66. key: 'tradeNo',
  67. align: 'center',
  68. },
  69. {
  70. title: '退款金额(元)',
  71. dataIndex: 'amount',
  72. key: 'amount',
  73. align: 'center',
  74. },
  75. {
  76. title: '退款创建时间',
  77. dataIndex: 'createDate',
  78. key: 'createDate',
  79. align: 'center',
  80. render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
  81. },
  82. {
  83. title: '退款状态',
  84. dataIndex: 'auditStatus',
  85. key: 'auditStatus',
  86. align: 'center',
  87. },
  88. {
  89. title: '驳回原因',
  90. dataIndex: 'auditResult',
  91. key: 'auditResult',
  92. align: 'center',
  93. },
  94. {
  95. title: '退款凭证',
  96. dataIndex: 'certificateList',
  97. key: 'certificateList',
  98. align: 'center',
  99. render: (x, row) => <><Navigate onClick={() => openImg(x)}>查看</Navigate> </>,
  100. },
  101. {
  102. title: '操作',
  103. dataIndex: 'num',
  104. key: 'num',
  105. align: 'center',
  106. render: withActions((text, row) => [
  107. <EditIcon type="look" text="查看联系人" onClick={() => router.push({
  108. pathname: '/funds/financialContact',
  109. })}> </EditIcon>,
  110. ]),
  111. },
  112. ]
  113. function download(data) {
  114. // if (!data) {
  115. // console.log('234')
  116. // return
  117. // }
  118. const url = window.URL.createObjectURL(new Blob([data]))
  119. const link = document.createElement('a')
  120. link.style.display = 'none'
  121. link.href = url
  122. link.setAttribute('download', '退款订单.xlsx')
  123. document.body.append(link)
  124. link.click()
  125. }
  126. const exportReport = () => {
  127. const requestParams = props.form.getFieldsValue();
  128. if (params.refundStartTime) {
  129. params.refundStartTime = `${moment(params.refundStartTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
  130. }
  131. if (params.refundEndTime) {
  132. params.refundEndTime = `${moment(params.refundEndTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
  133. }
  134. request({ ...apis.funds.refundexportList, responseType: 'blob', params: { ...requestParams } }).then(data => {
  135. download(data)
  136. }).catch()
  137. }
  138. const { getFieldDecorator } = props.form
  139. return (
  140. <>
  141. <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
  142. <Form.Item>
  143. {getFieldDecorator('tradeNo')(
  144. <Input
  145. placeholder="订单编号"
  146. />,
  147. )}
  148. </Form.Item>
  149. <Form.Item>
  150. {getFieldDecorator('refundStartTime')(
  151. <DatePicker placeholder="退款开始时间" />,
  152. )}
  153. </Form.Item>
  154. <Form.Item>
  155. {getFieldDecorator('refundEndTime')(
  156. <DatePicker placeholder="退款结束时间" />,
  157. )}
  158. </Form.Item>
  159. <Form.Item>
  160. {getFieldDecorator('auditStatus')(
  161. <Select style={{ width: '180px' }} placeholder="退款状态">
  162. <Option value="">全部</Option>
  163. <Option value="1">已申请</Option>
  164. <Option value="2">已驳回</Option>
  165. <Option value="3">已退款</Option>
  166. </Select>,
  167. )}
  168. </Form.Item>
  169. <Form.Item>
  170. {getFieldDecorator('phone')(
  171. <Input
  172. placeholder="接收人手机号"
  173. />,
  174. )}
  175. </Form.Item>
  176. <Form.Item>
  177. <Button type="primary" htmlType="submit"> 搜索</Button>
  178. <Button style={{ marginLeft: 8 }} onClick={handleReset}>重置</Button>
  179. </Form.Item>
  180. </Form>
  181. <div style={{ marginTop: '20px' }}>
  182. <Button type="primary" onClick={() => exportReport()} style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} >导出</Button>
  183. </div>
  184. <Table dataSource={data.records} columns={columns} pagination={false} style={{ marginTop: '20px' }} />
  185. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  186. <Pagination
  187. showQuickJumper
  188. defaultCurrent={1}
  189. total={data.total} onChange={e => changePageNum(e)} current={data.current} />
  190. </div>
  191. {showVoucher.visible && <ShowVoucher bannerList={showVoucher.bannerList} closeSwiper={() => setShowVoucher({ visible: false })} />}
  192. </>
  193. )
  194. }
  195. const WrappedRechargeOrder = Form.create({ name: 'RechargeOrder' })(RechargeOrder);
  196. export default WrappedRechargeOrder