import { useState } from 'react'; import { Button, Descriptions, Drawer, Form, Input, Modal, Space, Table, Typography, message, } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { request } from '../lib/api'; import { fmtTime } from '../lib/constants'; import { useAdminList } from '../lib/useAdminList'; type Row = { id: string; companyName: string; contactPhone: string; address: string; storeCount: number; accountCount: number; cityCount: number; createdAt: string; }; export default function PartnersPage() { const [form] = Form.useForm(); const [editForm] = Form.useForm(); const [createForm] = Form.useForm(); const [filters, setFilters] = useState>({}); const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList( '/admin/partners', () => { const qs = new URLSearchParams(); if (filters.companyName) qs.set('companyName', filters.companyName); if (filters.contactPhone) qs.set('contactPhone', filters.contactPhone); return qs; }, [filters], ); const [detail, setDetail] = useState | null>(null); const [drawerOpen, setDrawerOpen] = useState(false); const [createOpen, setCreateOpen] = useState(false); const columns: ColumnsType = [ { title: '公司名', dataIndex: 'companyName' }, { title: '联系电话', dataIndex: 'contactPhone', width: 130 }, { title: '门店', dataIndex: 'storeCount', width: 70 }, { title: '账号', dataIndex: 'accountCount', width: 70 }, { title: '开城城市', dataIndex: 'cityCount', width: 90 }, { title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime }, { title: '操作', width: 120, render: (_, row) => ( ), }, ]; return (
开城合伙人
{ setFilters(v); setPage(1); }}>
{ setPage(p); setPageSize(ps); } }} /> setDrawerOpen(false)} extra={detail && ( )}> {detail && ( <> {Array.isArray(detail.cities) && ( {(detail.cities as Array<{ name: string; code: string; status: string }>).map((c) => ( {c.name} ({c.status}) ))} )}
}> )}
setCreateOpen(false)} onOk={async () => { const v = await createForm.validateFields(); await request('/admin/partners', { method: 'POST', body: JSON.stringify(v) }); message.success('已创建'); setCreateOpen(false); createForm.resetFields(); void reload(); }}>
); }