diff --git a/apps/web/src/pages/points/Transactions.tsx b/apps/web/src/pages/points/Transactions.tsx index a6a1c65f7..e58d66b24 100644 --- a/apps/web/src/pages/points/Transactions.tsx +++ b/apps/web/src/pages/points/Transactions.tsx @@ -1,7 +1,6 @@ /** * 积分明细页(/app/points/transactions) - * 分页展示积分流水,支持按类型/来源/日期/关键字筛选 - * 日期筛选使用原生 Date,不引入额外依赖 + * 分页展示积分流水,支持按类型/来源筛选 */ import React, { useEffect, useState, useCallback } from "react" import { @@ -19,8 +18,8 @@ import { } from "antd" import { SearchOutlined, ReloadOutlined } from "@ant-design/icons" import type { ColumnsType } from "antd/es/table" -import type { Dayjs } from "dayjs" import { useNavigate } from "react-router-dom" +import dayjs from "dayjs" import PageHead from "@/components/layout/PageHead" import { getPointsTransactions } from "@/api/points" import type { PointsTransaction, PointsTxType } from "@/api/points/types" @@ -29,12 +28,6 @@ import "./Points.css" const { Text } = Typography const { RangePicker } = DatePicker -function formatDateTime(iso: string): string { - const d = new Date(iso) - const pad = (n: number) => String(n).padStart(2, "0") - return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}` -} - const TYPE_LABEL: Record = { earn: { text: "获得", color: "green" }, spend: { text: "消耗", color: "red" }, @@ -67,13 +60,13 @@ const PointsTransactions: React.FC = () => { const [pageSize, setPageSize] = useState(20) const [type, setType] = useState("all") const [source, setSource] = useState("all") - const [dateRange, setDateRange] = useState<[Dayjs | null, Dayjs | null] | null>(null) + const [dateRange, setDateRange] = useState<[dayjs.Dayjs | null, dayjs.Dayjs | null] | null>(null) const [keyword, setKeyword] = useState("") const load = useCallback(async () => { setLoading(true) try { - const params: Record = { page, page_size: pageSize } + const params: Record = { page, page_size: pageSize } if (type !== "all") params.type = type if (source !== "all") params.source = source if (dateRange && dateRange[0] && dateRange[1]) { @@ -106,7 +99,7 @@ const PointsTransactions: React.FC = () => { title: "时间", dataIndex: "created_at", width: 180, - render: (v: string) => formatDateTime(v), + render: (v: string) => dayjs(v).format("YYYY-MM-DD HH:mm"), }, { title: "类型", @@ -120,9 +113,11 @@ const PointsTransactions: React.FC = () => { { title: "来源/场景", dataIndex: "source", - width: 160, + width: 150, render: (s: string, r: PointsTransaction) => ( - {r.source_name || SOURCE_LABEL[s] || s} + + {r.source_name || SOURCE_LABEL[s] || s} + ), }, { @@ -164,7 +159,8 @@ const PointsTransactions: React.FC = () => {