feat(用户管理): 新增积分修改记录页面及功能
添加积分修改记录页面,包含列表展示和导出Excel功能。页面通过ProTable组件实现数据展示和搜索,并集成导出功能到现有工具方法中
| | |
| | | "name": "用户列表", |
| | | "path": "/user/list", |
| | | "component": "./user/list" |
| | | }, |
| | | { |
| | | "name": "积分修改记录", |
| | | "path": "/user/integralChangeRecord", |
| | | "component": "./user/integralChangeRecord" |
| | | } |
| | | ] |
| | | }, |
| New file |
| | |
| | | import React, { useRef, useState } from 'react'; |
| | | import { PageContainer, ProTable } from '@ant-design/pro-components'; |
| | | import { Button, Space, Avatar, message } from 'antd'; |
| | | import { getIntegralChangeRecordList, exportIntegralChangeRecordExcel } from './service'; |
| | | import { exportExcell } from '@/utils/utils'; |
| | | |
| | | const IntegralChangeRecordList = () => { |
| | | const actionRef = useRef(); |
| | | const [searchParams, setSearchParams] = useState({}); |
| | | |
| | | // 导出Excel |
| | | const handleExport = () => { |
| | | exportExcell('积分修改记录.xlsx', searchParams, '/t-app-user/exportIntegralChangeRecord'); |
| | | }; |
| | | |
| | | const columns = [ |
| | | { |
| | | title: '序号', |
| | | dataIndex: 'index', |
| | | hideInSearch: true, |
| | | align: 'center', |
| | | width: 60, |
| | | render: (text, record, index) => index + 1, |
| | | }, |
| | | { |
| | | title: '头像', |
| | | dataIndex: 'profilePhoto', |
| | | hideInSearch: true, |
| | | width: 80, |
| | | render: (text, record) => ( |
| | | <Avatar |
| | | src={text} |
| | | size="small" |
| | | style={{ backgroundColor: '#f5f5f5', color: '#000' }} |
| | | > |
| | | {text ? '' : record.name?.substring(-1)} |
| | | </Avatar> |
| | | ), |
| | | }, |
| | | { |
| | | title: '用户名', |
| | | dataIndex: 'name', |
| | | width: 120, |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: '推广号', |
| | | dataIndex: 'code', |
| | | width: 120, |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: '联系电话', |
| | | dataIndex: 'phone', |
| | | width: 130, |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: '修改前积分', |
| | | dataIndex: 'oldIntegral', |
| | | hideInSearch: true, |
| | | width: 110, |
| | | align: 'center', |
| | | render: (text) => text || 0, |
| | | }, |
| | | { |
| | | title: '修改后积分', |
| | | dataIndex: 'newIntegral', |
| | | hideInSearch: true, |
| | | width: 110, |
| | | align: 'center', |
| | | render: (text) => text || 0, |
| | | }, |
| | | { |
| | | title: '修改时间', |
| | | dataIndex: 'createTime', |
| | | hideInSearch: true, |
| | | width: 180, |
| | | valueType: 'dateTime', |
| | | render: (text) => text || '-', |
| | | }, |
| | | { |
| | | title: '操作人', |
| | | dataIndex: 'operatorName', |
| | | hideInSearch: true, |
| | | width: 120, |
| | | ellipsis: true, |
| | | }, |
| | | ]; |
| | | |
| | | return ( |
| | | <PageContainer> |
| | | <ProTable |
| | | actionRef={actionRef} |
| | | rowKey="id" |
| | | search={{ |
| | | labelWidth: 'auto', |
| | | defaultCollapsed: false, |
| | | }} |
| | | toolBarRender={() => [ |
| | | <Button |
| | | key="export" |
| | | type="primary" |
| | | onClick={handleExport} |
| | | > |
| | | 导出Excel |
| | | </Button>, |
| | | ]} |
| | | request={async (params) => { |
| | | const { current, pageSize, ...rest } = params; |
| | | |
| | | // 保存搜索参数,用于导出 |
| | | setSearchParams(rest); |
| | | |
| | | try { |
| | | const res = await getIntegralChangeRecordList({ |
| | | ...rest, |
| | | pageNum: current, |
| | | pageSize, |
| | | }); |
| | | |
| | | return { |
| | | data: res.data?.records || [], |
| | | success: res.code === 200, |
| | | total: res.data?.total || 0, |
| | | }; |
| | | } catch (error) { |
| | | message.error('获取数据失败'); |
| | | return { |
| | | data: [], |
| | | success: false, |
| | | total: 0, |
| | | }; |
| | | } |
| | | }} |
| | | pagination={{ |
| | | showSizeChanger: true, |
| | | showQuickJumper: true, |
| | | defaultPageSize: 10, |
| | | showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条/共 ${total} 条`, |
| | | }} |
| | | columns={columns} |
| | | scroll={{ x: 1000 }} |
| | | /> |
| | | </PageContainer> |
| | | ); |
| | | }; |
| | | |
| | | export default IntegralChangeRecordList; |
| New file |
| | |
| | | import { request } from '@umijs/max'; |
| | | |
| | | // 获取积分修改记录列表 |
| | | export async function getIntegralChangeRecordList(params) { |
| | | return request('/t-app-user/integralChangeRecord', { |
| | | method: 'POST', |
| | | data: params, |
| | | }); |
| | | } |
| | | |
| | | // 导出积分修改记录Excel |
| | | export async function exportIntegralChangeRecordExcel(params) { |
| | | return request('/t-app-user/exportIntegralChangeRecord', { |
| | | method: 'POST', |
| | | data: params, |
| | | }); |
| | | } |