feat: 删除平台客服角色,客服查询并入发货订单 Tab

This commit is contained in:
2026-11-10 10:28:48 +08:00
parent eba3af2054
commit 162745082b
18 changed files with 195 additions and 268 deletions
+2 -23
View File
@@ -23,7 +23,6 @@ const PlatformOrders = lazy(() => import('./pages/PlatformOrders'))
const PlatformProducts = lazy(() => import('./pages/PlatformProducts'))
const PlatformUsers = lazy(() => import('./pages/PlatformUsers'))
const PlatformRock = lazy(() => import('./pages/PlatformRock'))
const SupportRockTokens = lazy(() => import('./pages/SupportRockTokens'))
// RouteFallback 是懒加载页面与权限校验的统一占位,避免切换时白屏。
function RouteFallback() {
@@ -60,21 +59,8 @@ function MerchantPermissionRoute({ permission, children }: { permission?: string
return merchantPermissions.includes(permission) ? <>{children}</> : <Navigate to="/" replace />
}
function SupportQueryRoute({ children }: { children: ReactNode }) {
const { isAdmin, isPlatformSupport } = useAuth()
return isAdmin || isPlatformSupport ? <>{children}</> : <Navigate to="/" replace />
}
function HomeRoute() {
const { isPlatformSupport } = useAuth()
if (isPlatformSupport) return <Navigate to="/support-rock-tokens" replace />
return <Dashboard />
}
function MerchantCenterRoute() {
const { isPlatformSupport } = useAuth()
const location = useLocation()
if (isPlatformSupport) return <Navigate to="/merchant-orders" replace />
const requestedTab = new URLSearchParams(location.search).get('tab') || 'products'
const tab = requestedTab in tabPermissions ? requestedTab : 'products'
return (
@@ -97,7 +83,7 @@ function AppRoutes() {
</PrivateRoute>
}
>
<Route index element={<HomeRoute />} />
<Route index element={<Dashboard />} />
<Route path="merchant-center" element={<MerchantCenterRoute />} />
<Route path="merchant-products" element={<MerchantPermissionRoute permission="products:manage"><MerchantCenter fixedTab="products" title="商品列表" /></MerchantPermissionRoute>} />
<Route path="merchant-orders" element={<MerchantPermissionRoute permission="orders:manage"><MerchantCenter fixedTab="orders" title="发货订单" /></MerchantPermissionRoute>} />
@@ -139,14 +125,7 @@ function AppRoutes() {
</AdminRoute>
}
/>
<Route
path="support-rock-tokens"
element={
<SupportQueryRoute>
<SupportRockTokens />
</SupportQueryRoute>
}
/>
<Route path="support-rock-tokens" element={<Navigate to="/merchant-orders" replace />} />
<Route path="platform-users" element={<AdminRoute><PlatformUsers /></AdminRoute>} />
<Route path="open-api" element={<MerchantPermissionRoute permission="api:manage"><OpenApiDocs /></MerchantPermissionRoute>} />
<Route
-2
View File
@@ -103,7 +103,6 @@ export const userApi = {
username: string
password: string
nickname?: string
role?: 'admin' | 'platform_support'
}) => request.post("/platform/admins", data).then((r) => r.data.data as User),
update: (
id: number,
@@ -112,7 +111,6 @@ export const userApi = {
nickname?: string
password?: string
status: number
role?: 'admin' | 'platform_support'
},
) =>
request
+6 -28
View File
@@ -70,7 +70,6 @@ const adminSections: SidebarSection[] = [
{ key: 'merchant-products', label: '商品列表', path: '/merchant-products' },
{ key: 'platform-products', label: '渠道与路由配置', path: '/platform-products' },
{ key: 'platform-rock', label: 'Rock发货与库存风控', path: '/platform-rock' },
{ key: 'support-rock', label: '客服查询', path: '/support-rock-tokens' },
],
},
{
@@ -123,21 +122,6 @@ const adminSections: SidebarSection[] = [
},
]
const platformSupportSections: SidebarSection[] = [
{
key: 'products',
label: '商品管理',
icon: <AppstoreOutlined />,
children: [{ key: 'support-rock', label: '客服查询', path: '/support-rock-tokens' }],
},
{
key: 'orders',
label: '订单管理',
icon: <OrderedListOutlined />,
children: [{ key: 'fulfillment-orders', label: '发货订单', path: '/merchant-orders' }],
},
]
const merchantSections: SidebarSection[] = [
{
key: 'dashboard',
@@ -190,7 +174,6 @@ function getSelectedKey(pathname: string, search: string) {
if (pathname.startsWith('/merchant-products')) return 'merchant-products'
if (pathname.startsWith('/platform-products')) return 'platform-products'
if (pathname.startsWith('/platform-rock')) return 'platform-rock'
if (pathname.startsWith('/support-rock-tokens')) return 'support-rock'
if (pathname.startsWith('/merchant-orders')) return 'fulfillment-orders'
if (pathname.startsWith('/merchant-wallet')) return 'merchant-wallet'
if (pathname.startsWith('/merchant-recharge')) return 'merchant-recharge'
@@ -245,13 +228,13 @@ export default function MainLayout() {
const [collapsed, setCollapsed] = useState<boolean>(() => {
return localStorage.getItem(SIDEBAR_COLLAPSED_KEY) === 'true'
})
const { user, logout, refreshProfile, isAdmin, isPlatformSupport, merchant, merchantPermissions } = useAuth()
const { user, logout, refreshProfile, isAdmin, merchant, merchantPermissions } = useAuth()
useEffect(() => {
// 平台角色保持全局视角,清除任何残留的商户上下文
if ((isAdmin || isPlatformSupport) && localStorage.getItem('merchant_id')) {
// 平台管理员保持全局视角,清除任何残留的商户上下文
if (isAdmin && localStorage.getItem('merchant_id')) {
localStorage.removeItem('merchant_id')
}
}, [isAdmin, isPlatformSupport])
}, [isAdmin])
const [passwordOpen, setPasswordOpen] = useState(false)
const [passwordSaving, setPasswordSaving] = useState(false)
const [passwordForm] = Form.useForm()
@@ -261,7 +244,6 @@ export default function MainLayout() {
const sections = useMemo(() => {
if (isAdmin) return adminSections
if (isPlatformSupport) return platformSupportSections
const features = new Set((merchant?.features || '').split(/[\s,]+/).filter(Boolean))
return merchantSections.flatMap((section) => {
if (!section.children) return [section]
@@ -271,7 +253,7 @@ export default function MainLayout() {
))
return children.length > 0 ? [{ ...section, children }] : []
})
}, [isAdmin, isPlatformSupport, merchant?.features, merchantPermissions])
}, [isAdmin, merchant?.features, merchantPermissions])
const selectedKey = getSelectedKey(location.pathname, location.search)
const [openKeys, setOpenKeys] = useState<string[]>(() => loadStoredOpenKeys(sections, selectedKey))
@@ -343,7 +325,7 @@ export default function MainLayout() {
<div style={{ padding: '4px 0' }}>
<div style={{ fontWeight: 600, color: '#0f172a' }}>{user?.nickname || user?.username}</div>
<div style={{ fontSize: 12, color: '#64748b' }}>
角色:{isAdmin ? '平台超级管理员' : isPlatformSupport ? '平台客服' : '商户成员'}
角色:{isAdmin ? '平台超级管理员' : '商户成员'}
</div>
</div>
),
@@ -479,10 +461,6 @@ export default function MainLayout() {
<Tag color="blue" bordered={false} style={{ margin: 0, fontSize: 11, fontWeight: 600 }}>
管理员
</Tag>
) : isPlatformSupport ? (
<Tag color="purple" bordered={false} style={{ margin: 0, fontSize: 11, fontWeight: 600 }}>
平台客服
</Tag>
) : (
<Tag color="cyan" bordered={false} style={{ margin: 0, fontSize: 11, fontWeight: 600 }}>
商户
+5 -4
View File
@@ -60,7 +60,7 @@ export default function MerchantCenter({
fixedTab,
title = "商户中心",
}: MerchantCenterProps = {}) {
const { isAdmin, isPlatformSupport, user } = useAuth();
const { isAdmin, user } = useAuth();
const location = useLocation();
const navigate = useNavigate();
const routeTab = useMemo(
@@ -726,6 +726,8 @@ export default function MerchantCenter({
}
};
// 客服查询只对平台管理员与「自用自动发货」商户展示,其他商户保持原发货订单页。
const canUseSupportQuery = isAdmin || merchant?.code === "self-order-site";
const tabItems = [
{
key: "products",
@@ -766,6 +768,7 @@ export default function MerchantCenter({
onRevokeLink={revokeDeliveryLink}
onRestoreLink={restoreDeliveryLink}
onCancelOrder={cancelOrder}
showSupportQuery={canUseSupportQuery}
/>
),
},
@@ -893,9 +896,7 @@ export default function MerchantCenter({
title={title}
subtitle={
merchant
? isPlatformSupport
? `${merchant.name} (${merchant.code}) · 平台客服`
: `${merchant.name} (${merchant.code}) · 当前身份: ${merchantRole ? roleText(merchantRole) : "-"}`
? `${merchant.name} (${merchant.code}) · 当前身份: ${merchantRole ? roleText(merchantRole) : "-"}`
: "商户配置与管理中心"
}
breadcrumbs={computedBreadcrumbs}
+6 -32
View File
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { Button, Form, Input, Modal, Popconfirm, Select, Space, Switch, Table, Tabs, Tag, Typography, message } from 'antd'
import { Button, Form, Input, Modal, Popconfirm, Space, Switch, Table, Tabs, Tag, Typography, message } from 'antd'
import { DeleteOutlined, EditOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons'
import type { ColumnsType } from 'antd/es/table'
import { platformApi, userApi } from '../api'
@@ -15,16 +15,6 @@ type AdminFormValues = {
nickname?: string
password?: string
status: boolean
role: 'admin' | 'platform_support'
}
const platformRoleOptions = [
{ value: 'admin', label: '平台管理员' },
{ value: 'platform_support', label: '平台客服' },
]
function platformRoleLabel(role: string) {
return platformRoleOptions.find((item) => item.value === role)?.label || role
}
function maskPhone(value?: string) {
@@ -79,7 +69,7 @@ export default function PlatformUsers() {
const openCreate = () => {
setEditingAdmin(null)
form.setFieldsValue({ username: '', nickname: '', password: '', status: true, role: 'admin' })
form.setFieldsValue({ username: '', nickname: '', password: '', status: true })
setModalOpen(true)
}
@@ -90,7 +80,6 @@ export default function PlatformUsers() {
nickname: record.nickname,
password: '',
status: record.status === 1,
role: record.role === 'platform_support' ? 'platform_support' : 'admin',
})
setModalOpen(true)
}, [form])
@@ -105,15 +94,13 @@ export default function PlatformUsers() {
nickname: values.nickname || '',
password: values.password || undefined,
status: values.status ? 1 : 0,
role: values.role,
})
message.success('平台账号已更新,角色变更需该账号重新登录生效')
message.success('平台账号已更新')
} else {
await userApi.create({
username: values.username,
password: values.password || '',
nickname: values.nickname || '',
role: values.role,
})
message.success('平台账号已创建')
}
@@ -228,16 +215,6 @@ export default function PlatformUsers() {
const columns: ColumnsType<User> = useMemo(() => [
{ title: '用户名', dataIndex: 'username', width: 220, render: (value) => <Typography.Text strong>{value}</Typography.Text> },
{ title: '昵称', dataIndex: 'nickname', width: 180, render: (value) => value || '-' },
{
title: '角色',
dataIndex: 'role',
width: 120,
render: (role) => (
<Tag color={role === 'platform_support' ? 'purple' : 'blue'}>
{platformRoleLabel(role)}
</Tag>
),
},
{ title: '手机号', width: 170, render: (_, record) => phoneCell(record) },
{ title: '绑定设备', width: 200, render: (_, record) => deviceCell(record) },
{ title: '状态', dataIndex: 'status', width: 100, render: (value) => value === 1 ? <Tag color="green">启用</Tag> : <Tag>停用</Tag> },
@@ -248,7 +225,7 @@ export default function PlatformUsers() {
render: (_, record) => record.id === currentUser?.id ? <Typography.Text type="secondary">当前账号</Typography.Text> : (
<Space size={0}>
<Button type="link" size="small" icon={<EditOutlined />} onClick={() => openEdit(record)}>编辑</Button>
<Popconfirm title={`确认删除平台账号「${record.username}」?`} description="删除后无法登录平台;平台客服的订单与客服查询权限会同时失效。" onConfirm={() => remove(record)} okButtonProps={{ danger: true }}>
<Popconfirm title={`确认删除平台账号「${record.username}」?`} description="删除后该账号将无法登录平台。" onConfirm={() => remove(record)} okButtonProps={{ danger: true }}>
<Button type="link" danger size="small" icon={<DeleteOutlined />}>删除</Button>
</Popconfirm>
</Space>
@@ -343,7 +320,7 @@ export default function PlatformUsers() {
<div>
<PageHeader
title="账号管理"
subtitle="平台管理员与平台客服统一管理;平台客服仅可操作自营商户发货订单与查询全部绑定中 Token。"
subtitle="平台管理员账号统一管理;商户账号请在「商户账号」页签中管理。"
breadcrumbs={[{ title: '账号管理' }]}
extra={<Space><Button icon={<ReloadOutlined />} loading={loading} onClick={() => tab === 'admins' ? void loadAdmins() : void loadMerchantAccounts()}>刷新</Button>{tab === 'admins' && <Button type="primary" icon={<PlusOutlined />} onClick={openCreate}>新建平台账号</Button>}</Space>}
/>
@@ -357,16 +334,13 @@ export default function PlatformUsers() {
okText="保存"
destroyOnHidden
>
<Form form={form} layout="vertical" preserve={false} initialValues={{ status: true, role: 'admin' }}>
<Form form={form} layout="vertical" preserve={false} initialValues={{ status: true }}>
<Form.Item label="用户名" name="username" rules={[{ required: true, message: '请输入用户名' }, { max: 64, message: '用户名不能超过 64 个字符' }]}>
<Input autoComplete="off" />
</Form.Item>
<Form.Item label="昵称" name="nickname" rules={[{ max: 64, message: '昵称不能超过 64 个字符' }]}>
<Input autoComplete="off" />
</Form.Item>
<Form.Item label="角色" name="role" rules={[{ required: true, message: '请选择角色' }]} extra={editingAdmin ? '角色变更后,该账号需重新登录生效' : undefined}>
<Select options={platformRoleOptions} />
</Form.Item>
<Form.Item label={editingAdmin ? '新密码' : '密码'} name="password" rules={editingAdmin ? [{ min: 6, message: '密码至少 6 位' }] : [{ required: true, message: '请输入密码' }, { min: 6, message: '密码至少 6 位' }]} extra={editingAdmin ? '留空表示不修改密码' : undefined}>
<Input.Password autoComplete="new-password" />
</Form.Item>
+12 -6
View File
@@ -9,7 +9,11 @@ import { buildTokenColumns } from './platformRock/tokenColumns'
import { TokenStatusLogDrawer } from './platformRock/TokenStatusLogDrawer'
import { VoucherPreviewModal } from './platformRock/VoucherPreviewModal'
export default function SupportRockTokens() {
export default function SupportRockTokens({
embedded = false,
}: {
embedded?: boolean
}) {
const [search, setSearch] = useState('')
const [query, setQuery] = useState('')
const [searched, setSearched] = useState(false)
@@ -192,11 +196,13 @@ export default function SupportRockTokens() {
return (
<div style={{ padding: '0 4px' }}>
<PageHeader
title="客服查询 · 绑定中 Token"
subtitle="仅查询绑定中的 Token(status=bound),只读;请输入查询条件后查询,默认不加载数据。"
extra={searched ? <Tag color="blue">共 {total} 条</Tag> : undefined}
/>
{!embedded && (
<PageHeader
title="客服查询 · 绑定中 Token"
subtitle="仅查询绑定中的 Token(status=bound),只读;请输入查询条件后查询,默认不加载数据。"
extra={searched ? <Tag color="blue">共 {total} 条</Tag> : undefined}
/>
)}
<Alert
type="info"
+23 -3
View File
@@ -36,6 +36,7 @@ import {
} from "@ant-design/icons";
import type { ColumnsType } from "antd/es/table";
import { merchantApi } from "../api";
import SupportRockTokens from "./SupportRockTokens";
import { formatDateTime } from "../utils/time";
import type {
ApiClient,
@@ -484,6 +485,7 @@ export function OrdersTab({
onRevokeLink,
onRestoreLink,
onCancelOrder,
showSupportQuery,
}: {
loading: boolean;
orders: PageResult<FulfillmentOrder>;
@@ -499,11 +501,13 @@ export function OrdersTab({
onRevokeLink: (orderNo: string) => void;
onRestoreLink: (orderNo: string) => void;
onCancelOrder: (orderNo: string, reason: string) => Promise<void> | void;
showSupportQuery: boolean;
}) {
const [keyword, setKeyword] = useState(filters.keyword);
const [cancelling, setCancelling] = useState<FulfillmentOrder | null>(null);
const [cancelReason, setCancelReason] = useState("");
const [cancelSubmitting, setCancelSubmitting] = useState(false);
const [showSupport, setShowSupport] = useState(false);
useEffect(() => {
setKeyword(filters.keyword);
@@ -707,15 +711,25 @@ export function OrdersTab({
<Space direction="vertical" style={{ width: "100%" }} size="middle">
<Space wrap style={{ width: "100%", justifyContent: "space-between" }}>
<Tabs
activeKey={orderSource}
onChange={(key) => onOrderSourceChange(key as "api" | "manual")}
activeKey={showSupport ? "support" : orderSource}
onChange={(key) => {
if (key === "support") {
setShowSupport(true);
return;
}
setShowSupport(false);
onOrderSourceChange(key as "api" | "manual");
}}
items={[
{ key: "api", label: "API 订单" },
{ key: "manual", label: "手动订单" },
...(showSupportQuery
? [{ key: "support", label: "客服查询" }]
: []),
]}
style={{ minWidth: 220 }}
/>
{canManage && (
{canManage && !showSupport && (
<Space>
<Button
type="primary"
@@ -727,6 +741,10 @@ export function OrdersTab({
</Space>
)}
</Space>
{showSupport ? (
<SupportRockTokens embedded />
) : (
<>
<Card size="small" style={{ borderRadius: 8 }}>
<Space direction="vertical" size="middle" style={{ width: "100%" }}>
<Space wrap>
@@ -767,6 +785,8 @@ export function OrdersTab({
scroll={{ x: 1780 }}
pagination={pageConfig(orders, onLoadOrders)}
/>
</>
)}
<Modal
title={`取消订单:${cancelling?.order_no || ""}`}
open={!!cancelling}
-1
View File
@@ -104,7 +104,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
merchantLoading,
refreshMerchantContext,
isAdmin: user?.role === 'admin',
isPlatformSupport: user?.role === 'platform_support',
}),
[token, user, login, applyLoginResult, logout, refreshProfile, merchant, merchantRole, merchantPermissions, merchantLoading, refreshMerchantContext],
)
-1
View File
@@ -14,7 +14,6 @@ export interface AuthState {
merchantLoading: boolean
refreshMerchantContext: () => Promise<void>
isAdmin: boolean
isPlatformSupport: boolean
}
// Context 与 useAuth 单独放在本文件:auth.tsx 因此只导出 AuthProvider 组件,
+1 -1
View File
@@ -2,7 +2,7 @@ export interface User {
id: number
username: string
nickname: string
role: 'admin' | 'merchant' | 'platform_support'
role: 'admin' | 'merchant'
status: number
created_at: string
phone?: string