Files
SupplierSystem/server/src/modules/businessModules.ts
T
雨天 482c7c1e89
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
feat(小程序): 新增仓库管理内嵌面板与授权
首页 Tab 内嵌仓库管理面板:批次/可用/成本价/报告/入库时间

默认仅看可用,顶部统计库存批次、可用总量、可用货值

批量上传按 Web 流程:上传→识别→候选→人工确认,编辑可直传

新增权限码 warehouse_manage,默认赋予仓管,不映射 Web 菜单

6 条移动端薄路由,全部复用 Web 同一批 service

修复首页未转发 onReachBottom 导致内嵌列表只有第 1 页

修复录单员获授权后点仓库管理回弹(漏传 permissions)
2026-10-25 13:47:33 +08:00

222 lines
9.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { BusinessModuleDescriptor } from './types';
import type { Router } from 'express';
import { advanceFromAllocation } from './handlers/orderAllocationHandler';
import { advanceFromPreparation } from './handlers/preparationHandler';
import { advanceFromInspection } from './handlers/inspectionHandler';
import { advanceFromPicking } from './handlers/pickingHandler';
import {
advanceFromDelivering,
advanceFromPendingDelivery,
} from './handlers/deliveryFinanceHandlers';
import { mountPickingWorkflowRoutes } from './workflow/routes/pickingRoutes';
import { mountNotificationWorkflowRoutes } from './workflow/routes/notificationRoutes';
import { mountInspectionWorkflowRoutes } from './workflow/routes/inspectionRoutes';
import { mountOrderWorkflowRoutes } from './workflow/routes/orderRoutes';
import { mountBidWorkflowRoutes } from './workflow/routes/bidRoutes';
import { mountMainSystemBidWorkflowRoutes } from './workflow/routes/mainSystemBidRoutes';
import { mountPurchaseWorkflowRoutes } from './workflow/routes/purchaseRoutes';
import { mountPreparationWorkflowRoutes } from './workflow/routes/preparationRoutes';
import { mountFinanceWorkflowRoutes } from './workflow/routes/financeRoutes';
import { mountDeliveryWorkflowRoutes } from './workflow/routes/deliveryRoutes';
import { mountQuoteWorkflowRoutes } from './workflow/routes/quoteRoutes';
import { mountCustomerWorkflowRoutes } from './workflow/routes/customerRoutes';
import { mountMarketWorkflowRoutes } from './workflow/routes/marketRoutes';
import { mountSupplierWorkflowRoutes } from './workflow/routes/supplierRoutes';
import { mountPlatformConfigWorkflowRoutes } from './workflow/routes/platformRoutes';
import { mountTraceWorkflowRoutes } from './workflow/routes/traceRoutes';
import { mountInventoryWorkflowRoutes } from './workflow/routes/inventoryRoutes';
import { mountImportMappingWorkflowRoutes } from './workflow/routes/importMappingRoutes';
import { mountUnitWorkflowRoutes } from './workflow/routes/unitRoutes';
import { mountSkuDirectDeliveryWorkflowRoutes } from './workflow/routes/skuDirectDeliveryRoutes';
import { mountSkuPreferredSupplierWorkflowRoutes } from './workflow/routes/skuPreferredSupplierRoutes';
import { mountUiPreferenceWorkflowRoutes } from './workflow/routes/uiPreferenceRoutes';
import { mountNavBadgeWorkflowRoutes } from './workflow/routes/navBadgeRoutes';
function mountPlatformWorkflowRoutes(router: Router): void {
mountNotificationWorkflowRoutes(router);
mountPlatformConfigWorkflowRoutes(router);
mountImportMappingWorkflowRoutes(router);
mountUiPreferenceWorkflowRoutes(router);
mountNavBadgeWorkflowRoutes(router);
}
export const orderModule: BusinessModuleDescriptor = {
id: 'order',
name: '订单与分配',
description: '下单、订单列表、智能分配与状态推进',
permissions: ['order_manage', 'order_edit', 'order_entry', 'allocation_manage', 'bid_manage'],
orderStatuses: [20],
workflowApiPrefix: '/orders',
services: ['orderWorkflowService', 'orderAllocationService', 'customerOrderSubmitService'],
workflowTransitions: { 20: advanceFromAllocation },
mountWorkflowRoutes: (router) => {
mountOrderWorkflowRoutes(router);
// 本地竞价管理(已停用并摘除菜单,代码保留)
mountBidWorkflowRoutes(router);
// 主系统竞价「待报价」:我方只报价、不定标(2026-10-17)
mountMainSystemBidWorkflowRoutes(router);
},
};
export const purchaseModule: BusinessModuleDescriptor = {
id: 'purchase',
name: '采购与备货',
permissions: ['purchase_manage', 'preparation_manage'],
orderStatuses: [30],
workflowApiPrefix: '/purchase',
mobileApiPrefix: '/mobile/purchase',
services: ['preparationFulfillmentService', 'purchaseInboundService'],
workflowTransitions: { 30: advanceFromPreparation },
mountWorkflowRoutes: (router) => {
mountPreparationWorkflowRoutes(router);
mountPurchaseWorkflowRoutes(router);
},
};
export const inspectionModule: BusinessModuleDescriptor = {
id: 'inspection',
// 模块名以前端 src/modules/businessModules.ts 为准(该模块前端名即「验收与加工」)
name: '验收与加工',
permissions: ['inspection_manage', 'processing_manage'],
orderStatuses: [40],
workflowApiPrefix: '/inspection',
mobileApiPrefix: '/mobile/inspection',
services: ['inspectionComplianceService', 'processingTaskService'],
workflowTransitions: { 40: advanceFromInspection },
mountWorkflowRoutes: mountInspectionWorkflowRoutes,
};
export const pickingModule: BusinessModuleDescriptor = {
id: 'picking',
name: '分拣出库',
permissions: ['picking_manage', 'picking_barcode', 'picking_scale'],
orderStatuses: [45],
workflowApiPrefix: '/picking',
mobileApiPrefix: '/mobile/picking',
services: ['pickingService', 'pickingBarcodeService'],
workflowTransitions: { 45: advanceFromPicking },
mountWorkflowRoutes: mountPickingWorkflowRoutes,
};
export const deliveryModule: BusinessModuleDescriptor = {
id: 'delivery',
name: '配送',
permissions: ['delivery_manage', 'delivery_sign_photo', 'delivery_loading_photo', 'delivery_loading_qty_edit'],
orderStatuses: [50, 60],
workflowApiPrefix: '/delivery',
mobileApiPrefix: '/mobile/delivery',
services: ['deliveryRoutingService', 'deliveryLoadingService', 'deliveryPhotoService'],
workflowTransitions: {
50: advanceFromPendingDelivery,
60: advanceFromDelivering,
},
mountWorkflowRoutes: mountDeliveryWorkflowRoutes,
};
export const financeModule: BusinessModuleDescriptor = {
id: 'finance',
name: '财务',
description: '成本入账、结算单、发票与经营分析(与订单履约状态解耦)',
permissions: ['finance_manage', 'cost_manage', 'statement_manage', 'invoice_manage'],
workflowApiPrefix: '/finance',
services: [
'financeReconciliationService',
'costAllocationService',
'freeCostService',
'fixedCostTypeService',
'costDisplayNameService',
'orderCostPostingService',
],
mountWorkflowRoutes: mountFinanceWorkflowRoutes,
};
export const productModule: BusinessModuleDescriptor = {
id: 'product',
name: '商品主数据',
permissions: ['category_manage', 'sku_manage', 'alias_manage', 'product_manage'],
services: ['categoryCatalogService', 'quoteSheetService', 'unitDictionaryService'],
mountWorkflowRoutes: (router: Router) => {
mountQuoteWorkflowRoutes(router);
mountMarketWorkflowRoutes(router);
mountUnitWorkflowRoutes(router);
mountSkuDirectDeliveryWorkflowRoutes(router);
mountSkuPreferredSupplierWorkflowRoutes(router);
},
};
export const customerModule: BusinessModuleDescriptor = {
id: 'customer',
name: '客户管理',
permissions: ['customer_manage'],
services: ['customerBudgetService', 'quoteSheetService'],
mountWorkflowRoutes: mountCustomerWorkflowRoutes,
};
export const supplierModule: BusinessModuleDescriptor = {
id: 'supplier',
name: '供应商',
permissions: ['supplier_manage', 'supplier_supply_manage'],
services: ['supplierRatingService'],
mountWorkflowRoutes: mountSupplierWorkflowRoutes,
};
export const inventoryModule: BusinessModuleDescriptor = {
id: 'inventory',
name: '库存',
// warehouse_manage = 小程序「仓库管理」入口(不映射 Web 菜单,2026-10-23)
permissions: ['inventory_manage', 'warehouse_manage'],
// 本模块同时挂载 /inventory/* 与 /trace/*(商品溯源在前端也归属 inventory 模块的 menuKeys),
// 但主前缀应为本模块的主路由 /inventory —— 原值 '/trace' 是溯源路由,属填错。
workflowApiPrefix: '/inventory',
services: ['inboundGapRepairService', 'productTraceService', 'inventoryStockCoverService'],
mountWorkflowRoutes: (router: Router) => {
mountTraceWorkflowRoutes(router);
mountInventoryWorkflowRoutes(router);
},
};
/** 运营(售后 / 异常 / 市场行情):此前只存在于前端,后端注册表缺失 */
export const opsModule: BusinessModuleDescriptor = {
id: 'ops',
name: '运营',
description: '售后工单、异常工单、市场行情监控',
permissions: ['aftersales_manage', 'exception_manage', 'market_monitor'],
services: ['afterSaleLifecycleService', 'exceptionPredictionService', 'marketIndexService'],
};
/** 数据看板:此前只存在于前端,后端注册表缺失(无独立权限码,前端按角色 admin/super_admin 放行) */
export const dashboardModule: BusinessModuleDescriptor = {
id: 'dashboard',
name: '数据看板',
description: '首页 KPI、趋势、待办与损耗分析',
services: ['dashboardService', 'dashboardLossAnalysis'],
};
export const platformModule: BusinessModuleDescriptor = {
id: 'platform',
// 模块名以前端 src/modules/businessModules.ts 为准(前端该模块名为「系统」;
// docs/modules 的文件名仍是描述性长名「12-平台与系统.md」,两者有意不同)
name: '系统',
permissions: ['system_manage', 'role_manage', 'user_manage', 'branch_manage'],
workflowApiPrefix: '/system',
services: ['permissionCatalogService', 'roleDefinitionService', 'tenantScope'],
mountWorkflowRoutes: mountPlatformWorkflowRoutes,
};
/** 顺序与 docs/modules/01..13 的编号一致 */
export const ALL_BUSINESS_MODULES: BusinessModuleDescriptor[] = [
orderModule,
purchaseModule,
inspectionModule,
pickingModule,
deliveryModule,
financeModule,
productModule,
customerModule,
supplierModule,
inventoryModule,
opsModule,
platformModule,
dashboardModule,
];