diff --git a/src/config/menuCatalog.ts b/src/config/menuCatalog.ts index 9a28c17..3ba6cea 100644 --- a/src/config/menuCatalog.ts +++ b/src/config/menuCatalog.ts @@ -38,6 +38,7 @@ export const MENU_CATALOG: MenuCatalogEntry[] = [ }, { menuKey: 'customers-list', path: '/customers', defaultLabel: '客户列表', icon: 'ChevronRight', permission: 'customer_manage', secondary: true }, { menuKey: 'customers-quote-versions', path: '/customers/quote-versions', defaultLabel: '报价管理', icon: 'ChevronRight', permission: 'customer_manage', secondary: true }, + { menuKey: 'customers-supply-review', path: '/customers/supply-review', defaultLabel: '供需变更审核', icon: 'ChevronRight', permission: 'customer_manage', secondary: true }, { menuKey: 'products-categories', path: '/products/categories', defaultLabel: '分类管理', icon: 'ChevronRight', permission: ['category_manage', 'product_manage'], secondary: true }, { menuKey: 'products-skus', path: '/products/skus', defaultLabel: '商品管理', icon: 'ChevronRight', permission: ['sku_manage', 'product_manage'], secondary: true }, { menuKey: 'products-units', path: '/products/units', defaultLabel: '单位管理', icon: 'ChevronRight', permission: ['sku_manage', 'product_manage'], secondary: true }, diff --git a/src/i18n/locales/en/quotes.ts b/src/i18n/locales/en/quotes.ts index 04cad52..4d70de8 100644 --- a/src/i18n/locales/en/quotes.ts +++ b/src/i18n/locales/en/quotes.ts @@ -5,6 +5,10 @@ export const quotes: MessageDict = { 'tab.history': 'History', 'tab.library': 'Product library', 'tab.pendingCharges': 'Pending changes', + 'supplyReview.title': 'Supply change review', + 'supplyReview.hint': 'All price changes between supplier and delivery are reviewed here.', + 'supplyReview.tab.inbound': 'To review', + 'supplyReview.tab.outbound': 'Submitted by us', 'tab.deliveryPrice': 'Delivery sale price confirmation', 'history.hint': 'Expired, rollover-archived, or replaced by a newer quote', diff --git a/src/i18n/locales/id/quotes.ts b/src/i18n/locales/id/quotes.ts index 0e245e8..42342cc 100644 --- a/src/i18n/locales/id/quotes.ts +++ b/src/i18n/locales/id/quotes.ts @@ -5,6 +5,10 @@ export const quotes: MessageDict = { 'tab.history': 'Riwayat', 'tab.library': 'Pustaka produk', 'tab.pendingCharges': 'Perubahan menunggu', + 'supplyReview.title': 'Tinjauan perubahan pasokan', + 'supplyReview.hint': 'Semua perubahan harga antara pemasok dan pengiriman ditinjau di sini.', + 'supplyReview.tab.inbound': 'Perlu ditinjau', + 'supplyReview.tab.outbound': 'Diajukan kami', 'tab.deliveryPrice': 'Konfirmasi harga jual pengiriman', 'history.hint': 'Kedaluwarsa, diarsipkan rollover, atau diganti penawaran baru', diff --git a/src/i18n/locales/zh-CN/quotes.ts b/src/i18n/locales/zh-CN/quotes.ts index 6ed8109..a377842 100644 --- a/src/i18n/locales/zh-CN/quotes.ts +++ b/src/i18n/locales/zh-CN/quotes.ts @@ -5,6 +5,10 @@ export const quotes: MessageDict = { 'tab.history': '历史报价', 'tab.library': '商品库', 'tab.pendingCharges': '待审改价', + 'supplyReview.title': '供需变更审核', + 'supplyReview.hint': '供应商与配送商之间的价格变更都在这里审核:待我审核 / 我提出的。', + 'supplyReview.tab.inbound': '待我审核', + 'supplyReview.tab.outbound': '我提出的', 'tab.deliveryPrice': '配送商销售价确认', 'history.hint': '已过期、顺延归档或已被新报价替换', diff --git a/src/modules/businessModules.ts b/src/modules/businessModules.ts index 5b08d64..f3302f7 100644 --- a/src/modules/businessModules.ts +++ b/src/modules/businessModules.ts @@ -70,7 +70,7 @@ export const BUSINESS_MODULES: BusinessModuleDef[] = [ id: 'customer', name: '客户管理', permissions: ['customer_manage', 'alias_manage'], - menuKeys: ['customers-list', 'customers-quote-versions'], + menuKeys: ['customers-list', 'customers-quote-versions', 'customers-supply-review'], routes: [ { path: 'customers', @@ -79,6 +79,7 @@ export const BUSINESS_MODULES: BusinessModuleDef[] = [ { path: '', page: 'CustomerManagement', permission: 'customer_manage' }, { path: 'alias-library', page: 'CustomerManagement', permission: ['customer_manage', 'alias_manage'], redirect: '/customers/quote-versions?view=library' }, { path: 'quote-versions', page: 'QuoteVersionManagement', permission: 'customer_manage' }, + { path: 'supply-review', page: 'SupplyReview', permission: 'customer_manage' }, ], }, ], diff --git a/src/modules/routes.tsx b/src/modules/routes.tsx index 4b9289d..c526fb5 100644 --- a/src/modules/routes.tsx +++ b/src/modules/routes.tsx @@ -21,6 +21,7 @@ const PAGE_LOADERS: Record> = { UnitManagement: lazyPage(() => import('../pages/products/UnitManagement'), 'UnitManagement'), CustomerManagement: lazyPage(() => import('../pages/customers/CustomerManagement'), 'CustomerManagement'), QuoteVersionManagement: lazyPage(() => import('../pages/customers/QuoteVersionManagement'), 'QuoteVersionManagement'), + SupplyReview: lazyPage(() => import('../pages/customers/SupplyReview'), 'SupplyReview'), SupplierManagement: lazyPage(() => import('../pages/suppliers/SupplierManagement'), 'SupplierManagement'), OrderManagement: lazyPage(() => import('../pages/orders/orderManagement'), 'OrderManagement'), OrderTrash: lazyPage(() => import('../pages/orders/OrderTrash'), 'OrderTrash'), diff --git a/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx b/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx index bd6f86b..fe9f28b 100644 --- a/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx +++ b/src/pages/customers/QuoteDeliveryPriceProposalsPanel.tsx @@ -37,16 +37,20 @@ function formatTime(value: string | null | undefined): string { export type QuoteDeliveryPriceProposalsPanelProps = { /** 是否有审批权(`customer_manage`);false = 只读 */ canApprove: boolean; + /** 只看某个方向(服务端已返回两向;null/undefined = 全部) */ + direction?: 'from_delivery' | 'to_delivery' | null; /** 审核通过后回调(页面用来刷新报价单列表/详情) */ onApplied?: () => void; }; export const QuoteDeliveryPriceProposalsPanel: React.FC = ({ canApprove, + direction = null, onApplied, }) => { const t = useT(); - const [rows, setRows] = useState([]); + const [allRows, setRows] = useState([]); + const rows = direction ? allRows.filter((row) => row.direction === direction) : allRows; const [loading, setLoading] = useState(false); const [actingId, setActingId] = useState(null); const [rejecting, setRejecting] = useState<{ id: string; reason: string } | null>(null); diff --git a/src/pages/customers/QuoteVersionManagement.priceProposal.contract.test.ts b/src/pages/customers/QuoteVersionManagement.priceProposal.contract.test.ts index 292062c..c2c384f 100644 --- a/src/pages/customers/QuoteVersionManagement.priceProposal.contract.test.ts +++ b/src/pages/customers/QuoteVersionManagement.priceProposal.contract.test.ts @@ -17,25 +17,30 @@ describe('报价单页 · 双向价格传递接线', () => { expect(page).toMatch(/\{isActiveSheet\(row\) && canManageQuotes && \(/); expect(page).toContain('submitQuotePriceProposalApi(row.quote_sheet_code)'); expect(page).toContain("notify.success(t('quotes.toast.submittedForDeliveryReview'))"); - expect(page).toMatch(/setPageTab\('deliveryPrice'\)/); + // 2026-10-19:提交成功后跳到统一的「供需变更审核」页 + expect(page).toMatch(/navigate\('\/customers\/supply-review'\)/); expect(page).toContain("notify.error(error?.message || t('quotes.toast.submitForDeliveryFail'))"); // 防连点:同一时刻只允许一条在途 expect(page).toContain('submittingProposalCode'); expect(page).toMatch(/disabled=\{submittingProposalCode === row\.quote_sheet_code\}/); }); - it('「配送商成本价确认」是页内页签(不新增菜单),审批权按 customer_manage 收窄', () => { - expect(page).toContain("t('quotes.tab.deliveryPrice')"); - expect(page).toMatch(/id: 'deliveryPrice', label: t\('quotes\.tab\.deliveryPrice'\), hidden: !canManageQuotes/); - expect(page).toMatch(/pageTab === 'deliveryPrice'/); - expect(page).toContain(' { + // 报价页不再有 deliveryPrice 页签,而是重定向到统一页 + expect(page).not.toMatch(/id: 'deliveryPrice'/); + expect(page).toMatch(/navigate\('\/customers\/supply-review', \{ replace: true \}\)/); + const review = readFileSync(new URL('./SupplyReview.tsx', import.meta.url), 'utf8'); + expect(review).toContain(' { - expect(page).toMatch( - /if \(\(view !== 'pending' && view !== 'deliveryPrice' && view !== 'skuMappings'\) \|\| canManageQuotes\) return;/ - ); + expect(page).toMatch(/if \(view !== 'skuMappings' \|\| canManageQuotes\) return;/); }); it('提交配送商审核失败时透出后端中文说明(如内部审核在途 409)', () => { diff --git a/src/pages/customers/QuoteVersionManagement.tsx b/src/pages/customers/QuoteVersionManagement.tsx index a24cfac..85bfd32 100644 --- a/src/pages/customers/QuoteVersionManagement.tsx +++ b/src/pages/customers/QuoteVersionManagement.tsx @@ -1,7 +1,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Plus, RefreshCw, ChevronDown, ChevronUp, Trash2, X, Pencil, Search } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; -import { useSearchParams } from 'react-router-dom'; +import { useNavigate, useSearchParams } from 'react-router-dom'; import { supabase } from '../../supabase/client'; import { notify } from '../../utils/notify'; import { useAuth } from '../../hooks/useAuth'; @@ -47,7 +47,6 @@ import { useClientTablePagination } from '../../hooks/useClientTablePagination'; import { TablePaginationBar } from '../../components/ui/TablePaginationBar'; import { SortableThLabel } from '../../components/ui/SortableThLabel'; import { CustomerSkuLibraryPanel } from '../../components/customers/CustomerSkuLibraryPanel'; -import { QuoteDeliveryPriceProposalsPanel } from './QuoteDeliveryPriceProposalsPanel'; import { QuoteSkuMappingsPanel } from './QuoteSkuMappingsPanel'; import { AppPageTabs } from '../../components/ModuleTabLayout'; import { PageFilterToolbar } from '../../components/ui/PagePrimitives'; @@ -335,17 +334,22 @@ export const QuoteVersionManagement: React.FC = () => { const canManageQuotes = hasPermission(['customer_manage', 'order_manage']); const canManageCustomerLibrary = hasPermission('customer_manage'); const [searchParams, setSearchParams] = useSearchParams(); - const pageTab: 'sheets' | 'library' | 'deliveryPrice' | 'skuMappings' = + const navigate = useNavigate(); + // 2026-10-19:配送商销售价确认已合并到「供需变更审核」/customers/supply-review,旧链接直接跳过去 + useEffect(() => { + if (searchParams.get('view') === 'deliveryPrice') { + navigate('/customers/supply-review', { replace: true }); + } + }, [searchParams, navigate]); + const pageTab: 'sheets' | 'library' | 'skuMappings' = searchParams.get('view') === 'library' ? 'library' - : searchParams.get('view') === 'deliveryPrice' - ? 'deliveryPrice' - : searchParams.get('view') === 'skuMappings' - ? 'skuMappings' - : 'sheets'; - const setPageTab = (tab: 'sheets' | 'library' | 'deliveryPrice' | 'skuMappings') => { + : searchParams.get('view') === 'skuMappings' + ? 'skuMappings' + : 'sheets'; + const setPageTab = (tab: 'sheets' | 'library' | 'skuMappings') => { const next = new URLSearchParams(searchParams); - if (tab === 'library' || tab === 'deliveryPrice' || tab === 'skuMappings') next.set('view', tab); + if (tab === 'library' || tab === 'skuMappings') next.set('view', tab); else next.delete('view'); setSearchParams(next, { replace: true }); }; @@ -361,17 +365,11 @@ export const QuoteVersionManagement: React.FC = () => { /** 「同步商品字典」在途(D4 推字典 + D5 拉映射) */ const [syncingDictionary, setSyncingDictionary] = useState(false); const [viewFilter, setViewFilter] = useState<'active' | 'history'>('active'); - type QuoteChromeTab = 'active' | 'history' | 'library' | 'deliveryPrice' | 'skuMappings'; + type QuoteChromeTab = 'active' | 'history' | 'library' | 'skuMappings'; const chromeTab: QuoteChromeTab = - pageTab === 'library' - ? 'library' - : pageTab === 'deliveryPrice' - ? 'deliveryPrice' - : pageTab === 'skuMappings' - ? 'skuMappings' - : viewFilter; + pageTab === 'library' ? 'library' : pageTab === 'skuMappings' ? 'skuMappings' : viewFilter; const setChromeTab = (tab: QuoteChromeTab) => { - if (tab === 'library' || tab === 'deliveryPrice' || tab === 'skuMappings') { + if (tab === 'library' || tab === 'skuMappings') { setPageTab(tab); return; } @@ -513,7 +511,7 @@ export const QuoteVersionManagement: React.FC = () => { // 无报价单编辑权的人看不到「配送商销售价确认 / 商品映射」页签:手输 URL 进来也退回当前执行(后端另有 403 兜底) useEffect(() => { const view = searchParams.get('view'); - if ((view !== 'deliveryPrice' && view !== 'skuMappings') || canManageQuotes) return; + if (view !== 'skuMappings' || canManageQuotes) return; const next = new URLSearchParams(searchParams); next.delete('view'); setSearchParams(next, { replace: true }); @@ -853,7 +851,7 @@ export const QuoteVersionManagement: React.FC = () => { } await submitQuotePriceProposalApi(row.quote_sheet_code); notify.success(t('quotes.toast.submittedForDeliveryReview')); - setPageTab('deliveryPrice'); + navigate('/customers/supply-review'); } catch (error: any) { notify.error(error?.message || t('quotes.toast.submitForDeliveryFail')); } finally { @@ -1060,7 +1058,7 @@ export const QuoteVersionManagement: React.FC = () => { { id: 'history', label: t('quotes.tab.history') }, { id: 'library', label: t('quotes.tab.library'), hidden: !canManageCustomerLibrary }, // 配送商销售价确认:供应商眼中的「销售价」= 配送商眼中的「成本价」;通过/驳回在面板内按 customer_manage 再收一次 - { id: 'deliveryPrice', label: t('quotes.tab.deliveryPrice'), hidden: !canManageQuotes }, + { id: 'skuMappings', label: t('quotes.tab.skuMappings'), hidden: !canManageQuotes }, ]} /> @@ -1068,7 +1066,7 @@ export const QuoteVersionManagement: React.FC = () => { {pageTab === 'sheets' && viewFilter === 'history' ? ( {t('quotes.history.hint')} ) : null} - {pageTab !== 'deliveryPrice' && pageTab !== 'skuMappings' ? ( + {pageTab !== 'skuMappings' ? ( { {pageTab === 'skuMappings' ? ( - ) : pageTab === 'deliveryPrice' ? ( - { - void loadSheets(); - }} - /> ) : pageTab === 'library' && canManageCustomerLibrary ? ( customerFilter ? ( diff --git a/src/pages/customers/SupplyReview.tsx b/src/pages/customers/SupplyReview.tsx new file mode 100644 index 0000000..ce02665 --- /dev/null +++ b/src/pages/customers/SupplyReview.tsx @@ -0,0 +1,56 @@ +import React, { useState } from 'react'; +import { useAuth } from '../../hooks/useAuth'; +import { useOperatingBranch } from '../../hooks/useOperatingBranch'; +import { useT } from '../../i18n'; +import { QuoteDeliveryPriceProposalsPanel } from './QuoteDeliveryPriceProposalsPanel'; + +/** + * 供需变更审核(2026-10-19 用户要求:把涉及审核的供需变更收到一个界面)。 + * + * 页内两个 Tab: + * · 待我审核:配送商提交的成本价变更(我方销售价) + * · 我提出的:我方提交给配送商的报价单变更(等对方审) + * + * 原来是「报价管理」里的「配送商销售价确认」页签,现合并到此,报价管理只保留报价单本身。 + */ +export const SupplyReview: React.FC = () => { + const t = useT(); + const { hasPermission } = useAuth(); + const { operatingBranchCode } = useOperatingBranch(); + const [tab, setTab] = useState<'inbound' | 'outbound'>('inbound'); + const canApprove = hasPermission('customer_manage'); + + const tabClass = (active: boolean) => + `rounded-lg px-3 py-1.5 text-sm ${ + active + ? 'bg-emerald-600 text-white' + : 'border border-gray-300 text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700' + }`; + + return ( +
+
+
+

+ {t('supplyReview.title')} +

+

{t('supplyReview.hint')}

+
+
+ + +
+
+ + {tab === 'inbound' ? ( + + ) : ( + + )} +
+ ); +}; diff --git a/src/utils/menuLayout.newMenu.test.ts b/src/utils/menuLayout.newMenu.test.ts index 3e1cb3d..caac7dc 100644 --- a/src/utils/menuLayout.newMenu.test.ts +++ b/src/utils/menuLayout.newMenu.test.ts @@ -194,6 +194,7 @@ const LEGACY_ELEVEN_TOP_LEVEL = { { menuKey: 'products-skus', visible: true }, { menuKey: 'products-categories', visible: true }, { menuKey: 'customers-quote-versions', label: '报价管理', visible: true }, + { menuKey: 'customers-supply-review', label: '供需变更审核', visible: true }, { menuKey: 'suppliers-list', visible: true }, { menuKey: 'orders-bids', visible: false }, { menuKey: 'inventory', label: '仓库管理', visible: true }, diff --git a/src/utils/menuLayout.ts b/src/utils/menuLayout.ts index 6b3c78f..da44b7a 100644 --- a/src/utils/menuLayout.ts +++ b/src/utils/menuLayout.ts @@ -66,6 +66,7 @@ const MASTER_DATA_CANONICAL_ITEMS: NavSecondaryItemConfig[] = [ { menuKey: 'products-skus', visible: true }, { menuKey: 'products-categories', visible: true }, { menuKey: 'customers-quote-versions', label: '报价管理', visible: true }, + { menuKey: 'customers-supply-review', label: '供需变更审核', visible: true }, { menuKey: 'suppliers-list', visible: true }, { menuKey: 'inventory', label: '仓库管理', visible: true }, { menuKey: 'product-trace', visible: true },