feat(审核): 供需变更审核合并为独立菜单页(待我审核 / 我提出的)
用户要求:把供应商与配送商的价格审核收拢到一个界面(用户选定:两个系统都加、合并成一页两 Tab)。 - 新增 /customers/supply-review(SupplyReview):Tab 待我审核 / 我提出的 - 面板新增 direction 过滤(from_delivery / to_delivery) - 报价管理移除「配送商销售价确认」页签;?view=deliveryPrice 自动跳新页 - 菜单注册 + 菜单布局默认项 + 契约测试同步
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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': '已过期、顺延归档或已被新报价替换',
|
||||
|
||||
|
||||
@@ -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' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -21,6 +21,7 @@ const PAGE_LOADERS: Record<string, ReturnType<typeof lazyPage>> = {
|
||||
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'),
|
||||
|
||||
@@ -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<QuoteDeliveryPriceProposalsPanelProps> = ({
|
||||
canApprove,
|
||||
direction = null,
|
||||
onApplied,
|
||||
}) => {
|
||||
const t = useT();
|
||||
const [rows, setRows] = useState<QuotePriceProposalDto[]>([]);
|
||||
const [allRows, setRows] = useState<QuotePriceProposalDto[]>([]);
|
||||
const rows = direction ? allRows.filter((row) => row.direction === direction) : allRows;
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [actingId, setActingId] = useState<string | null>(null);
|
||||
const [rejecting, setRejecting] = useState<{ id: string; reason: string } | null>(null);
|
||||
|
||||
@@ -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('<QuoteDeliveryPriceProposalsPanel');
|
||||
expect(page).toMatch(/canApprove=\{canManageCustomerLibrary\}/);
|
||||
it('「配送商成本价确认」已合并为独立菜单页「供需变更审核」,审批权按 customer_manage 收窄', () => {
|
||||
// 报价页不再有 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('<QuoteDeliveryPriceProposalsPanel');
|
||||
expect(review).toContain('direction="from_delivery"');
|
||||
expect(review).toContain('direction="to_delivery"');
|
||||
expect(review).toMatch(/hasPermission\('customer_manage'\)/);
|
||||
const catalog = readFileSync(new URL('../../config/menuCatalog.ts', import.meta.url), 'utf8');
|
||||
expect(catalog).toContain("menuKey: 'customers-supply-review'");
|
||||
expect(catalog).toContain('供需变更审核');
|
||||
});
|
||||
|
||||
it('无权限手输 URL 会退回当前执行(后端另有 403/503 兜底)', () => {
|
||||
expect(page).toMatch(
|
||||
/if \(\(view !== 'pending' && view !== 'deliveryPrice' && view !== 'skuMappings'\) \|\| canManageQuotes\) return;/
|
||||
);
|
||||
expect(page).toMatch(/if \(view !== 'skuMappings' \|\| canManageQuotes\) return;/);
|
||||
});
|
||||
|
||||
it('提交配送商审核失败时透出后端中文说明(如内部审核在途 409)', () => {
|
||||
|
||||
@@ -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' ? (
|
||||
<span className="text-xs text-gray-500">{t('quotes.history.hint')}</span>
|
||||
) : null}
|
||||
{pageTab !== 'deliveryPrice' && pageTab !== 'skuMappings' ? (
|
||||
{pageTab !== 'skuMappings' ? (
|
||||
<SearchableSelect
|
||||
value={customerFilter}
|
||||
onChange={setCustomerFilter}
|
||||
@@ -1124,13 +1122,6 @@ export const QuoteVersionManagement: React.FC = () => {
|
||||
|
||||
{pageTab === 'skuMappings' ? (
|
||||
<QuoteSkuMappingsPanel />
|
||||
) : pageTab === 'deliveryPrice' ? (
|
||||
<QuoteDeliveryPriceProposalsPanel
|
||||
canApprove={canManageCustomerLibrary}
|
||||
onApplied={() => {
|
||||
void loadSheets();
|
||||
}}
|
||||
/>
|
||||
) : pageTab === 'library' && canManageCustomerLibrary ? (
|
||||
customerFilter ? (
|
||||
<CustomerSkuLibraryPanel customerCode={customerFilter} customerName={libraryCustomerName} />
|
||||
|
||||
@@ -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 (
|
||||
<div className="space-y-3" data-branch={operatingBranchCode || ''}>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold text-gray-900 dark:text-gray-100">
|
||||
{t('supplyReview.title')}
|
||||
</h1>
|
||||
<p className="mt-1 text-xs text-gray-500">{t('supplyReview.hint')}</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button type="button" className={tabClass(tab === 'inbound')} onClick={() => setTab('inbound')}>
|
||||
{t('supplyReview.tab.inbound')}
|
||||
</button>
|
||||
<button type="button" className={tabClass(tab === 'outbound')} onClick={() => setTab('outbound')}>
|
||||
{t('supplyReview.tab.outbound')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{tab === 'inbound' ? (
|
||||
<QuoteDeliveryPriceProposalsPanel canApprove={canApprove} direction="from_delivery" />
|
||||
) : (
|
||||
<QuoteDeliveryPriceProposalsPanel canApprove={canApprove} direction="to_delivery" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -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 },
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user