新增余额明细页面,修复页面useId不更新的问题

This commit is contained in:
Eamon
2026-04-11 14:57:45 +08:00
parent 790180a847
commit ed95f0520d
23 changed files with 780 additions and 215 deletions

View File

@@ -19,7 +19,6 @@ import { Input } from "@/components/ui/input"
import type { Channel } from "@/models/channel"
type FilterValues = {
user_id: number
batch_no?: string
user_phone?: string
resource_no?: string
@@ -67,9 +66,7 @@ const ispMap: Record<number, string> = {
export default function ChannelPage() {
const searchParams = useSearchParams()
const userId = searchParams.get("userId")
const [filters, setFilters] = useState<FilterValues>({
user_id: Number(userId),
})
const [filters, setFilters] = useState<FilterValues>({})
const { control, handleSubmit, reset } = useForm<FilterSchema>({
resolver: zodResolver(filterSchema),
defaultValues: {
@@ -85,13 +82,11 @@ export default function ChannelPage() {
})
const table = useDataTable<Channel>((page, size) =>
getChannel({ page, size, ...filters }),
getChannel({ page, size, user_id: Number(userId), ...filters }),
)
const onFilter = handleSubmit(data => {
const result: FilterValues = {
user_id: Number(userId),
}
const result: FilterValues = {}
if (data.batch_no?.trim()) result.batch_no = data.batch_no.trim()
if (data.user_phone?.trim()) result.user_phone = data.user_phone.trim()
if (data.resource_no?.trim()) result.resource_no = data.resource_no.trim()
@@ -218,7 +213,7 @@ export default function ChannelPage() {
variant="outline"
onClick={() => {
reset()
setFilters({ user_id: Number(userId) })
setFilters({})
table.pagination.onPageChange(1)
}}
>
@@ -233,7 +228,7 @@ export default function ChannelPage() {
columns={[
{
header: "会员号",
accessorFn: row => row.user?.phone || "-",
accessorFn: row => row.user?.phone || "",
},
{ header: "套餐号", accessorKey: "resource.resource_no" },
{ header: "批次号", accessorKey: "batch_no" },