表格增加序号列,移除 id 列

This commit is contained in:
2026-04-07 17:06:19 +08:00
parent edc87c6eea
commit 0789462a8d
9 changed files with 9 additions and 9 deletions

View File

@@ -250,7 +250,6 @@ export default function BatchPage() {
<DataTable<Batch> <DataTable<Batch>
{...table} {...table}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ {
header: "会员号", header: "会员号",
accessorFn: row => row.user?.phone || "-", accessorFn: row => row.user?.phone || "-",

View File

@@ -328,7 +328,6 @@ export default function BillingPage() {
<DataTable<Billing> <DataTable<Billing>
{...table} {...table}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ header: "会员号", accessorFn: row => row.user?.phone || "-" }, { header: "会员号", accessorFn: row => row.user?.phone || "-" },
{ header: "套餐号", accessorKey: "resource.resource_no" }, { header: "套餐号", accessorKey: "resource.resource_no" },
{ {

View File

@@ -238,7 +238,6 @@ export default function ChannelPage() {
<DataTable<Channel> <DataTable<Channel>
{...table} {...table}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ {
header: "会员号", header: "会员号",
accessorFn: row => row.user?.phone || "-", accessorFn: row => row.user?.phone || "-",

View File

@@ -35,7 +35,6 @@ export default function CouponPage() {
<DataTable<Coupon> <DataTable<Coupon>
{...table} {...table}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ header: "所属用户", accessorKey: "user_id" }, { header: "所属用户", accessorKey: "user_id" },
{ header: "代码", accessorKey: "code" }, { header: "代码", accessorKey: "code" },
{ header: "备注", accessorKey: "remark" }, { header: "备注", accessorKey: "remark" },

View File

@@ -234,7 +234,6 @@ export default function UserPage() {
<DataTable<Cust> <DataTable<Cust>
{...table} {...table}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ header: "账号", accessorKey: "username" }, { header: "账号", accessorKey: "username" },
{ header: "手机", accessorKey: "phone" }, { header: "手机", accessorKey: "phone" },
{ header: "邮箱", accessorKey: "email" }, { header: "邮箱", accessorKey: "email" },

View File

@@ -281,7 +281,6 @@ function ResourceList({ resourceType }: ResourceListProps) {
const columns = useMemo( const columns = useMemo(
() => [ () => [
{ header: "ID", accessorKey: "id" },
{ {
header: "会员号", header: "会员号",
accessorFn: (row: Resources) => row.user?.phone || "-", accessorFn: (row: Resources) => row.user?.phone || "-",

View File

@@ -258,7 +258,6 @@ export default function TradePage() {
<DataTable<Trade> <DataTable<Trade>
{...table} {...table}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ {
header: "会员号", header: "会员号",
accessorFn: row => row.user?.phone || "-", accessorFn: row => row.user?.phone || "-",

View File

@@ -150,7 +150,6 @@ export default function UserPage() {
data={userList || []} data={userList || []}
status={loading ? "load" : "done"} status={loading ? "load" : "done"}
columns={[ columns={[
{ header: "ID", accessorKey: "id" },
{ header: "账号", accessorKey: "username" }, { header: "账号", accessorKey: "username" },
{ header: "手机", accessorKey: "phone" }, { header: "手机", accessorKey: "phone" },
{ header: "邮箱", accessorKey: "email" }, { header: "邮箱", accessorKey: "email" },

View File

@@ -29,6 +29,7 @@ export type DataTableProps<T> = {
headRow?: string headRow?: string
dataRow?: string dataRow?: string
} }
serial?: boolean
} }
export function DataTable<T extends Record<string, unknown>>( export function DataTable<T extends Record<string, unknown>>(
@@ -36,7 +37,14 @@ export function DataTable<T extends Record<string, unknown>>(
) { ) {
const table = useReactTable({ const table = useReactTable({
data: props.data, data: props.data,
columns: props.columns, columns: [
{
id: "serial",
header: "#",
cell: ({ row }) => row.index + 1,
},
...props.columns,
],
getCoreRowModel: getCoreRowModel(), getCoreRowModel: getCoreRowModel(),
manualPagination: true, manualPagination: true,
rowCount: props.pagination?.total, rowCount: props.pagination?.total,