"use client" import { format } from "date-fns" import { CreditCard } from "lucide-react" import { Suspense } from "react" import { getPageBill } from "@/actions/bill" import { DataTable, useDataTable } from "@/components/data-table" import type { Billing } from "@/models/billing" export default function BillingPage() { const table = useDataTable((page, size) => getPageBill({ page, size }), ) return ( {...table} columns={[ { header: "ID", accessorKey: "id" }, { header: "账单号", accessorKey: "bill_no" }, { header: "账单详情", accessorKey: "info", cell: ({ row }) => { const bill = row.original return (
{/* 类型展示 */}
{bill.type === 1 && (
消费
)} {bill.type === 2 && (
退款
)} {bill.type === 3 && (
充值
)}
{/* 账单详情 */}
{bill.info}
) }, }, { header: "支付信息", accessorKey: "amount", cell: ({ row }) => { const amount = typeof row.original.amount === "string" ? parseFloat(row.original.amount) : row.original.amount || 0 return (
0 ? "text-green-500" : "text-orange-500" } > ¥{amount.toFixed(2)}
) }, }, // { header: "资源数量", accessorKey: "resource_id" }, { header: "创建时间", accessorKey: "created_at", cell: ({ row }) => format(new Date(row.original.created_at), "yyyy-MM-dd HH:mm"), }, { header: "更新时间", accessorKey: "updated_at", cell: ({ row }) => format(new Date(row.original.updated_at), "yyyy-MM-dd HH:mm"), }, ]} />
) }