表格增加序号列,移除 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>
{...table}
columns={[
{ header: "ID", accessorKey: "id" },
{
header: "会员号",
accessorFn: row => row.user?.phone || "-",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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