123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- import React, { useState, useEffect } from 'react';
- import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, Breadcrumb, DatePicker } from 'antd';
- import router from 'umi/router';
- import moment from 'moment';
- import withActions from '@/components/ActionList';
- import EditIcon from '@/components/EditIcon';
- import apis from '../../../../services/apis';
- import request from '../../../../utils/request';
- import Navigate from '@/components/Navigate'
- import ShowVoucher from './ShowVoucher';
-
- const { Option } = Select
-
- function RechargeOrder(props) {
-
- // const [taNoticeList, setTaNoticeList] = useState([])
- const [data, setData] = useState({})
-
- const [showVoucher, setShowVoucher] = useState({})
-
- useEffect(() => {
- getList({ pageNum: 1, pageSize: 10 });
- }, [])
- // 查询列表
-
- const getList = params => {
- if (params.refundStartTime) {
- params.refundStartTime = `${moment(params.refundStartTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
- }
- if (params.refundEndTime) {
- params.refundEndTime = `${moment(params.refundEndTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
- }
- request({ ...apis.funds.refundlist, params: { ...params } }).then(data => {
- setData(data)
- })
- }
-
- function handleSubmit(e) {
- e.preventDefault();
- props.form.validateFields((err, values) => {
- if (!err) {
- // eslint-disable-next-line no-console
- console.log('提交数据: ', values)
- getList({ pageNum: 1, pageSize: 10, ...values })
- }
- });
- }
-
- const openImg = data => {
- setShowVoucher(
- {
- visible: true,
- bannerList: data,
- },
- )
- }
-
- function handleReset() {
- props.form.resetFields();
-
- getList({ pageNum: 1, pageSize: 10 })
- }
-
- const changePageNum = e => {
- props.form.validateFields((err, values) => {
- if (!err) {
- // eslint-disable-next-line no-console
- console.log('提交数据: ', values)
- getList({ pageNum: e, pageSize: 10, ...values })
- }
- });
-
- }
-
- const columns = [
- {
- title: '订单编号',
- dataIndex: 'tradeNo',
- key: 'tradeNo',
- align: 'center',
- },
- {
- title: '退款金额(元)',
- dataIndex: 'amount',
- key: 'amount',
- align: 'center',
- },
- {
- title: '退款创建时间',
- dataIndex: 'createDate',
- key: 'createDate',
- align: 'center',
- render: (x, row) => <><span>{`${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}`}</span></>,
- },
- {
- title: '退款状态',
- dataIndex: 'auditStatus',
- key: 'auditStatus',
- align: 'center',
- },
- {
- title: '驳回原因',
- dataIndex: 'auditResult',
- key: 'auditResult',
- align: 'center',
- },
-
- {
- title: '退款凭证',
- dataIndex: 'certificateList',
- key: 'certificateList',
- align: 'center',
- render: (x, row) => <><Navigate onClick={() => openImg(x)}>查看</Navigate> </>,
- },
- {
- title: '操作',
- dataIndex: 'num',
- key: 'num',
- align: 'center',
- render: withActions((text, row) => [
-
- <EditIcon type="look" text="查看联系人" onClick={() => router.push({
- pathname: '/funds/financialContact',
- })}> </EditIcon>,
-
-
- ]),
- },
- ]
-
- function download(data) {
- // if (!data) {
- // console.log('234')
- // return
- // }
- const url = window.URL.createObjectURL(new Blob([data]))
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = url
- link.setAttribute('download', '退款订单.xlsx')
- document.body.append(link)
- link.click()
- }
-
- const exportReport = () => {
- const requestParams = props.form.getFieldsValue();
- if (params.refundStartTime) {
- params.refundStartTime = `${moment(params.refundStartTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
- }
- if (params.refundEndTime) {
- params.refundEndTime = `${moment(params.refundEndTime).format('YYYY-MM-DDTHH:mm:ss')}Z`;
- }
- request({ ...apis.funds.refundexportList, responseType: 'blob', params: { ...requestParams } }).then(data => {
- download(data)
- }).catch()
- }
-
- const { getFieldDecorator } = props.form
-
- return (
-
- <>
- <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
- <Form.Item>
- {getFieldDecorator('tradeNo')(
- <Input
- placeholder="订单编号"
- />,
- )}
- </Form.Item>
- <Form.Item>
- {getFieldDecorator('refundStartTime')(
- <DatePicker placeholder="退款开始时间" />,
- )}
- </Form.Item>
- <Form.Item>
- {getFieldDecorator('refundEndTime')(
- <DatePicker placeholder="退款结束时间" />,
- )}
- </Form.Item>
- <Form.Item>
- {getFieldDecorator('auditStatus')(
- <Select style={{ width: '180px' }} placeholder="退款状态">
- <Option value="">全部</Option>
- <Option value="1">已申请</Option>
- <Option value="2">已驳回</Option>
- <Option value="3">已退款</Option>
- </Select>,
- )}
- </Form.Item>
- <Form.Item>
- {getFieldDecorator('phone')(
- <Input
- placeholder="接收人手机号"
- />,
- )}
- </Form.Item>
- <Form.Item>
- <Button type="primary" htmlType="submit"> 搜索</Button>
- <Button style={{ marginLeft: 8 }} onClick={handleReset}>重置</Button>
- </Form.Item>
- </Form>
- <div style={{ marginTop: '20px' }}>
- <Button type="primary" onClick={() => exportReport()} style={{ float: 'right', marginBottom: '20px', zIndex: 1 }} >导出</Button>
- </div>
- <Table dataSource={data.records} columns={columns} pagination={false} style={{ marginTop: '20px' }} />
- <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
- <Pagination
- showQuickJumper
- defaultCurrent={1}
- total={data.total} onChange={e => changePageNum(e)} current={data.current} />
- </div>
- {showVoucher.visible && <ShowVoucher bannerList={showVoucher.bannerList} closeSwiper={() => setShowVoucher({ visible: false })} />}
- </>
-
- )
- }
-
-
- const WrappedRechargeOrder = Form.create({ name: 'RechargeOrder' })(RechargeOrder);
-
- export default WrappedRechargeOrder
|