优化售后问题单后台位置
This commit is contained in:
@@ -1,27 +1,35 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Card, Space, Tabs } from 'antd'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useSearchParams } from 'react-router'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useLocation, useSearchParams } from 'react-router'
|
||||
|
||||
import PageHeader from '@/components/admin/PageHeader'
|
||||
import type { WorkOrder } from '@/types/worker-platform'
|
||||
import { fetchAdminWorkerPlatformSummary } from '@/services/admin'
|
||||
import { getAdminRole } from '@/utils/admin-auth'
|
||||
import CategoriesPanel from './panels/CategoriesPanel'
|
||||
import AfterSalesPanel, { type AfterSalesPanelHandle } from './panels/AfterSalesPanel'
|
||||
import AnnouncementPanel from './panels/AnnouncementPanel'
|
||||
import CancelRequestsPanel from './panels/CancelRequestsPanel'
|
||||
import FinancePanel from './panels/FinancePanel'
|
||||
import CategoriesPanel from './panels/CategoriesPanel'
|
||||
import FeedbacksPanel from './panels/FeedbacksPanel'
|
||||
import FinancePanel from './panels/FinancePanel'
|
||||
import HallConfigPanel from './panels/HallConfigPanel'
|
||||
import LevelsPanel from './panels/LevelsPanel'
|
||||
import NotificationsPanel from './panels/NotificationsPanel'
|
||||
import ProductRulesPanel from './panels/ProductRulesPanel'
|
||||
import ProductMatchPanel from './panels/ProductMatchPanel'
|
||||
import ProductRulesPanel from './panels/ProductRulesPanel'
|
||||
import WorkersPanel from './panels/WorkersPanel'
|
||||
import WorkOrdersPanel from './panels/WorkOrdersPanel'
|
||||
|
||||
type AfterSalesLocationState = {
|
||||
createOrder?: WorkOrder
|
||||
}
|
||||
|
||||
export default function AdminWorkerPlatformPage() {
|
||||
const [searchParams] = useSearchParams()
|
||||
const location = useLocation()
|
||||
const [activeTab, setActiveTab] = useState(() => loadActiveTab(searchParams.get('tab')))
|
||||
const afterSalesPanelRef = useRef<AfterSalesPanelHandle>(null)
|
||||
const role = getAdminRole()
|
||||
const isAdmin = role === 'admin'
|
||||
const isSupport = role === 'support'
|
||||
@@ -34,14 +42,33 @@ export default function AdminWorkerPlatformPage() {
|
||||
}
|
||||
}, [searchParams])
|
||||
|
||||
useEffect(() => {
|
||||
const state = location.state as AfterSalesLocationState | null
|
||||
if (state?.createOrder) {
|
||||
setActiveTab('after-sales')
|
||||
afterSalesPanelRef.current?.openCreateModal(state.createOrder)
|
||||
// 清掉 state,避免刷新或后退时重复弹窗。
|
||||
window.history.replaceState({}, '')
|
||||
}
|
||||
}, [location.state])
|
||||
|
||||
function changeTab(nextTab: string) {
|
||||
setActiveTab(nextTab)
|
||||
localStorage.setItem(ACTIVE_TAB_STORAGE_KEY, nextTab)
|
||||
}
|
||||
|
||||
const afterSalesTab = {
|
||||
key: 'after-sales',
|
||||
label: '售后问题单',
|
||||
children: <AfterSalesPanel ref={afterSalesPanelRef} />,
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="page-stack">
|
||||
<PageHeader title="接单平台" description="管理打手、接单工单、等级权限和本地 Mock 工单。" />
|
||||
<PageHeader
|
||||
title="接单平台"
|
||||
description="管理打手、接单工单、等级权限、售后追责和本地 Mock 工单。"
|
||||
/>
|
||||
<SummaryCards />
|
||||
<Tabs
|
||||
destroyOnHidden={false}
|
||||
@@ -53,11 +80,13 @@ export default function AdminWorkerPlatformPage() {
|
||||
{ key: 'orders', label: '接单工单', children: <WorkOrdersPanel /> },
|
||||
{ key: 'cancel-requests', label: '撤单审核', children: <CancelRequestsPanel /> },
|
||||
{ key: 'feedbacks', label: '问题反馈', children: <FeedbacksPanel /> },
|
||||
afterSalesTab,
|
||||
]
|
||||
: [
|
||||
{ key: 'orders', label: '接单工单', children: <WorkOrdersPanel /> },
|
||||
{ key: 'cancel-requests', label: '撤单审核', children: <CancelRequestsPanel /> },
|
||||
{ key: 'feedbacks', label: '问题反馈', children: <FeedbacksPanel /> },
|
||||
afterSalesTab,
|
||||
...(isAdmin
|
||||
? [{ key: 'announcement', label: '公告管理', children: <AnnouncementPanel /> }]
|
||||
: []),
|
||||
@@ -85,6 +114,7 @@ function loadActiveTabPreference(): string {
|
||||
return saved === 'orders' ||
|
||||
saved === 'cancel-requests' ||
|
||||
saved === 'feedbacks' ||
|
||||
saved === 'after-sales' ||
|
||||
saved === 'announcement' ||
|
||||
saved === 'rules' ||
|
||||
saved === 'product-match' ||
|
||||
@@ -107,6 +137,7 @@ function isWorkerPlatformTab(tab: string | null): tab is string {
|
||||
'orders',
|
||||
'cancel-requests',
|
||||
'feedbacks',
|
||||
'after-sales',
|
||||
'announcement',
|
||||
'rules',
|
||||
'product-match',
|
||||
|
||||
@@ -42,7 +42,6 @@ import JsonPreview from '@/components/admin/JsonPreview'
|
||||
import WorkOrderEventTimeline from '@/components/WorkOrderEventTimeline'
|
||||
import ImageUpload from '@/components/files/ImageUpload'
|
||||
import ImagePreviewList from '@/components/files/ImagePreviewList'
|
||||
import AfterSalesPanel, { type AfterSalesPanelHandle } from './AfterSalesPanel'
|
||||
import {
|
||||
acceptAdminWorkOrder,
|
||||
acceptAdminWorkOrderShare,
|
||||
@@ -135,7 +134,6 @@ export default function WorkOrdersPanel() {
|
||||
const navigate = useNavigate()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const queryClient = useQueryClient()
|
||||
const afterSalesPanelRef = useRef<AfterSalesPanelHandle>(null)
|
||||
const canEditRequirementFields = hasAdminRole('operator')
|
||||
const canViewStatistics = hasAdminRole('operator')
|
||||
const [statuses, setStatuses] = useState<string[]>([])
|
||||
@@ -989,7 +987,11 @@ export default function WorkOrdersPanel() {
|
||||
<Button
|
||||
icon={<WarningOutlined />}
|
||||
danger
|
||||
onClick={() => afterSalesPanelRef.current?.openCreateModal(row)}
|
||||
onClick={() =>
|
||||
navigate('/admin/worker-platform?tab=after-sales', {
|
||||
state: { createOrder: row },
|
||||
})
|
||||
}
|
||||
>
|
||||
售后
|
||||
</Button>
|
||||
@@ -1165,7 +1167,6 @@ export default function WorkOrdersPanel() {
|
||||
scroll={{ x: 1240 }}
|
||||
/>
|
||||
</Card>
|
||||
<AfterSalesPanel ref={afterSalesPanelRef} />
|
||||
<Drawer
|
||||
className="worker-order-detail-drawer"
|
||||
title={
|
||||
|
||||
Reference in New Issue
Block a user