新增余额明细页面,修复页面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

@@ -7,8 +7,8 @@ import { Controller, useForm } from "react-hook-form"
import { toast } from "sonner"
import { z } from "zod"
import { getPageUser } from "@/actions/user"
import { DeductionDialog } from "@/app/(root)/cust/deduction"
import { DepositDialog } from "@/app/(root)/cust/deposit"
// import { DeductionDialog } from "@/app/(root)/cust/deduction"
// import { DepositDialog } from "@/app/(root)/cust/deposit"
import { UpdateDialog } from "@/app/(root)/cust/update"
import { Auth } from "@/components/auth"
import { DataTable } from "@/components/data-table"
@@ -22,6 +22,7 @@ import {
} from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import {
ScopeBalanceActivityReadOfUser,
ScopeBatchReadOfUser,
ScopeBillReadOfUser,
ScopeChannelReadOfUser,
@@ -29,14 +30,10 @@ import {
ScopeTradeReadOfUser,
ScopeUserWrite,
ScopeUserWriteBalance,
ScopeUserWriteBalanceDec,
ScopeUserWriteBalanceInc,
} from "@/lib/scopes"
import type { User } from "@/models/user"
import { AddUserDialog } from "../../cust/create"
// import { ResourcesDialog } from "./resourcesDialog"
interface UserQueryParams {
account?: string
name?: string
@@ -52,10 +49,10 @@ type FormValues = z.infer<typeof filterSchema>
export default function UserQueryPage() {
const [userList, setUserList] = useState<User[]>([])
const [loading, setLoading] = useState(false)
const [depositDialog, setDepositDialog] = useState(false)
const [deposit, setDeposit] = useState<User | null>(null)
const [deductionDialog, setDeductionDialog] = useState(false)
const [deduction, setDeduction] = useState<User | null>(null)
// const [depositDialog, setDepositDialog] = useState(false)
// const [deposit, setDeposit] = useState<User | null>(null)
// const [deductionDialog, setDeductionDialog] = useState(false)
// const [deduction, setDeduction] = useState<User | null>(null)
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
const [currentEditUser, setCurrentEditUser] = useState<User | null>(null)
const [currentFilters, setCurrentFilters] = useState<UserQueryParams>({})
@@ -149,15 +146,15 @@ export default function UserQueryPage() {
</div>
<FieldGroup className="flex-row justify-start mt-4 gap-2">
<Button type="submit"></Button>
<Button type="button" variant="outline" onClick={handleReset}>
</Button>
<Auth scope={ScopeUserWrite}>
<Button type="button" onClick={() => setIsAddDialogOpen(true)}>
</Button>
</Auth>
<Button type="button" variant="outline" onClick={handleReset}>
</Button>
<Button type="submit"></Button>
</FieldGroup>
</form>
@@ -166,10 +163,26 @@ export default function UserQueryPage() {
data={userList || []}
status={loading ? "load" : "done"}
columns={[
{ header: "账号", accessorKey: "username" },
{ header: "手机", accessorKey: "phone" },
{ header: "邮箱", accessorKey: "email" },
{ header: "姓名", accessorKey: "name" },
{
header: "创建时间",
accessorKey: "created_at",
cell: ({ row }) =>
format(new Date(row.original.created_at), "yyyy-MM-dd HH:mm"),
},
{
header: "客户来源",
accessorKey: "source",
cell: ({ row }) => {
const sourceMap: Record<number, string> = {
0: "官网注册",
1: "管理员添加",
2: "代理商注册",
3: "代理商添加",
}
return sourceMap[row.original.source] ?? "未知"
},
},
{
header: "余额",
accessorKey: "balance",
@@ -186,6 +199,17 @@ export default function UserQueryPage() {
)
},
},
{ header: "账号", accessorKey: "username" },
{
header: "账号状态",
accessorKey: "status",
cell: ({ row }) => (row.original.status === 1 ? "正常" : "禁用"),
},
{
header: "客户经理",
cell: ({ row }) => row.original.admin?.name || "",
},
{ header: "姓名", accessorKey: "name" },
{
header: "实名状态",
accessorKey: "id_type",
@@ -202,37 +226,6 @@ export default function UserQueryPage() {
</Badge>
),
},
{
header: "身份证号",
accessorKey: "id_no",
cell: ({ row }) => {
const idNo = row.original.id_no
return idNo ? `${idNo.slice(0, 6)}****${idNo.slice(-4)}` : ""
},
},
{
header: "客户来源",
accessorKey: "source",
cell: ({ row }) => {
const sourceMap: Record<number, string> = {
0: "官网注册",
1: "管理员添加",
2: "代理商注册",
3: "代理商添加",
}
return sourceMap[row.original.source] ?? "未知"
},
},
{
header: "账号状态",
accessorKey: "status",
cell: ({ row }) => (row.original.status === 1 ? "正常" : "禁用"),
},
{ header: "联系方式", accessorKey: "contact_wechat" },
{
header: "客户经理",
cell: ({ row }) => row.original.admin?.name || "",
},
{
header: "最后登录时间",
accessorKey: "last_login",
@@ -249,12 +242,7 @@ export default function UserQueryPage() {
accessorKey: "last_login_ip",
cell: ({ row }) => row.original.last_login_ip || "",
},
{
header: "创建时间",
accessorKey: "created_at",
cell: ({ row }) =>
format(new Date(row.original.created_at), "yyyy-MM-dd HH:mm"),
},
{ header: "联系方式", accessorKey: "contact_wechat" },
{
id: "action",
meta: { pin: "right" },
@@ -262,7 +250,7 @@ export default function UserQueryPage() {
cell: ({ row }) => {
return (
<div className="flex flex-wrap gap-2 w-75">
<Auth scope={ScopeUserWriteBalanceInc}>
{/* <Auth scope={ScopeUserWriteBalanceInc}>
<Button
size="sm"
onClick={() => {
@@ -284,7 +272,7 @@ export default function UserQueryPage() {
>
扣款
</Button>
</Auth>
</Auth> */}
<Auth scope={ScopeUserWriteBalance}>
<Button
size="sm"
@@ -352,6 +340,18 @@ export default function UserQueryPage() {
IP管理
</Button>
</Auth>
<Auth scope={ScopeBalanceActivityReadOfUser}>
<Button
size="sm"
onClick={() => {
router.push(
`/client/balance?userId=${row.original.id}&phone=${row.original.phone}`,
)
}}
>
</Button>
</Auth>
</div>
)
},
@@ -371,19 +371,19 @@ export default function UserQueryPage() {
onSuccess={refreshTable}
/>
<DepositDialog
{/* <DepositDialog
open={depositDialog}
onOpenChange={setDepositDialog}
currentUser={deposit}
onSuccess={refreshTable}
/>
/> */}
<DeductionDialog
{/* <DeductionDialog
open={deductionDialog}
onOpenChange={setDeductionDialog}
currentUser={deduction}
onSuccess={refreshTable}
/>
/> */}
</div>
)
}