feat: 业务员角色权限限制 + 客户查看弹窗
- 新增 acl.ts 工具:isSuperAdmin/SUPER_ADMIN;utils.ts 加 maskPhone - 侧边栏按角色过滤:系统管理菜单仅超管可见 - /rbac 路由服务端拦截:非超管访问重定向首页 - 客户列表:业务员手机号脱敏(中间5位星号)、删除按钮隐藏、新增查看按钮 - 删除服务端校验:仅超管可执行 - 新增 customer-view.tsx 查看弹窗,展示完整商户信息(含完整手机号) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import Link from "next/link";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { fmtDate } from "@/lib/utils";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { isSuperAdmin } from "@/lib/acl";
|
||||
import { fmtDate, maskPhone } from "@/lib/utils";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { Table, THead, TR, TH, TD } from "@/components/ui/table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { CustomerToolbar } from "./customer-toolbar";
|
||||
import { DeleteButton } from "./delete-button";
|
||||
import { CustomerView } from "./customer-view";
|
||||
import { buildCustomerWhere } from "./query";
|
||||
|
||||
const PAGE_SIZE = 15;
|
||||
@@ -23,6 +26,8 @@ export default async function CustomersPage({
|
||||
}: {
|
||||
searchParams: Promise<SearchParams>;
|
||||
}) {
|
||||
const session = await auth();
|
||||
const superAdmin = isSuperAdmin(session?.user?.roles);
|
||||
const sp = await searchParams;
|
||||
const keyword = (sp.keyword ?? "").trim();
|
||||
const page = Math.max(1, Number(sp.page) || 1);
|
||||
@@ -84,7 +89,7 @@ export default async function CustomersPage({
|
||||
<TD className="font-medium">{c.customerName}</TD>
|
||||
<TD>{c.contacts}</TD>
|
||||
<TD>{c.balanceUser}</TD>
|
||||
<TD className="tabular-nums">{c.phone}</TD>
|
||||
<TD className="tabular-nums">{superAdmin ? c.phone : maskPhone(c.phone)}</TD>
|
||||
<TD className="max-w-[280px] whitespace-normal break-words">{c.detail}</TD>
|
||||
<TD>{c.deposit}</TD>
|
||||
<TD>{c.buy}</TD>
|
||||
@@ -101,10 +106,11 @@ export default async function CustomersPage({
|
||||
<TD className="max-w-[280px] whitespace-normal break-words">{c.remark}</TD>
|
||||
<TD>
|
||||
<div className="flex justify-end gap-1.5">
|
||||
<CustomerView customer={c} />
|
||||
<Link href={`/customers/${c.id}/edit`}>
|
||||
<Button variant="outline" size="sm">编辑</Button>
|
||||
</Link>
|
||||
<DeleteButton id={c.id} name={c.customerName ?? ""} />
|
||||
{superAdmin && <DeleteButton id={c.id} name={c.customerName ?? ""} />}
|
||||
</div>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
Reference in New Issue
Block a user