diff --git a/apps/frontend/src/pages/admin/cost-center/CostCenterShell.tsx b/apps/frontend/src/pages/admin/cost-center/CostCenterShell.tsx index d53ee3a0..42edb0df 100644 --- a/apps/frontend/src/pages/admin/cost-center/CostCenterShell.tsx +++ b/apps/frontend/src/pages/admin/cost-center/CostCenterShell.tsx @@ -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 ( , }, - { - key: 'mappings', - label: '渠道映射', - children: mappingsApplicable ? ( - - ) : ( - 归一,不经过渠道映射;要核对采购价请到「成本配置 → 自动发货采购价」。' - : '人工客服的订单项按内部 SKU 归一(man: 前缀),不走渠道映射;要配置消耗积分请到「成本配置 → 人工客服 SKU」。' - } - /> - ), - }, + ...(mappingsApplicable + ? [ + { + key: 'mappings', + label: '渠道映射', + children: , + }, + ] + : []), { key: 'cost', label: '成本配置', diff --git a/apps/frontend/src/pages/admin/cost-center/ProductCatalogPanel.tsx b/apps/frontend/src/pages/admin/cost-center/ProductCatalogPanel.tsx index 22b072df..86c5aa10 100644 --- a/apps/frontend/src/pages/admin/cost-center/ProductCatalogPanel.tsx +++ b/apps/frontend/src/pages/admin/cost-center/ProductCatalogPanel.tsx @@ -659,25 +659,23 @@ export function ProductCatalogPanel() { extra={ canConfig ? ( - {!productSourceFilter || - productSourceFilter === 'work_order' || - productSourceFilter === 'manual' ? ( - { - if (value?.[0] && value?.[1]) setBackfillRange([value[0], value[1]]) - }} - allowClear={false} - /> - ) : null} - {productSourceFilter !== 'affiliate_dash' ? ( - + {productSourceFilter === 'work_order' ? ( + <> + { + if (value?.[0] && value?.[1]) setBackfillRange([value[0], value[1]]) + }} + allowClear={false} + /> + + ) : null}