import { Button, Popconfirm, Space, Table, Tag, Typography } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { PARTNER_PERMISSION_LABELS, PARTNER_STAFF_ROLE_LABELS, type PartnerPermissionKey, } from '@dukang/shared-types'; export type PartnerSubAccountRow = { id: string; phone: string; name: string; staffRole?: string; permissions?: string[]; status: string; }; function formatPermissions(permissions?: string[]) { return permissions?.map((k) => PARTNER_PERMISSION_LABELS[k as PartnerPermissionKey] || k).join('、') || '—'; } type Props = { subs: PartnerSubAccountRow[]; onAdd: () => void; onEdit: (sub: PartnerSubAccountRow) => void; onDelete: (subId: string) => void; }; export default function PartnerSubAccountList({ subs, onAdd, onEdit, onDelete }: Props) { const columns: ColumnsType = [ { title: '姓名', dataIndex: 'name', width: 100 }, { title: '手机', dataIndex: 'phone', width: 120 }, { title: '角色', dataIndex: 'staffRole', width: 90, render: (v) => v ? PARTNER_STAFF_ROLE_LABELS[v as keyof typeof PARTNER_STAFF_ROLE_LABELS] || v : '—', }, { title: '状态', dataIndex: 'status', width: 80, render: (s) => ( {s === 'ACTIVE' ? '启用' : '停用'} ), }, { title: '权限', dataIndex: 'permissions', ellipsis: true, render: (p: string[] | undefined) => formatPermissions(p), }, { title: '操作', width: 120, render: (_, row) => ( onDelete(row.id)}> ), }, ]; return ( <>
子账号({subs.length})· 仅主账号可添加,不可多级
); }