feat(功能收窄): 隐藏「市场价格监控」—— 供应商系统不需要该功能
开发者指令(原话):「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能。」
只删菜单项不够(直接敲 URL 仍能打开),四处一起摘:
① src/config/menuCatalog.ts:删除 market-monitor 条目
—— 运行时菜单树只渲染目录里有的 key ⇒ **老布局(库里存过该项)也不会再显示**
② src/utils/menuLayout.ts:从「基础数据」规范条目删除
—— 否则归位逻辑会把它塞回分组(规范条目是权威顺序表)
③ src/modules/businessModules.ts:删除 ops 模块的 route 与 menuKeys ⇒ /market-monitor 不再可达
④ src/utils/authRouting.ts:删除「只有 market_monitor 权限 ⇒ 落 /market-monitor」兜底
—— 否则这类账号登录后被送到已隐藏的页面
有意保留(避免动到权限体系与将来恢复成本):
· 权限码 market_monitor(permissionCatalog / permissionLabels / 角色目录 / 后端都在用)
· 页面文件 MarketMonitor.tsx 与 AI 副驾合同(不删代码,恢复只需把①②③④加回去)
· i18n 三语文案(无入口即不可见)
未动(开发者未要求,需单独裁决):后台「市场监控每日刷新」调度(每日 03:00,调外部行情接口)
与后端只读行情接口 —— 本轮只隐藏界面。
验证:新增 src/utils/hiddenFeatures.marketMonitor.test.ts 5 例(逐条钉 ①②③④ + 老布局不显示 +
同组其它菜单项不受影响);前端全量 722 用例(新增 5),失败仅另一条工作线遗留的
SystemConfig.allowZeroCost 2 条;tsc 通过;门禁同基线。
设计:docs/design/20261027-隐藏市场价格监控功能.md
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# 隐藏「市场价格监控」(2026-10-10 定稿)
|
||||
|
||||
> 开发者当轮指令(原话):「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能。」
|
||||
|
||||
## 1. 为什么不能只删菜单项
|
||||
|
||||
侧边栏的数据源是「**菜单目录**(`MENU_CATALOG`)+ 按分公司存库的布局」两层:
|
||||
只改布局/只改文案,用户直接敲 URL 仍能打开页面;而只删菜单项不删路由,
|
||||
`businessModules` 里那条路由依旧可达。所以四处一起摘:
|
||||
|
||||
| # | 落点 | 改动 | 不改会怎样 |
|
||||
|---|---|---|---|
|
||||
| ① | `src/config/menuCatalog.ts` | 删除 `market-monitor` 条目 | 侧边栏(含**老布局**)仍会显示 —— 运行时树只渲染目录里有的 key |
|
||||
| ② | `src/utils/menuLayout.ts` | 从「基础数据」规范条目里删除 | 归位逻辑会把它**塞回**分组(规范条目是权威顺序表) |
|
||||
| ③ | `src/modules/businessModules.ts` | 删除 `ops` 模块的该 `route` 与 `menuKeys` | 直接访问 `/market-monitor` 仍能打开页面 |
|
||||
| ④ | `src/utils/authRouting.ts` | 删除「只有 `market_monitor` 权限 ⇒ 落 `/market-monitor`」兜底 | 这类账号登录后被送到**已隐藏**的页面 |
|
||||
|
||||
## 2. 有意保留的东西
|
||||
|
||||
- **权限码 `market_monitor` 保留**(`permissionCatalog` / `permissionLabels` / 角色目录、后端权限判定都在用;
|
||||
删掉它会牵动角色同步与既有角色映射)—— 它现在只是"没有任何入口会用到";
|
||||
- **页面文件 `src/pages/ai/MarketMonitor.tsx` 与 AI 副驾合同保留**:不删代码,将来要恢复只需把 ①②③④ 加回去;
|
||||
- **i18n 文案保留**(`menu.ts` 的 `market-monitor` 三语)—— 无入口即不可见,删了反而让恢复变麻烦。
|
||||
|
||||
## 3. 未动的部分(开发者未要求)
|
||||
|
||||
- **后台「市场监控每日刷新」调度仍在跑**(`scheduledJobs`,每日 03:00,会调用外部行情接口)。
|
||||
本轮只隐藏界面;若要连数据采集一起停,需要单独裁决(涉及外部 API 调用与历史行情数据)。
|
||||
- 后端行情接口仍在(只读),不影响任何既有数据。
|
||||
|
||||
## 4. 验收
|
||||
|
||||
- 侧边栏:`基础数据` 分组里不再有「市场价格监控」;
|
||||
- 老布局(库里存过该项)加载后也不显示 —— 运行时树对**目录里没有的 key** 直接跳过;
|
||||
- 直接访问 `/market-monitor` ⇒ 不再匹配任何业务路由;
|
||||
- 回归:`src/utils/hiddenFeatures.marketMonitor.test.ts`(5 例)逐条钉住 ①②③④ + 老布局不显示;
|
||||
前端全量 722 用例(新增 5)。
|
||||
@@ -43,6 +43,7 @@ AI 提示词清理已停用条目(7 条归档不删、清单过滤 archived、
|
||||
跨系统改价/改量:请求 → 主系统管理员审核 → 结果回传(免审例外=补价/改低/减量;主系统侧**新开**流程、复用改数据模块;我方侧已实现台账/写路径守卫/回写门禁/申请页,总开关默认关;含**主系统客户端模块化与域名端点统一管理**)见 [20261011-跨系统改价改量审核.md](./20261011-跨系统改价改量审核.md)。
|
||||
分公司「接入编码」与主系统供应商绑定(我方每家分公司一个唯一编码;主系统在其**唯一授权登记表** `supplier_integration_client_suppliers` 上按 **`(分公司 + 供应商)`** 绑该编码;**货按编码流转、未绑即收不到**;一码可被 A/B/C 多行绑定;登录改**我方本地账号**、与手机号彻底解耦;**已实现并真库实测**,主系统侧 5 项 P0 待回执)见 [20261027-分公司接入编码与主系统供应商绑定.md](./20261027-分公司接入编码与主系统供应商绑定.md)。
|
||||
导航菜单按**主系统当前布局**收敛(顶层只留 数据看板/订单录入 + 业务流程/基础数据/财务结算/系统管理;老布局**每次加载自动归位**、幂等、不写一次性 SQL ⇒ 迁移换机都一样;缓存指纹加模板版本;含「财务管理→财务结算」这一处显示名收敛)见 [20261027-导航菜单按主系统模板收敛.md](./20261027-导航菜单按主系统模板收敛.md)。
|
||||
隐藏「市场价格监控」界面(本产品不需要:①菜单目录 ②基础数据规范条目 ③模块路由 ④落地路径兜底 四处同删;权限码/页面代码/i18n **有意保留**;后台每日行情刷新**未动**)见 [20261027-隐藏市场价格监控功能.md](./20261027-隐藏市场价格监控功能.md)。
|
||||
|
||||
## 全量对齐与改造方案(2026-09-28)
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ export const MENU_CATALOG: MenuCatalogEntry[] = [
|
||||
{ menuKey: 'after-sales', path: '/after-sales', defaultLabel: '售后管理', icon: 'Package', permission: 'aftersales_manage' },
|
||||
{ menuKey: 'exceptions', path: '/exceptions', defaultLabel: '异常管理', icon: 'AlertTriangle', permission: 'exception_manage' },
|
||||
{ menuKey: 'picking', path: '/picking', defaultLabel: '分拣出库', icon: 'ClipboardCheck', permission: 'picking_manage' },
|
||||
{ menuKey: 'market-monitor', path: '/market-monitor', defaultLabel: '市场价格监控', icon: 'TrendingUp', permission: 'market_monitor', secondary: true },
|
||||
{ menuKey: 'system-config', path: '/system/config', defaultLabel: '系统配置', icon: 'ChevronRight', permission: 'system_manage', roles: ['super_admin', 'admin'], secondary: true },
|
||||
{ menuKey: 'system-ai-models', path: '/system/ai-models', defaultLabel: 'AI 模型', icon: 'ChevronRight', permission: 'system_manage', roles: ['super_admin'], secondary: true },
|
||||
{ menuKey: 'system-ai-prompts', path: '/system/ai-prompts', defaultLabel: 'AI 提示词', icon: 'ChevronRight', permission: 'system_manage', roles: ['super_admin'], secondary: true },
|
||||
|
||||
@@ -231,17 +231,11 @@ export const BUSINESS_MODULES: BusinessModuleDef[] = [
|
||||
{
|
||||
id: 'ops',
|
||||
name: '运营',
|
||||
permissions: ['aftersales_manage', 'exception_manage', 'market_monitor'],
|
||||
menuKeys: ['after-sales', 'exceptions', 'market-monitor'],
|
||||
permissions: ['aftersales_manage', 'exception_manage'],
|
||||
menuKeys: ['after-sales', 'exceptions'],
|
||||
routes: [
|
||||
{ path: 'after-sales', page: 'AfterSalesManagement', permission: 'aftersales_manage' },
|
||||
{ path: 'exceptions', page: 'ExceptionManagement', permission: 'exception_manage' },
|
||||
{
|
||||
path: 'market-monitor',
|
||||
page: 'MarketMonitor',
|
||||
permission: 'market_monitor',
|
||||
tabChildren: ['', 'index', 'trend', 'recommend'],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
+53
-54
@@ -1,54 +1,53 @@
|
||||
import type { UserRole } from '../hooks/useAuth';
|
||||
|
||||
type HasRole = (role: UserRole | UserRole[]) => boolean;
|
||||
type HasPermission = (permission: string | string[]) => boolean;
|
||||
|
||||
interface ProfileAccess {
|
||||
roles: UserRole[];
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export function createAccessCheckers(profile: ProfileAccess) {
|
||||
const hasRole: HasRole = (role) => {
|
||||
if (Array.isArray(role)) return role.some((r) => profile.roles.includes(r));
|
||||
return profile.roles.includes(role);
|
||||
};
|
||||
|
||||
const hasPermission: HasPermission = (permission) => {
|
||||
if (Array.isArray(permission)) {
|
||||
return permission.some((p) => profile.permissions.includes(p));
|
||||
}
|
||||
return profile.permissions.includes(permission);
|
||||
};
|
||||
|
||||
return { hasRole, hasPermission };
|
||||
}
|
||||
|
||||
export function getDefaultHomePath(hasRole: HasRole, hasPermission: HasPermission): string {
|
||||
// 与后端统一登录入口 accountLoginService.resolveWebHomePath 保持一致:
|
||||
// 超管落地「系统设置」,而非数据看板 —— /dashboard 的路由守卫只放行 admin(roles: ['admin']),
|
||||
// 超管的 roles 只有 'super_admin'(不会被补成 admin),落过去会命中 App.tsx 的
|
||||
// 「无权限 → 跳回默认首页」而自环。超管现有权限为 system_manage / branch_manage / data_import_export。
|
||||
if (hasRole('super_admin')) return '/system/config';
|
||||
if (hasRole('admin')) return '/dashboard';
|
||||
if (hasRole('purchaser')) return '/purchaser/dashboard';
|
||||
if (hasPermission('order_entry')) return '/customer-order';
|
||||
if (hasPermission('order_manage')) return '/orders';
|
||||
if (hasPermission('customer_manage')) return '/customers';
|
||||
if (hasPermission('supplier_manage')) return '/suppliers';
|
||||
if (hasPermission('preparation_manage')) return '/purchase/preparations';
|
||||
if (hasPermission('purchase_manage')) return '/purchase';
|
||||
if (hasPermission('picking_manage')) return '/picking';
|
||||
if (hasPermission('inventory_manage')) return '/inventory';
|
||||
if (hasPermission('delivery_manage')) return '/delivery';
|
||||
if (hasPermission('finance_manage')) return '/finance';
|
||||
if (hasPermission('inspection_manage')) return '/inspection';
|
||||
if (hasPermission('processing_manage')) return '/inspection/processing';
|
||||
if (hasPermission('market_monitor')) return '/market-monitor';
|
||||
if (hasPermission(['system_manage', 'user_manage', 'role_manage', 'log_view'])) return '/system/config';
|
||||
// 兜底必须是「不需要任何权限就能进」的页面。
|
||||
// 原为 '/customer-order',但该路由守卫要求 order_entry,
|
||||
// 无角色/无权限的账号落过去会被 App.tsx「无权限 → 回默认首页」打回这里 → 自环。
|
||||
// 见 src/pages/auth/NoAccess.tsx 顶部说明。
|
||||
return '/no-access';
|
||||
}
|
||||
import type { UserRole } from '../hooks/useAuth';
|
||||
|
||||
type HasRole = (role: UserRole | UserRole[]) => boolean;
|
||||
type HasPermission = (permission: string | string[]) => boolean;
|
||||
|
||||
interface ProfileAccess {
|
||||
roles: UserRole[];
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export function createAccessCheckers(profile: ProfileAccess) {
|
||||
const hasRole: HasRole = (role) => {
|
||||
if (Array.isArray(role)) return role.some((r) => profile.roles.includes(r));
|
||||
return profile.roles.includes(role);
|
||||
};
|
||||
|
||||
const hasPermission: HasPermission = (permission) => {
|
||||
if (Array.isArray(permission)) {
|
||||
return permission.some((p) => profile.permissions.includes(p));
|
||||
}
|
||||
return profile.permissions.includes(permission);
|
||||
};
|
||||
|
||||
return { hasRole, hasPermission };
|
||||
}
|
||||
|
||||
export function getDefaultHomePath(hasRole: HasRole, hasPermission: HasPermission): string {
|
||||
// 与后端统一登录入口 accountLoginService.resolveWebHomePath 保持一致:
|
||||
// 超管落地「系统设置」,而非数据看板 —— /dashboard 的路由守卫只放行 admin(roles: ['admin']),
|
||||
// 超管的 roles 只有 'super_admin'(不会被补成 admin),落过去会命中 App.tsx 的
|
||||
// 「无权限 → 跳回默认首页」而自环。超管现有权限为 system_manage / branch_manage / data_import_export。
|
||||
if (hasRole('super_admin')) return '/system/config';
|
||||
if (hasRole('admin')) return '/dashboard';
|
||||
if (hasRole('purchaser')) return '/purchaser/dashboard';
|
||||
if (hasPermission('order_entry')) return '/customer-order';
|
||||
if (hasPermission('order_manage')) return '/orders';
|
||||
if (hasPermission('customer_manage')) return '/customers';
|
||||
if (hasPermission('supplier_manage')) return '/suppliers';
|
||||
if (hasPermission('preparation_manage')) return '/purchase/preparations';
|
||||
if (hasPermission('purchase_manage')) return '/purchase';
|
||||
if (hasPermission('picking_manage')) return '/picking';
|
||||
if (hasPermission('inventory_manage')) return '/inventory';
|
||||
if (hasPermission('delivery_manage')) return '/delivery';
|
||||
if (hasPermission('finance_manage')) return '/finance';
|
||||
if (hasPermission('inspection_manage')) return '/inspection';
|
||||
if (hasPermission('processing_manage')) return '/inspection/processing';
|
||||
if (hasPermission(['system_manage', 'user_manage', 'role_manage', 'log_view'])) return '/system/config';
|
||||
// 兜底必须是「不需要任何权限就能进」的页面。
|
||||
// 原为 '/customer-order',但该路由守卫要求 order_entry,
|
||||
// 无角色/无权限的账号落过去会被 App.tsx「无权限 → 回默认首页」打回这里 → 自环。
|
||||
// 见 src/pages/auth/NoAccess.tsx 顶部说明。
|
||||
return '/no-access';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { MENU_CATALOG } from '../config/menuCatalog';
|
||||
import { buildRuntimeMenuTree, mergeNavMenuLayout } from './menuLayout';
|
||||
|
||||
/**
|
||||
* 本产品的**功能收窄**:隐藏「市场价格监控」(开发者 2026-10-10:
|
||||
* 「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能」)。
|
||||
*
|
||||
* 四处一起摘才算真隐藏(只删菜单项的话,直接敲 URL 仍能打开):
|
||||
* ① 菜单目录 `MENU_CATALOG`(运行时菜单树的唯一数据源);
|
||||
* ② 基础数据分组的规范条目(否则归位逻辑会把它塞回分组);
|
||||
* ③ 模块注册表 `businessModules` 的 **route** 与 `menuKeys`(URL 不再可达);
|
||||
* ④ 落地路径兜底(否则"只有 market_monitor 权限"的账号会被送到已隐藏的页面)。
|
||||
*
|
||||
* ⚠️ 权限码 `market_monitor` **保留**(角色/权限目录与后端仍在用,删了会动到角色同步);
|
||||
* 页面文件与 AI 副驾合同也保留(将来要恢复只需把 ①②③④ 加回去)。
|
||||
*/
|
||||
describe('市场价格监控已在本产品隐藏', () => {
|
||||
const catalog = readFileSync(new URL('../config/menuCatalog.ts', import.meta.url), 'utf8');
|
||||
const layout = readFileSync(new URL('./menuLayout.ts', import.meta.url), 'utf8');
|
||||
const modules = readFileSync(new URL('../modules/businessModules.ts', import.meta.url), 'utf8');
|
||||
const routing = readFileSync(new URL('./authRouting.ts', import.meta.url), 'utf8');
|
||||
|
||||
it('① 菜单目录里没有它', () => {
|
||||
expect(MENU_CATALOG.some((entry) => entry.menuKey === 'market-monitor')).toBe(false);
|
||||
expect(catalog).not.toContain("menuKey: 'market-monitor'");
|
||||
});
|
||||
|
||||
it('② 基础数据规范条目里没有它(不会被归位逻辑塞回分组)', () => {
|
||||
expect(layout).not.toContain("menuKey: 'market-monitor'");
|
||||
});
|
||||
|
||||
it('③ 模块注册表没有它的路由与 menuKey', () => {
|
||||
expect(modules).not.toContain("'market-monitor'");
|
||||
expect(modules).not.toContain('MarketMonitor');
|
||||
});
|
||||
|
||||
it('④ 落地路径兜底不再指向它', () => {
|
||||
expect(routing).not.toContain("hasPermission('market_monitor')");
|
||||
});
|
||||
|
||||
it('老布局(库里存过该项)加载后侧边栏也不显示它', () => {
|
||||
const saved = {
|
||||
version: 1,
|
||||
order: [
|
||||
{ kind: 'standalone', menuKey: 'dashboard' },
|
||||
{ kind: 'group', groupId: 'grp-master-data' },
|
||||
],
|
||||
standalone: [{ menuKey: 'dashboard', visible: true }],
|
||||
groups: [
|
||||
{
|
||||
id: 'grp-master-data',
|
||||
label: '基础数据',
|
||||
icon: 'Store',
|
||||
visible: true,
|
||||
items: [
|
||||
{ menuKey: 'customers-list', visible: true },
|
||||
{ menuKey: 'market-monitor', label: '市场价格监控', visible: true },
|
||||
{ menuKey: 'products-units', visible: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const tree = buildRuntimeMenuTree(mergeNavMenuLayout(saved));
|
||||
const flat = JSON.stringify(tree);
|
||||
expect(flat).not.toContain('市场价格监控');
|
||||
expect(flat).not.toContain('/market-monitor');
|
||||
// 同组的其它菜单项不受影响
|
||||
expect(flat).toContain('/customers');
|
||||
});
|
||||
});
|
||||
@@ -69,7 +69,6 @@ const MASTER_DATA_CANONICAL_ITEMS: NavSecondaryItemConfig[] = [
|
||||
{ menuKey: 'suppliers-list', visible: true },
|
||||
{ menuKey: 'orders-bids', visible: false },
|
||||
{ menuKey: 'inventory', label: '仓库管理', visible: true },
|
||||
{ menuKey: 'market-monitor', label: '市场价格监控', visible: true },
|
||||
{ menuKey: 'product-trace', visible: true },
|
||||
{ menuKey: 'quality-reports', visible: true },
|
||||
{ menuKey: 'products-units', visible: true },
|
||||
|
||||
Reference in New Issue
Block a user