From 8fcf54ae103734df22200116b0f871b55ddeac5b Mon Sep 17 00:00:00 2001 From: Eamon <17516219072@163.com> Date: Wed, 8 Apr 2026 13:41:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=A1=B5=E9=9D=A2=E5=8C=85=E6=8B=AC=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6=20&=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(root)/appbar.tsx | 110 ----------- src/app/(root)/navigation.tsx | 8 + src/app/(root)/userQuery/page.tsx | 313 ++++++++++++++++++++++++++++++ src/lib/scopes.ts | 1 + src/models/cust.ts | 6 +- src/models/user.ts | 6 +- 6 files changed, 328 insertions(+), 116 deletions(-) create mode 100644 src/app/(root)/userQuery/page.tsx diff --git a/src/app/(root)/appbar.tsx b/src/app/(root)/appbar.tsx index e408016..ac88f61 100644 --- a/src/app/(root)/appbar.tsx +++ b/src/app/(root)/appbar.tsx @@ -1,12 +1,9 @@ "use client" import { BadgeQuestionMarkIcon, - BellIcon, ChevronDownIcon, ChevronRightIcon, - InboxIcon, LogOutIcon, - SearchIcon, SettingsIcon, UserIcon, } from "lucide-react" @@ -16,36 +13,12 @@ import { usePathname, useRouter } from "next/navigation" import { useEffect, useRef, useState } from "react" import { logout } from "@/actions/auth" import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" import type { Admin } from "@/models/admin" export default function Appbar(props: { admin: Admin }) { const router = useRouter() const [showDropdown, setShowDropdown] = useState(false) const [showNotifications, setShowNotifications] = useState(false) - const [notifications] = useState([ - { - id: 1, - title: "系统通知", - content: "您有新的待审核内容", - time: "10分钟前", - read: false, - }, - { - id: 2, - title: "安全提醒", - content: "您的账号于昨天登录了新设备", - time: "1小时前", - read: true, - }, - { - id: 3, - title: "系统更新", - content: "系统将在今晚进行例行维护", - time: "2小时前", - read: true, - }, - ]) const pathname = usePathname() const dropdownRef = useRef(null) @@ -119,7 +92,6 @@ export default function Appbar(props: { admin: Admin }) { } const breadcrumbs = generateBreadcrumbs() - const unreadCount = notifications.filter(n => !n.read).length const doLogout = async () => { const resp = await logout() if (resp.success) { @@ -153,88 +125,6 @@ export default function Appbar(props: { admin: Admin }) { {/* 右侧用户信息和工具栏 */}
- {/* 搜索框 */} -
-
- - -
-
- - {/* 通知图标 */} -
- - - {/* 通知下拉面板 */} - {showNotifications && ( -
-
-

通知

- -
- -
- {notifications.length > 0 ? ( - notifications.map(notification => ( -
-
-

- {notification.title} -

- - {notification.time} - -
-

- {notification.content} -

-
- )) - ) : ( -
- -

暂无通知

-
- )} -
- -
- - 查看全部通知 - -
-
- )} -
- - {/* 分隔线 */} -
- {/* 用户下拉菜单 */}
+ + + + + + + data={userList || []} + status={loading ? "load" : "done"} + columns={[ + { header: "账号", accessorKey: "username" }, + { header: "手机", accessorKey: "phone" }, + { header: "邮箱", accessorKey: "email" }, + { header: "姓名", accessorKey: "name" }, + { + header: "余额", + accessorKey: "balance", + cell: ({ row }) => { + const balance = Number(row.original.balance) || 0 + return ( + 0 ? "text-green-500" : "text-orange-500" + } + > + ¥{balance.toFixed(2)} + + ) + }, + }, + { + header: "实名状态", + accessorKey: "id_type", + cell: ({ row }) => ( + + {row.original.id_type === 1 ? "已认证" : "未认证"} + + ), + }, + { + 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 = { + 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", + cell: ({ row }) => + row.original.last_login + ? format( + new Date(row.original.last_login), + "yyyy-MM-dd HH:mm", + ) + : "", + }, + { + header: "最后登录IP", + 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"), + }, + { + id: "action", + meta: { pin: "right" }, + header: "操作", + cell: ({ row }) => { + return ( +
+ + + + + + + + + +
+ ) + }, + }, + ]} + /> +
+ + + + + + +
+ ) +} diff --git a/src/lib/scopes.ts b/src/lib/scopes.ts index d88fbde..38f9202 100644 --- a/src/lib/scopes.ts +++ b/src/lib/scopes.ts @@ -38,6 +38,7 @@ export const ScopeUser = "user" export const ScopeUserRead = "user:read" // 读取用户列表 export const ScopeUserWrite = "user:write" // 添加用户 export const ScopeUserWriteBalance = "user:write:balance" // 修改 +export const ScopeUserReadNotBind = "user:read:not-bind" //客户认领 export const ScopeUserReadOne = "user:read:one" // 读取单个用户 export const ScopeUserWriteBind = "user:write:bind" // 认领用户 export const ScopeUserWriteBalanceInc = "user:write:balance:inc" //充值 diff --git a/src/models/cust.ts b/src/models/cust.ts index 0686ae1..f7034d9 100644 --- a/src/models/cust.ts +++ b/src/models/cust.ts @@ -1,5 +1,5 @@ +import type { Admin } from "./admin" import type { ProductDiscount } from "./product_discount" - export type Cust = { id: number admin_id?: number @@ -28,7 +28,3 @@ export type Cust = { updated_at: Date discount: ProductDiscount } -export type Admin = { - name: string - password: string -} diff --git a/src/models/user.ts b/src/models/user.ts index 1d29446..79c9309 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -1,9 +1,9 @@ import type { Admin } from "./admin" +import type { ProductDiscount } from "./product_discount" export type User = { id: number admin_id?: number - admin?: Admin phone: string source: number has_password: boolean @@ -24,4 +24,8 @@ export type User = { last_login_ip: string created_at: Date updated_at: Date + password: string + discount_id: string + discount: ProductDiscount + admin?: Admin }