feat:寄卖增加对接客服,页面移动到接单平台

This commit is contained in:
2026-10-27 18:49:39 +08:00
parent 0d9fb29460
commit 2ddc26091c
6 changed files with 86 additions and 56 deletions
@@ -15,6 +15,7 @@ import AfterSalesPanel, { type AfterSalesPanelHandle } from './panels/AfterSales
import AnnouncementPanel from './panels/AnnouncementPanel'
import CancelRequestsPanel from './panels/CancelRequestsPanel'
import CategoriesPanel from './panels/CategoriesPanel'
import ConsignmentContactsPanel from './panels/ConsignmentContactsPanel'
import ConsignmentInventoryPanel from './panels/ConsignmentInventoryPanel'
import ConsignmentSubmissionsPanel from './panels/ConsignmentSubmissionsPanel'
import FeedbacksPanel from './panels/FeedbacksPanel'
@@ -44,8 +45,10 @@ export default function AdminWorkerPlatformPage() {
const isFinance = role === 'finance'
const canViewConsignment = hasAdminPermission('consignment.view')
const isConsignmentTab =
activeTab === 'consignment-inventory' || activeTab === 'consignment-submissions'
// 没有 consignment.view 时这两个 tab 不渲染,把 URL/localStorage 里的旧选择也拉回工单页,
activeTab === 'consignment-inventory' ||
activeTab === 'consignment-submissions' ||
activeTab === 'consignment-contacts'
// 没有 consignment.view 时这些 tab 不渲染,把 URL/localStorage 里的旧选择也拉回工单页,
// 否则会落在一个空的 tab 内容上。
const visibleActiveTab = isFinance
? 'finance'
@@ -113,6 +116,11 @@ export default function AdminWorkerPlatformPage() {
label: '寄售仓库',
children: <ConsignmentInventoryPanel />,
},
{
key: 'consignment-contacts',
label: '对接客服',
children: <ConsignmentContactsPanel />,
},
{
key: 'consignment-submissions',
label: '寄卖提报审核',
@@ -16,8 +16,8 @@ import {
} from 'antd'
import { useEffect, useState } from 'react'
import PageHeader from '@/components/admin/PageHeader'
import PercentTable from '@/components/common/PercentTable'
import { fetchAdminSession } from '@/services/admin/auth'
import {
createAdminConsignmentContact,
deleteAdminConsignmentContact,
@@ -26,6 +26,7 @@ import {
updateAdminConsignmentContact,
} from '@/services/admin/consignment'
import type { ConsignmentContactSupporter } from '@/types/consignment'
import { resolveAdminPermission } from '@/utils/admin-auth'
import { formatDateTime } from '@/utils/date-time'
import type { TableColumnsType } from 'antd'
@@ -45,12 +46,12 @@ const ENABLED_FILTER_OPTIONS = [
]
/**
* 配置 → 对接客服。
* 接单平台 → 对接客服。
*
* 独立名单(不复用后台账号):打手发布寄卖时必选,后台按人统计提成与快速联系。
* 已被寄卖记录引用的客服只能禁用,不能删除,保证历史单归属不丢。
*/
export default function AdminConsignmentContactsPage() {
export default function ConsignmentContactsPanel() {
const { message, modal } = App.useApp()
const queryClient = useQueryClient()
const [form] = Form.useForm<ContactForm>()
@@ -68,6 +69,18 @@ export default function AdminConsignmentContactsPage() {
return () => window.clearTimeout(timer)
}, [keywordInput])
const adminSessionQuery = useQuery({
queryKey: ['admin-session'],
queryFn: fetchAdminSession,
retry: false,
})
// 写操作统一按 consignment.manage 门控:后端接口都挂了 requireAdminPermission,
// 没有权限时按钮点了只会 403,所以直接从界面隐藏。
const canManage = resolveAdminPermission(
adminSessionQuery.data?.data.user.permissions,
'consignment.manage',
)
const query = useQuery({
queryKey: ['admin-consignment-contacts', keyword, enabledFilter],
queryFn: () =>
@@ -195,6 +208,7 @@ export default function AdminConsignmentContactsPage() {
<Switch
size="small"
checked={record.enabled}
disabled={!canManage}
loading={actionId === record.id}
checkedChildren="启用"
unCheckedChildren="禁用"
@@ -216,52 +230,55 @@ export default function AdminConsignmentContactsPage() {
title: '操作',
key: 'actions',
width: 140,
render: (_, record) => (
<Space size={4}>
<Button size="small" type="link" onClick={() => openEdit(record)}>
编辑
</Button>
<Button size="small" type="link" danger onClick={() => handleDelete(record)}>
删除
</Button>
</Space>
),
render: (_, record) =>
canManage ? (
<Space size={4}>
<Button size="small" type="link" onClick={() => openEdit(record)}>
编辑
</Button>
<Button size="small" type="link" danger onClick={() => handleDelete(record)}>
删除
</Button>
</Space>
) : (
<Text type="secondary">-</Text>
),
},
]
return (
<div>
<PageHeader
title="对接客服"
description="打手发布寄卖时必须选择对接客服;本名单独立于后台账号,用于提成归属与联系。"
extra={
<Button type="primary" icon={<PlusOutlined />} onClick={openCreate}>
新增对接客服
</Button>
}
/>
<Card size="small" style={{ marginBottom: 16 }}>
<Space wrap size={12}>
<Input
allowClear
prefix={<SearchOutlined />}
placeholder="搜索姓名 / 备注"
value={keywordInput}
onChange={(event) => setKeywordInput(event.target.value)}
style={{ width: 280 }}
/>
<Select
value={enabledFilter}
options={ENABLED_FILTER_OPTIONS}
onChange={setEnabledFilter}
style={{ width: 140 }}
/>
<Button icon={<ReloadOutlined />} onClick={() => void query.refetch()}>
刷新
</Button>
<Text type="secondary">
共 {total} 个,本页启用 {enabledCount} 个
<Space direction="vertical" size={10} style={{ width: '100%' }}>
<Space wrap size={12}>
<Input
allowClear
prefix={<SearchOutlined />}
placeholder="搜索姓名 / 备注"
value={keywordInput}
onChange={(event) => setKeywordInput(event.target.value)}
style={{ width: 280 }}
/>
<Select
value={enabledFilter}
options={ENABLED_FILTER_OPTIONS}
onChange={setEnabledFilter}
style={{ width: 140 }}
/>
<Button icon={<ReloadOutlined />} onClick={() => void query.refetch()}>
刷新
</Button>
<Text type="secondary">
共 {total} 个,本页启用 {enabledCount} 个
</Text>
{canManage ? (
<Button type="primary" icon={<PlusOutlined />} onClick={openCreate}>
新增对接客服
</Button>
) : null}
</Space>
<Text type="secondary" style={{ fontSize: 12 }}>
打手发布寄卖时必须选择对接客服;已被寄卖记录使用的客服只能禁用,不能删除。
</Text>
</Space>
</Card>