董国庆
2026-01-06 f13a77f3606057cd186c53a833e1bbe58175aafb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import { exportExcell } from '@/utils/utils';
import { Button, message, Popconfirm } from 'antd';
import { request } from '@umijs/max';
import { useRef, useState } from 'react';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import RefundDetailModal from './components/RefundDetailModal';
import { deleteRefundApplication, pageRefundList } from './service';
import { Access, useAccess } from 'umi';
 
const RefundAudit = () => {
  const access = useAccess();
  const actionRef = useRef();
  const [searchParams, setSearchParams] = useState({});
  const [detailVisible, setDetailVisible] = useState(false);
  const [currentId, setCurrentId] = useState(null);
  const [currentRecord, setCurrentRecord] = useState(null);
 
  // 状态映射
  const auditStatusMap = {
    1: { text: '待审核', status: 'Warning' },
    2: { text: '审核通过', status: 'Success' },
    3: { text: '审核驳回', status: 'Error' },
  };
 
  const paymentTypeMap = {
    1: '订金+尾款',
    2: '全款',
  };
 
  const columns = [
    {
      title: '序号',
      dataIndex: 'index',
      hideInSearch: true,
      width: 60,
      render: (text, record, index) => index + 1,
    },
    {
      title: '订单编号',
      dataIndex: 'code',
      hideInSearch: true,
      width: 180,
      ellipsis: true,
    },
    {
      title: '下单时间',
      dataIndex: 'createTime',
      hideInSearch: true,
      valueType: 'dateTime',
      width: 180,
      search: {
        transform: (value) => ({
          createTime: value ? value.join(' - ') : undefined,
        }),
      },
    },
    {
      title: '下单用户',
      dataIndex: 'userName',
      hideInSearch: true,
      width: 120,
      ellipsis: true,
    },
    {
      title: '用户手机号',
      dataIndex: 'phone',
      hideInSearch: true,
      width: 120,
    },
    {
      title: '订单价格',
      dataIndex: 'orderPrice',
      hideInSearch: true,
      width: 100,
      render: (text) => `¥${text}`,
      search: false,
    },
    {
      title: '商品名称',
      dataIndex: 'bigGiftPackageName',
      width: 200,
      ellipsis: true,
    },
    {
      title: '支付方式',
      dataIndex: 'paymentType',
      hideInSearch: true,
      valueType: 'select',
      valueEnum: paymentTypeMap,
      width: 120,
    },
    {
      title: '定金',
      dataIndex: 'deposit',
      hideInSearch: true,
      width: 100,
      render: (text) => `¥${text || '0.00'}`,
      search: false,
    },
    {
      title: '尾款',
      dataIndex: 'finalPayment',
      hideInSearch: true,
      width: 100,
      render: (text) => `¥${text || '0.00'}`,
      search: false,
    },
    {
      title: '审核状态',
      dataIndex: 'auditStatus',
      hideInSearch: true,
      valueType: 'select',
      valueEnum: auditStatusMap,
      width: 120,
    },
    {
      title: '操作',
      dataIndex: 'action',
      valueType: 'option',
      width: 200,
      fixed: 'right',
      render: (_, record) => (
        <>
          <Access accessible={(access.refundAudit_audit || false) && record.auditStatus === 1}>
          <Button
            type="link"
            size="small"
            onClick={() => {
              setCurrentId(record.id);
              setCurrentRecord(record);
              setDetailVisible(true);
            }}
          >
            审核
          </Button>
          </Access>
          <Access accessible={access.refundAudit_detail || false}>
            <Button
              type="link"
              size="small"
              onClick={() => {
                setCurrentId(record.id);
                setCurrentRecord(record);
                setDetailVisible(true);
              }}
            >
              详情
            </Button>
          </Access>
          <Access accessible={access.refundAudit_del || false}>
            <Popconfirm
              title="确认删除该退款申请?"
              onConfirm={() => handleDelete(record.id)}
              okText="确认"
              cancelText="取消"
            >
              <Button type="link" size="small" danger>
                删除
              </Button>
            </Popconfirm>
          </Access>
        </>
      ),
    },
  ];
 
  // 删除退款申请
  const handleDelete = async (id) => {
    try {
      const res = await deleteRefundApplication(id);
      if (res.code === 200) {
        message.success('删除成功');
        actionRef.current?.reload();
      } else {
        message.error(res.msg || '删除失败');
      }
    } catch (error) {
      message.error('删除失败');
    }
  };
 
  // 导出Excel
  const handleExport = async () => {
    try {
      exportExcell('退款申请列表.xlsx', searchParams, '/t-refund-application/export');
      message.success('导出成功');
    } catch (error) {
      message.error('导出失败');
    }
  };
 
 
  return (
    <PageContainer>
      <ProTable
        actionRef={actionRef}
        rowKey="id"
        search={{
          labelWidth: 'auto',
        }}
        toolBarRender={() => [
          <Access accessible={access.refundAudit_exportExcel || false}>
            <Button
              key="export"
              type="primary"
              onClick={handleExport}
            >
              导出Excel
            </Button>
          </Access>,
        ]}
        request={async (params) => {
          const { current, pageSize, ...rest } = params;
          let queryParams = {
            ...rest,
            pageNum: current,
            pageSize,
          };
          if (queryParams.bigGiftPackageName) {
            queryParams.name = queryParams.bigGiftPackageName;
          }
          // 保存搜索参数,用于导出
          setSearchParams(queryParams);
 
          const res = await pageRefundList(queryParams);
 
          return {
            data: res.data?.records || [],
            success: res.code === 200,
            total: res.data?.total || 0,
          };
        }}
        columns={columns}
        scroll={{ x: 1600 }}
        pagination={{
          showSizeChanger: true,
          showQuickJumper: true,
          defaultPageSize: 10,
        }}
      />
 
      {/* 详情弹窗 */}
      <RefundDetailModal
        visible={detailVisible}
        onCancel={() => {
          setDetailVisible(false);
          setCurrentId(null);
          setCurrentRecord(null);
        }}
        id={currentId}
        onRefresh={() => actionRef.current?.reload()}
      />
    </PageContainer>
  );
};
 
export default RefundAudit;