fix(admin): 成本中心来源页签与成本异常交互

This commit is contained in:
yml2213
2026-11-02 13:17:16 +08:00
parent c79a7e0790
commit fbd5f8f74e
2 changed files with 34 additions and 39 deletions
@@ -23,6 +23,7 @@ import {
Typography,
} from 'antd'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useEffect } from 'react'
import FinanceSubNav from '@/components/admin/FinanceSubNav'
import { usePersistedState } from '@/hooks/usePersistedState'
@@ -85,6 +86,13 @@ export default function CostCenterShell() {
'products',
isCostCenterTab,
)
const mappingsApplicable = scope === 'all' || scope === 'work_order'
useEffect(() => {
if (!mappingsApplicable && activeTab === 'mappings') {
setActiveTab('products')
}
}, [activeTab, mappingsApplicable, setActiveTab])
const overviewQuery = useQuery({
queryKey: ['admin-cost-center-overview', scope],
@@ -112,8 +120,6 @@ export default function CostCenterShell() {
scope === 'all'
? undefined
: (scope as 'affiliate_dash' | 'work_order' | 'third_party_voucher' | 'manual')
const mappingsApplicable = scope === 'all' || scope === 'work_order'
return (
<CostCenterContext.Provider
value={{
@@ -205,24 +211,15 @@ export default function CostCenterShell() {
label: '标准商品',
children: <ProductCatalogPanel />,
},
{
key: 'mappings',
label: '渠道映射',
children: mappingsApplicable ? (
<ChannelMappingPanel />
) : (
<Alert
type="info"
showIcon
message={`${scopeLabel}不维护渠道映射`}
description={
scope === 'affiliate_dash'
? '自动发货的订单项直接按 aff:<skuCode> 归一,不经过渠道映射;要核对采购价请到「成本配置 → 自动发货采购价」。'
: '人工客服的订单项按内部 SKU 归一(man: 前缀),不走渠道映射;要配置消耗积分请到「成本配置 → 人工客服 SKU」。'
}
/>
),
},
...(mappingsApplicable
? [
{
key: 'mappings',
label: '渠道映射',
children: <ChannelMappingPanel />,
},
]
: []),
{
key: 'cost',
label: '成本配置',
@@ -659,25 +659,23 @@ export function ProductCatalogPanel() {
extra={
canConfig ? (
<Space size={6} wrap>
{!productSourceFilter ||
productSourceFilter === 'work_order' ||
productSourceFilter === 'manual' ? (
<AdminRangePicker
value={backfillRange}
onChange={(value) => {
if (value?.[0] && value?.[1]) setBackfillRange([value[0], value[1]])
}}
allowClear={false}
/>
) : null}
{productSourceFilter !== 'affiliate_dash' ? (
<Button
icon={<SyncOutlined />}
loading={bootstrapPreviewing || bootstrapApplying}
onClick={() => void runTemplateBootstrap()}
>
从接单模板初始化
</Button>
{productSourceFilter === 'work_order' ? (
<>
<AdminRangePicker
value={backfillRange}
onChange={(value) => {
if (value?.[0] && value?.[1]) setBackfillRange([value[0], value[1]])
}}
allowClear={false}
/>
<Button
icon={<SyncOutlined />}
loading={bootstrapPreviewing || bootstrapApplying}
onClick={() => void runTemplateBootstrap()}
>
从接单模板初始化
</Button>
</>
) : null}
<Button
icon={<ReloadOutlined />}