import { ActionType, DrawerForm, PageContainer, ProColumns, ProFormText, ProTable } from '@ant-design/pro-components'; import { request, useParams } from '@umijs/max'; import { App, Avatar, Button, Popconfirm, Space, Tag } from 'antd'; import React, { useRef, useState } from 'react'; import { DeleteFilled, EditOutlined, PlusOutlined, UserOutlined } from '@ant-design/icons'; const CustomerPage: React.FC = () => { const { message } = App.useApp(); const { siteId } = useParams<{ siteId: string }>(); const [editing, setEditing] = useState(null); const [selectedRowKeys, setSelectedRowKeys] = useState([]); const actionRef = useRef(); const handleDelete = async (id: number) => { if (!siteId) return; try { const res = await request(`/site-api/${siteId}/customers/${id}`, { method: 'DELETE' }); if (res.success) { message.success('删除成功'); actionRef.current?.reload(); } else { message.error(res.message || '删除失败'); } } catch (e) { message.error('删除失败'); } }; const columns: ProColumns[] = [ { title: '头像', dataIndex: 'avatar_url', hideInSearch: true, width: 80, render: (_, record) => { // 从raw数据中获取头像URL,因为DTO中没有这个字段 const avatarUrl = record.raw?.avatar_url || record.avatar_url; return } size="large" />; }, }, { title: '姓名', dataIndex: 'username', render: (_, record) => { // DTO中有first_name和last_name字段,username可能从raw数据中获取 const username = record.username || record.raw?.username || 'N/A'; return (
{username}
{record.first_name} {record.last_name}
); }, }, { title: '邮箱', dataIndex: 'email', copyable: true, }, { title: '角色', dataIndex: 'role', render: (_, record) => { // 角色信息可能从raw数据中获取,因为DTO中没有这个字段 const role = record.role || record.raw?.role || 'N/A'; return {role}; }, }, { title: '账单地址', dataIndex: 'billing', hideInSearch: true, render: (_, record) => { const { billing } = record; if (!billing) return '-'; return (
{billing.address_1} {billing.address_2}
{billing.city}, {billing.state}, {billing.postcode}
{billing.country}
{billing.phone}
); }, }, { title: '注册时间', dataIndex: 'date_created', valueType: 'dateTime', hideInSearch: true, }, { title: '操作', valueType: 'option', width: 120, render: (_, record) => (