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