feat(导航角标): 查询天数可配置(默认30天,仅分公司管理员)
- system_configs.nav_badge_days 1~365,分支级;超管固定30 - scope=days 默认,10 个 counter 统一滚动窗口;缓存 key 含 days - 系统配置页新增仅分公司管理员可见卡片 - 保留 today/month/all 与切页单菜单刷新
This commit is contained in:
@@ -2,7 +2,7 @@ import { Router, Response } from 'express';
|
||||
import { authMiddleware, type AuthRequest } from '../../../middleware/auth';
|
||||
import { readOperatingBranchCode } from '../../../services/tenantScope';
|
||||
import { runWithTenantDbContext } from '../../../services/tenantDbContext';
|
||||
import { getNavBadges, NAV_BADGE_COUNTERS, type NavBadgeScope } from '../../../services/navBadgeService';
|
||||
import { getNavBadgeDays, getNavBadges, NAV_BADGE_COUNTERS, type NavBadgeScope } from '../../../services/navBadgeService';
|
||||
import { getWorkflowCtx, sendWorkflowError } from '../context';
|
||||
|
||||
/**
|
||||
@@ -17,9 +17,9 @@ export function mountNavBadgeWorkflowRoutes(router: Router): void {
|
||||
if (tokenScope && tokenScope !== 'web') {
|
||||
return res.status(403).json({ error: 'forbidden', error_description: '仅 Web token 可访问' });
|
||||
}
|
||||
const rawScope = String(req.query?.scope || 'month').trim().toLowerCase();
|
||||
if (rawScope !== 'today' && rawScope !== 'month' && rawScope !== 'all') {
|
||||
return res.status(400).json({ error: 'invalid_scope', error_description: 'scope 只能是 today、month 或 all' });
|
||||
const rawScope = String(req.query?.scope || 'days').trim().toLowerCase();
|
||||
if (rawScope !== 'today' && rawScope !== 'month' && rawScope !== 'all' && rawScope !== 'days') {
|
||||
return res.status(400).json({ error: 'invalid_scope', error_description: 'scope 只能是 today、month、all 或 days' });
|
||||
}
|
||||
const scope = rawScope as NavBadgeScope;
|
||||
const rawMenus = req.query?.menus;
|
||||
@@ -49,6 +49,10 @@ export function mountNavBadgeWorkflowRoutes(router: Router): void {
|
||||
const generatedAt = new Date().toISOString();
|
||||
if (!enabled) return res.json({ data: {}, disabled: true, scope, generated_at: generatedAt });
|
||||
|
||||
// 在分公司租户上下文里读 public.system_configs,避免 RLS 看不到配置
|
||||
const days = ctx.isSuperAdmin
|
||||
? 30
|
||||
: await runWithTenantDbContext(branchCode, () => getNavBadgeDays(branchCode));
|
||||
const data = await runWithTenantDbContext(branchCode, () =>
|
||||
getNavBadges(
|
||||
{
|
||||
@@ -56,6 +60,7 @@ export function mountNavBadgeWorkflowRoutes(router: Router): void {
|
||||
branchCode,
|
||||
userId: ctx.userId,
|
||||
scope,
|
||||
days,
|
||||
},
|
||||
requestedMenus,
|
||||
refresh
|
||||
|
||||
@@ -18,13 +18,15 @@ import { purchaseOrderBranchWhereSql } from './purchaserBranchScope';
|
||||
* · 20 秒进程缓存(key = branch|user|scope),防止切页/轮询放大 DB;
|
||||
* · picking/delivery 管理员看分公司全部、作业角色只看本人。
|
||||
*/
|
||||
export type NavBadgeScope = 'today' | 'month' | 'all';
|
||||
export type NavBadgeScope = 'today' | 'month' | 'all' | 'days';
|
||||
|
||||
export type NavBadgeContext = {
|
||||
ctx: TenantContext;
|
||||
branchCode: string;
|
||||
userId: string;
|
||||
scope: NavBadgeScope;
|
||||
/** scope=days 时的滚动窗口天数(1~365,默认 30) */
|
||||
days?: number;
|
||||
};
|
||||
|
||||
type NavBadgeCounter = {
|
||||
@@ -34,6 +36,42 @@ type NavBadgeCounter = {
|
||||
count(input: NavBadgeContext): Promise<number>;
|
||||
};
|
||||
|
||||
export const DEFAULT_NAV_BADGE_DAYS = 30;
|
||||
|
||||
/** 导航待办角标滚动天数:只接受 1~365 整数,非法回退 30。 */
|
||||
export function normalizeNavBadgeDays(raw: unknown): number {
|
||||
const n = Number(raw);
|
||||
if (!Number.isInteger(n) || n < 1 || n > 365) return DEFAULT_NAV_BADGE_DAYS;
|
||||
return n;
|
||||
}
|
||||
|
||||
/** 读取分公司 `nav_badge_days`;未配置/非法=30。 */
|
||||
export async function getNavBadgeDays(branchCode: string): Promise<number> {
|
||||
const code = String(branchCode || '').trim();
|
||||
if (code) {
|
||||
const res = await pool.query<{ config_value: unknown }>(
|
||||
`SELECT config_value FROM public.system_configs
|
||||
WHERE config_key = 'nav_badge_days' AND branch_code = $1 LIMIT 1`,
|
||||
[code]
|
||||
);
|
||||
const parsed = parseNavBadgeConfigValue(res.rows[0]?.config_value);
|
||||
if (parsed != null) return parsed;
|
||||
}
|
||||
return DEFAULT_NAV_BADGE_DAYS;
|
||||
}
|
||||
|
||||
function parseNavBadgeConfigValue(raw: unknown): number | null {
|
||||
if (raw == null) return null;
|
||||
if (typeof raw === 'number' || typeof raw === 'string') return normalizeNavBadgeDays(raw);
|
||||
if (typeof raw === 'object') {
|
||||
const obj = raw as Record<string, unknown>;
|
||||
const value = obj.days ?? obj.value;
|
||||
if (value == null) return null;
|
||||
return normalizeNavBadgeDays(value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const LOCKED_AFTERSALE_TYPES = ['order_return', 'spi_void', 'inbound_switch'];
|
||||
/** 自然月(Asia/Shanghai)半开区间,供只读 COUNT 复用。 */
|
||||
function monthRangeSql(dateExpr: string): string {
|
||||
@@ -41,6 +79,21 @@ function monthRangeSql(dateExpr: string): string {
|
||||
AND (${dateExpr}) < (date_trunc('month', (NOW() AT TIME ZONE 'Asia/Shanghai')::date) + INTERVAL '1 month')::date`;
|
||||
}
|
||||
|
||||
/** 统一滚动窗口:业务日 >= 今天-(N-1),含今天;N 已 clamp 1~365。 */
|
||||
function rollingDaysRangeSql(dateExpr: string, days?: number): string {
|
||||
const n = Math.max(1, Math.min(365, Math.floor(Number(days) || 30)));
|
||||
return `(${dateExpr}) >= ((NOW() AT TIME ZONE 'Asia/Shanghai')::date - ${n - 1})
|
||||
AND (${dateExpr}) <= (NOW() AT TIME ZONE 'Asia/Shanghai')::date`;
|
||||
}
|
||||
|
||||
/** scope 统一日期阈值;all 返回空串。 */
|
||||
function scopedDateFilter(scope: NavBadgeScope, dateExpr: string, days?: number): string {
|
||||
if (scope === 'all') return '';
|
||||
if (scope === 'month') return monthRangeSql(dateExpr);
|
||||
if (scope === 'days') return rollingDaysRangeSql(dateExpr, days);
|
||||
return `(${dateExpr}) = (NOW() AT TIME ZONE 'Asia/Shanghai')::date`;
|
||||
}
|
||||
|
||||
const CACHE_TTL_MS = 20_000;
|
||||
const cache = new Map<string, { expiresAt: number; value: number }>();
|
||||
|
||||
@@ -60,7 +113,7 @@ function hasRole(ctx: TenantContext, roles: string[]): boolean {
|
||||
}
|
||||
|
||||
/** 管理员 = 分公司全部;picker = 本人;today 只看配送日=今天,pick_status < 30 */
|
||||
async function countPicking(ctx: TenantContext, branchCode: string, scope: NavBadgeScope): Promise<number> {
|
||||
async function countPicking(ctx: TenantContext, branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const pickerId = !isBranchAdmin(ctx) && hasRole(ctx, ['picker']) ? ctx.userId : null;
|
||||
const params: unknown[] = [branchCode];
|
||||
let pickerFilter = '';
|
||||
@@ -69,12 +122,7 @@ async function countPicking(ctx: TenantContext, branchCode: string, scope: NavBa
|
||||
pickerFilter = `AND pt.picker_id = $${params.length}`;
|
||||
}
|
||||
const businessDay = `COALESCE(o.delivery_date::date, (o.created_at AT TIME ZONE 'Asia/Shanghai')::date)`;
|
||||
const dateFilter =
|
||||
scope === 'today'
|
||||
? `AND ${businessDay} = (NOW() AT TIME ZONE 'Asia/Shanghai')::date`
|
||||
: scope === 'month'
|
||||
? `AND ${monthRangeSql(businessDay)}`
|
||||
: '';
|
||||
const dateFilter = scope === 'all' ? '' : `AND ${scopedDateFilter(scope, businessDay, days)}`;
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM picking_tasks pt
|
||||
@@ -96,7 +144,7 @@ async function countPicking(ctx: TenantContext, branchCode: string, scope: NavBa
|
||||
}
|
||||
|
||||
/** 管理员 = 分公司全部;配送员 = 本人;today 只看配送日=今天,task_status = 10 */
|
||||
async function countDelivery(ctx: TenantContext, branchCode: string, scope: NavBadgeScope): Promise<number> {
|
||||
async function countDelivery(ctx: TenantContext, branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
let personCode: string | null = null;
|
||||
if (!isBranchAdmin(ctx) && hasRole(ctx, ['delivery'])) {
|
||||
const person = await pool.query<{ person_code: string | null }>(
|
||||
@@ -118,12 +166,7 @@ async function countDelivery(ctx: TenantContext, branchCode: string, scope: NavB
|
||||
personFilter = `AND dt.person_code = $${params.length}`;
|
||||
}
|
||||
const businessDay = `COALESCE(o.delivery_date::date, (o.created_at AT TIME ZONE 'Asia/Shanghai')::date)`;
|
||||
const dateFilter =
|
||||
scope === 'today'
|
||||
? `AND ${businessDay} = (NOW() AT TIME ZONE 'Asia/Shanghai')::date`
|
||||
: scope === 'month'
|
||||
? `AND ${monthRangeSql(businessDay)}`
|
||||
: '';
|
||||
const dateFilter = scope === 'all' ? '' : `AND ${scopedDateFilter(scope, businessDay, days)}`;
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM delivery_tasks dt
|
||||
@@ -169,17 +212,12 @@ async function countProcessingAll(): Promise<number> {
|
||||
* 智能入库待验收:只读 COUNT,绝不能调会 prune/DELETE 的旧函数。
|
||||
* today 与页面默认口径一致:inspection_time IS NULL + 可见性 + 配送日=今天(无订单回退建单日)。
|
||||
*/
|
||||
async function countPendingInspectionsReadonly(scope: NavBadgeScope): Promise<number> {
|
||||
async function countPendingInspectionsReadonly(scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const inspectionDay = `COALESCE(
|
||||
(SELECT o.delivery_date::date FROM orders o WHERE o.order_code = i.order_code LIMIT 1),
|
||||
(i.created_at AT TIME ZONE 'Asia/Shanghai')::date
|
||||
)`;
|
||||
const dateFilter =
|
||||
scope === 'today'
|
||||
? `AND ${inspectionDay} = (NOW() AT TIME ZONE 'Asia/Shanghai')::date`
|
||||
: scope === 'month'
|
||||
? `AND ${monthRangeSql(inspectionDay)}`
|
||||
: '';
|
||||
const dateFilter = scope === 'all' ? '' : `AND ${scopedDateFilter(scope, inspectionDay, days)}`;
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM inspections i
|
||||
@@ -191,14 +229,9 @@ async function countPendingInspectionsReadonly(scope: NavBadgeScope): Promise<nu
|
||||
}
|
||||
|
||||
/** 供应商备货待办:today 配送日优先(无订单回退 sp.created_at);all 去日期。 */
|
||||
async function countPendingPreparationsReadonly(branchCode: string, scope: NavBadgeScope): Promise<number> {
|
||||
async function countPendingPreparationsReadonly(branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const prepDay = `COALESCE(o.delivery_date::date, (sp.created_at AT TIME ZONE 'Asia/Shanghai')::date)`;
|
||||
const dateFilter =
|
||||
scope === 'today'
|
||||
? `AND ${prepDay} = (NOW() AT TIME ZONE 'Asia/Shanghai')::date`
|
||||
: scope === 'month'
|
||||
? `AND ${monthRangeSql(prepDay)}`
|
||||
: '';
|
||||
const dateFilter = scope === 'all' ? '' : `AND ${scopedDateFilter(scope, prepDay, days)}`;
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM supplier_preparations sp
|
||||
@@ -218,7 +251,7 @@ async function countPendingPreparationsReadonly(branchCode: string, scope: NavBa
|
||||
}
|
||||
|
||||
/** 售后按 delivery_date 默认口径 + 异常 <30;按权限拆分,admin/super 两者都算。 */
|
||||
async function countOps(ctx: TenantContext, branchCode: string, scope: NavBadgeScope): Promise<number> {
|
||||
async function countOps(ctx: TenantContext, branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const both = ctx.isSuperAdmin || isBranchAdmin(ctx);
|
||||
const canSales = both || hasPermission(ctx, 'aftersales_manage');
|
||||
const canException = both || hasPermission(ctx, 'exception_manage');
|
||||
@@ -230,12 +263,7 @@ async function countOps(ctx: TenantContext, branchCode: string, scope: NavBadgeS
|
||||
(o.created_at AT TIME ZONE 'Asia/Shanghai')::date,
|
||||
(a.created_at AT TIME ZONE 'Asia/Shanghai')::date
|
||||
)`;
|
||||
const dateFilter =
|
||||
scope === 'today'
|
||||
? `AND ${salesDay} = (NOW() AT TIME ZONE 'Asia/Shanghai')::date`
|
||||
: scope === 'month'
|
||||
? `AND ${monthRangeSql(salesDay)}`
|
||||
: '';
|
||||
const dateFilter = scope === 'all' ? '' : `AND ${scopedDateFilter(scope, salesDay, days)}`;
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM after_sales a
|
||||
@@ -250,8 +278,8 @@ async function countOps(ctx: TenantContext, branchCode: string, scope: NavBadgeS
|
||||
}
|
||||
if (canException) {
|
||||
const exceptionDateFilter =
|
||||
scope === 'month'
|
||||
? `AND ${monthRangeSql("(et.created_at AT TIME ZONE 'Asia/Shanghai')::date")}`
|
||||
scope === 'month' || scope === 'days'
|
||||
? `AND ${scopedDateFilter(scope, "(et.created_at AT TIME ZONE 'Asia/Shanghai')::date", days)}`
|
||||
: '';
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
@@ -283,7 +311,7 @@ async function countPendingSpi(branchCode: string, scope: NavBadgeScope): Promis
|
||||
return Number(result.rows[0]?.c) || 0;
|
||||
}
|
||||
|
||||
async function countPurchaseMonth(branchCode: string): Promise<number> {
|
||||
async function countPurchaseWindow(branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const day = `COALESCE(o.delivery_date::date, (po.created_at AT TIME ZONE 'Asia/Shanghai')::date)`;
|
||||
const po = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
@@ -292,7 +320,7 @@ async function countPurchaseMonth(branchCode: string): Promise<number> {
|
||||
WHERE ${purchaseOrderBranchWhereSql('po', '$1')}
|
||||
AND po.purchase_status IN (10, 32)
|
||||
AND (po.order_code IS NULL OR TRIM(po.order_code) = '' OR ${orderCodeActiveExistsSql('po.order_code')})
|
||||
AND ${monthRangeSql(day)}`,
|
||||
AND ${scopedDateFilter(scope, day, days)}`,
|
||||
[branchCode]
|
||||
);
|
||||
const spiDay = `(spi.created_at AT TIME ZONE 'Asia/Shanghai')::date`;
|
||||
@@ -302,26 +330,26 @@ async function countPurchaseMonth(branchCode: string): Promise<number> {
|
||||
WHERE spi.branch_code = $1
|
||||
AND spi.voided_at IS NULL
|
||||
AND spi.inventory_id IS NULL
|
||||
AND ${monthRangeSql(spiDay)}`,
|
||||
AND ${scopedDateFilter(scope, spiDay, days)}`,
|
||||
[branchCode]
|
||||
);
|
||||
return (Number(po.rows[0]?.c) || 0) + (Number(spi.rows[0]?.c) || 0);
|
||||
}
|
||||
|
||||
async function countPendingPriceQtyMonth(branchCode: string): Promise<number> {
|
||||
async function countPendingPriceQtyWindow(branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM public.main_system_actual_qty_requests
|
||||
WHERE branch_code = $1
|
||||
AND status = 'pending'
|
||||
AND ${monthRangeSql("(created_at AT TIME ZONE 'Asia/Shanghai')::date")}`,
|
||||
AND ${scopedDateFilter(scope, "(created_at AT TIME ZONE 'Asia/Shanghai')::date", days)}`,
|
||||
[branchCode]
|
||||
);
|
||||
return Number(result.rows[0]?.c) || 0;
|
||||
}
|
||||
|
||||
/** 待竞价:表里没有 invited_at,按 respond_deadline 所在自然月(同页面的报价截止业务日)。 */
|
||||
async function countPendingBidMonth(branchCode: string): Promise<number> {
|
||||
async function countPendingBidWindow(branchCode: string, scope: NavBadgeScope, days?: number): Promise<number> {
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM public.main_system_bid_invitations
|
||||
@@ -329,7 +357,7 @@ async function countPendingBidMonth(branchCode: string): Promise<number> {
|
||||
AND deleted_at IS NULL
|
||||
AND local_status = 'pending'
|
||||
AND respond_deadline IS NOT NULL
|
||||
AND ${monthRangeSql("(respond_deadline AT TIME ZONE 'Asia/Shanghai')::date")}`,
|
||||
AND ${scopedDateFilter(scope, "(respond_deadline AT TIME ZONE 'Asia/Shanghai')::date", days)}`,
|
||||
[branchCode]
|
||||
);
|
||||
return Number(result.rows[0]?.c) || 0;
|
||||
@@ -341,7 +369,7 @@ export const NAV_BADGE_COUNTERS: Record<string, NavBadgeCounter> = {
|
||||
async count(input) {
|
||||
if (input.scope === 'today') return countPendingPickingOrders();
|
||||
const day = `COALESCE(o.delivery_date::date, (o.created_at AT TIME ZONE 'Asia/Shanghai')::date)`;
|
||||
const dateFilter = input.scope === 'month' ? `AND ${monthRangeSql(day)}` : '';
|
||||
const dateFilter = input.scope === 'all' ? '' : `AND ${scopedDateFilter(input.scope, day, input.days)}`;
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c FROM orders o
|
||||
WHERE o.order_status < 50 AND ${orderNotDeletedSql('o')} ${dateFilter}`
|
||||
@@ -353,7 +381,7 @@ export const NAV_BADGE_COUNTERS: Record<string, NavBadgeCounter> = {
|
||||
permission: 'purchase_manage',
|
||||
async count(input) {
|
||||
// 页面默认 today 是配送日轴(不是 created_at)
|
||||
if (input.scope === 'month') return countPurchaseMonth(input.branchCode);
|
||||
if (input.scope === 'month' || input.scope === 'days') return countPurchaseWindow(input.branchCode, input.scope, input.days);
|
||||
const [po, spi] = await Promise.all([
|
||||
input.scope === 'today'
|
||||
? countPendingBranchPurchaseTasks(input.branchCode, 'delivery_date')
|
||||
@@ -366,13 +394,13 @@ export const NAV_BADGE_COUNTERS: Record<string, NavBadgeCounter> = {
|
||||
'purchase-preparations': {
|
||||
permission: 'preparation_manage',
|
||||
async count(input) {
|
||||
return countPendingPreparationsReadonly(input.branchCode, input.scope);
|
||||
return countPendingPreparationsReadonly(input.branchCode, input.scope, input.days);
|
||||
},
|
||||
},
|
||||
'orders-price-qty': {
|
||||
permission: 'price_qty_review',
|
||||
async count(input) {
|
||||
if (input.scope === 'month') return countPendingPriceQtyMonth(input.branchCode);
|
||||
if (input.scope === 'month' || input.scope === 'days') return countPendingPriceQtyWindow(input.branchCode, input.scope, input.days);
|
||||
const inbox = await listActualQtyInbox({
|
||||
branchCode: input.branchCode,
|
||||
scope: 'pending',
|
||||
@@ -385,7 +413,7 @@ export const NAV_BADGE_COUNTERS: Record<string, NavBadgeCounter> = {
|
||||
'orders-bid-invitations': {
|
||||
permission: 'bid_quote',
|
||||
async count(input) {
|
||||
if (input.scope === 'month') return countPendingBidMonth(input.branchCode);
|
||||
if (input.scope === 'month' || input.scope === 'days') return countPendingBidWindow(input.branchCode, input.scope, input.days);
|
||||
const result = await listBidInvitations({
|
||||
branchCode: input.branchCode,
|
||||
status: 'pending',
|
||||
@@ -396,20 +424,20 @@ export const NAV_BADGE_COUNTERS: Record<string, NavBadgeCounter> = {
|
||||
},
|
||||
'inspection-list': {
|
||||
permission: 'inspection_manage',
|
||||
count: (input) => countPendingInspectionsReadonly(input.scope),
|
||||
count: (input) => countPendingInspectionsReadonly(input.scope, input.days),
|
||||
},
|
||||
'inspection-processing': {
|
||||
permission: 'processing_manage',
|
||||
async count(input) {
|
||||
if (input.scope === 'today') return countPendingProcessingTasks('created_at');
|
||||
if (input.scope === 'month') {
|
||||
if (input.scope === 'month' || input.scope === 'days') {
|
||||
const result = await pool.query(
|
||||
`SELECT COUNT(*)::int AS c
|
||||
FROM processing_tasks pt
|
||||
LEFT JOIN orders o ON o.order_code = pt.order_code
|
||||
WHERE pt.process_status IN (10, 20, 30)
|
||||
AND (pt.order_code IS NULL OR ${orderCodeActiveExistsSql('pt.order_code')})
|
||||
AND ${monthRangeSql("(pt.created_at AT TIME ZONE 'Asia/Shanghai')::date")}`
|
||||
AND ${scopedDateFilter(input.scope, "(pt.created_at AT TIME ZONE 'Asia/Shanghai')::date", input.days)}`
|
||||
);
|
||||
return Number(result.rows[0]?.c) || 0;
|
||||
}
|
||||
@@ -419,16 +447,16 @@ export const NAV_BADGE_COUNTERS: Record<string, NavBadgeCounter> = {
|
||||
picking: {
|
||||
permission: 'picking_manage',
|
||||
roles: ['picker'],
|
||||
count: (input) => countPicking(input.ctx, input.branchCode, input.scope),
|
||||
count: (input) => countPicking(input.ctx, input.branchCode, input.scope, input.days),
|
||||
},
|
||||
delivery: {
|
||||
permission: 'delivery_manage',
|
||||
roles: ['delivery'],
|
||||
count: (input) => countDelivery(input.ctx, input.branchCode, input.scope),
|
||||
count: (input) => countDelivery(input.ctx, input.branchCode, input.scope, input.days),
|
||||
},
|
||||
ops: {
|
||||
permission: ['aftersales_manage', 'exception_manage'],
|
||||
count: (input) => countOps(input.ctx, input.branchCode, input.scope),
|
||||
count: (input) => countOps(input.ctx, input.branchCode, input.scope, input.days),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -460,7 +488,9 @@ export async function getNavBadges(
|
||||
}
|
||||
const permissionKey = [...(input.ctx.permissions || [])].sort().join(',');
|
||||
const roleKey = [...(input.ctx.roles || [])].sort().join(',');
|
||||
const baseKey = `${input.branchCode}|${input.userId}|${input.scope}|${input.ctx.isSuperAdmin ? 1 : 0}|${permissionKey}|${roleKey}`;
|
||||
const daysKey = normalizeNavBadgeDays(input.days);
|
||||
const baseKey = `${input.branchCode}|${input.userId}|${input.scope}|${daysKey}|${input.ctx.isSuperAdmin ? 1 : 0}|${permissionKey}|${roleKey}`;
|
||||
const effectiveInput: NavBadgeContext = { ...input, days: normalizeNavBadgeDays(input.days) };
|
||||
const selectedKeys = requestedKeys ?? Object.keys(NAV_BADGE_COUNTERS);
|
||||
|
||||
const data: Record<string, number> = {};
|
||||
@@ -475,7 +505,7 @@ export async function getNavBadges(
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const value = Number(await counter.count(input)) || 0;
|
||||
const value = Number(await counter.count(effectiveInput)) || 0;
|
||||
data[menuKey] = value;
|
||||
cache.set(cacheKey, { expiresAt: Date.now() + CACHE_TTL_MS, value });
|
||||
} catch (error) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { TenantContext } from '../src/services/tenantScope';
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
getNavBadges: vi.fn(),
|
||||
getNavBadgeDays: vi.fn(),
|
||||
getWorkflowCtx: vi.fn(),
|
||||
runWithTenantDbContext: vi.fn(),
|
||||
}));
|
||||
@@ -33,6 +34,7 @@ vi.mock('../src/services/tenantDbContext', () => ({
|
||||
}));
|
||||
vi.mock('../src/services/navBadgeService', () => ({
|
||||
getNavBadges: (...args: unknown[]) => mocks.getNavBadges(...args),
|
||||
getNavBadgeDays: (...args: unknown[]) => mocks.getNavBadgeDays(...args),
|
||||
NAV_BADGE_COUNTERS: {
|
||||
'orders-list': {},
|
||||
picking: {},
|
||||
@@ -76,6 +78,7 @@ beforeEach(() => {
|
||||
delete process.env.NAV_BADGES_ENABLED;
|
||||
mocks.getWorkflowCtx.mockResolvedValue(ctx());
|
||||
mocks.getNavBadges.mockResolvedValue({ 'orders-list': 3 });
|
||||
mocks.getNavBadgeDays.mockResolvedValue(30);
|
||||
mocks.runWithTenantDbContext.mockImplementation(async (_branch: string, fn: () => Promise<unknown>) => fn());
|
||||
});
|
||||
afterEach(() => {
|
||||
@@ -91,18 +94,42 @@ describe('GET /api/workflow/nav-badges', () => {
|
||||
expect(res.body.error).toBe('invalid_scope');
|
||||
});
|
||||
|
||||
it('不传 scope 默认 month;scope=month 合法', async () => {
|
||||
it('不传 scope 默认 days;scope=days 合法并读取配置天数', async () => {
|
||||
process.env.NAV_BADGES_ENABLED = '1';
|
||||
const def = await request(buildApp())
|
||||
.get('/api/workflow/nav-badges')
|
||||
.set('x-test-user-id', 'U1');
|
||||
expect(def.status).toBe(200);
|
||||
expect(def.body.scope).toBe('month');
|
||||
const month = await request(buildApp())
|
||||
.get('/api/workflow/nav-badges?scope=month')
|
||||
expect(def.body.scope).toBe('days');
|
||||
mocks.getNavBadgeDays.mockResolvedValueOnce(7);
|
||||
const days = await request(buildApp())
|
||||
.get('/api/workflow/nav-badges?scope=days')
|
||||
.set('x-test-user-id', 'U1');
|
||||
expect(month.status).toBe(200);
|
||||
expect(month.body.scope).toBe('month');
|
||||
expect(days.status).toBe(200);
|
||||
expect(days.body.scope).toBe('days');
|
||||
expect(mocks.getNavBadges).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ days: 7 }),
|
||||
undefined,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('超管不读分公司配置,固定 days=30', async () => {
|
||||
process.env.NAV_BADGES_ENABLED = '1';
|
||||
mocks.getWorkflowCtx.mockResolvedValue(
|
||||
ctx({ isSuperAdmin: true, isBranchAdmin: false, roles: ['super_admin'], branchCode: null })
|
||||
);
|
||||
const res = await request(buildApp())
|
||||
.get('/api/workflow/nav-badges')
|
||||
.set('x-test-user-id', 'U1')
|
||||
.set('x-test-operating-branch', 'BR002');
|
||||
expect(res.status).toBe(200);
|
||||
expect(mocks.getNavBadgeDays).not.toHaveBeenCalled();
|
||||
expect(mocks.getNavBadges).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ days: 30, branchCode: 'BR002' }),
|
||||
undefined,
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('menus 指定 key 传给 service;refresh=1 透传', async () => {
|
||||
|
||||
@@ -47,7 +47,14 @@ vi.mock('../src/services/deliveryTaskQueryService', () => ({
|
||||
countPendingDriverDeliveryTasks: (...args: unknown[]) => mocks.driverDelivery(...args),
|
||||
}));
|
||||
|
||||
import { clearNavBadgeCache, getNavBadges, isNavBadgeAllowed, NAV_BADGE_COUNTERS } from '../src/services/navBadgeService';
|
||||
import {
|
||||
clearNavBadgeCache,
|
||||
getNavBadgeDays,
|
||||
getNavBadges,
|
||||
isNavBadgeAllowed,
|
||||
NAV_BADGE_COUNTERS,
|
||||
normalizeNavBadgeDays,
|
||||
} from '../src/services/navBadgeService';
|
||||
|
||||
const ctx = (overrides: Partial<TenantContext> = {}): TenantContext => ({
|
||||
userId: 'U1',
|
||||
@@ -180,6 +187,37 @@ describe('navBadgeService', () => {
|
||||
expect(String(mocks.query.mock.calls.find(([s]) => String(s).includes('exception_tickets'))?.[0] || '')).toContain('ticket_status < 30');
|
||||
});
|
||||
|
||||
it('nav_badge_days:默认 30、范围 1~365、非法回退;配置读取分支优先', async () => {
|
||||
expect(normalizeNavBadgeDays(undefined)).toBe(30);
|
||||
expect(normalizeNavBadgeDays(0)).toBe(30);
|
||||
expect(normalizeNavBadgeDays(366)).toBe(30);
|
||||
expect(normalizeNavBadgeDays('abc')).toBe(30);
|
||||
expect(normalizeNavBadgeDays(1)).toBe(1);
|
||||
expect(normalizeNavBadgeDays(365)).toBe(365);
|
||||
|
||||
mocks.query.mockImplementation(async (sql: string) => {
|
||||
if (String(sql).includes("config_key = 'nav_badge_days'")) {
|
||||
return { rows: [{ config_value: { days: 7 } }], rowCount: 1 };
|
||||
}
|
||||
return { rows: [{ c: 9 }], rowCount: 1 };
|
||||
});
|
||||
expect(await getNavBadgeDays('BR002')).toBe(7);
|
||||
});
|
||||
|
||||
it('scope=days:统一滚动窗口 >= 今天-(N-1),缓存含 days', async () => {
|
||||
await getNavBadges({ ctx: ctx(), branchCode: 'BR002', userId: 'D7', scope: 'days', days: 7 });
|
||||
const sqls = mocks.query.mock.calls.map(([s]) => String(s));
|
||||
const daySql = sqls.find((sql) => sql.includes('FROM orders o') && sql.includes('- 6'));
|
||||
expect(daySql).toBeTruthy();
|
||||
expect(daySql).toContain('<= (NOW() AT TIME ZONE');
|
||||
|
||||
const before = mocks.query.mock.calls.length;
|
||||
await getNavBadges({ ctx: ctx(), branchCode: 'BR002', userId: 'D7', scope: 'days', days: 7 });
|
||||
expect(mocks.query.mock.calls.length).toBe(before); // 同 key 缓存
|
||||
await getNavBadges({ ctx: ctx(), branchCode: 'BR002', userId: 'D7', scope: 'days', days: 30 });
|
||||
expect(mocks.query.mock.calls.length).toBeGreaterThan(before); // days 不同不共用
|
||||
});
|
||||
|
||||
it('menus keys:只算指定 key;refresh=1 绕过缓存;非法 key 抛 400;权限外不返回', async () => {
|
||||
const partial = await getNavBadges({ ctx: ctx(), branchCode: 'BR002', userId: 'K1', scope: 'today' }, ['orders-list']);
|
||||
expect(partial).toEqual({ 'orders-list': 1 });
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('Layout 导航角标接线', () => {
|
||||
it('调用 hook + 渲染 NavBadge', () => {
|
||||
expect(layout).toContain("import { useNavBadgeCounts } from '../hooks/useNavBadgeCounts'");
|
||||
expect(layout).toContain("import { NavBadge } from './NavBadge'");
|
||||
expect(layout).toContain("useNavBadgeCounts('month', outletKey, location.pathname)");
|
||||
expect(layout).toContain("useNavBadgeCounts('days', outletKey, location.pathname)");
|
||||
});
|
||||
|
||||
it('二级菜单用 child.menuKey 映射', () => {
|
||||
|
||||
@@ -82,7 +82,7 @@ export const Layout: React.FC = () => {
|
||||
const outletKey = isSuperAdmin
|
||||
? (operatingBranchCode || profile?.branch_code || 'no-branch')
|
||||
: (profile?.branch_code || 'default');
|
||||
const { counts: navBadgeCounts } = useNavBadgeCounts('month', outletKey, location.pathname);
|
||||
const { counts: navBadgeCounts } = useNavBadgeCounts('days', outletKey, location.pathname);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = window.setInterval(() => setCurrentTime(new Date()), 30_000);
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('useNavBadgeCounts', () => {
|
||||
});
|
||||
expect(result.current.counts['orders-list']).toBe(3);
|
||||
expect(mocks.fetchNavBadgeCountsApi).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.fetchNavBadgeCountsApi).toHaveBeenCalledWith('month');
|
||||
expect(mocks.fetchNavBadgeCountsApi).toHaveBeenCalledWith('days');
|
||||
|
||||
await act(async () => {
|
||||
await vi.advanceTimersByTimeAsync(60_000);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { MENU_CATALOG } from '../config/menuCatalog';
|
||||
import { fetchNavBadgeCountsApi } from '../utils/workflowApi';
|
||||
|
||||
export type NavBadgeScope = 'today' | 'month' | 'all';
|
||||
export type NavBadgeScope = 'today' | 'month' | 'all' | 'days';
|
||||
|
||||
/** 后端 NAV_BADGE_COUNTERS 的 key;pathname 只映射这些,避免把无角标菜单发给接口 */
|
||||
export const NAV_BADGE_MENU_KEYS = new Set([
|
||||
@@ -43,7 +43,7 @@ export function menuKeyForPath(pathname: string): string | null {
|
||||
* - 任一请求带 seq;旧响应不能覆盖新值;失败保留旧值。
|
||||
*/
|
||||
export function useNavBadgeCounts(
|
||||
scope: NavBadgeScope = 'month',
|
||||
scope: NavBadgeScope = 'days',
|
||||
branchKey = '',
|
||||
reloadKey = ''
|
||||
) {
|
||||
|
||||
@@ -894,6 +894,10 @@ export const system: MessageDict = {
|
||||
"roles.act.deleteBuiltinTitle": "Built-in roles cannot be deleted",
|
||||
"menuLayout.unassignedWarn": "{n} modules are unassigned; set standalone or add to a group.",
|
||||
// 「允许成本价为 0」开关(分公司管理员可见,默认关闭)
|
||||
'config.navBadgeDays.title': 'Nav badge lookback days',
|
||||
'config.navBadgeDays.hint': 'Only affects sidebar pending badges, using a rolling business-day window (1–365, default 30).',
|
||||
'config.navBadgeDays.label': 'Lookback days',
|
||||
'config.navBadgeDays.saved': 'Nav badge lookback saved',
|
||||
'config.zeroCost.title': 'Allow zero cost price',
|
||||
'config.zeroCost.desc': 'When on, self-purchase, preparation, supplier and independent inbound may save/proceed with a 0 cost; cost and margin are then computed as 0 (off by default).',
|
||||
'config.zeroCost.saved': 'Saved. Applies to this branch.',
|
||||
|
||||
@@ -894,6 +894,10 @@ export const system: MessageDict = {
|
||||
"roles.act.deleteBuiltinTitle": "Peran bawaan tidak dapat dihapus",
|
||||
"menuLayout.unassignedWarn": "{n} modul belum ditetapkan; pilih mandiri atau masukkan ke grup.",
|
||||
// 「允许成本价为 0」开关(分公司管理员可见,默认关闭)
|
||||
'config.navBadgeDays.title': 'Hari mundur lencana navigasi',
|
||||
'config.navBadgeDays.hint': 'Hanya memengaruhi lencana tertunda sidebar, memakai jendela hari bisnis bergulir (1–365, default 30).',
|
||||
'config.navBadgeDays.label': 'Hari mundur',
|
||||
'config.navBadgeDays.saved': 'Hari mundur lencana disimpan',
|
||||
'config.zeroCost.title': 'Izinkan harga pokok 0',
|
||||
'config.zeroCost.desc': 'Jika aktif, pembelian sendiri, persiapan, pemasok, dan barang masuk mandiri dapat disimpan/dilanjutkan dengan biaya 0; biaya dan margin dihitung 0 (default nonaktif).',
|
||||
'config.zeroCost.saved': 'Tersimpan. Berlaku untuk cabang ini.',
|
||||
|
||||
@@ -894,6 +894,10 @@ export const system: MessageDict = {
|
||||
"roles.act.deleteBuiltinTitle": "内置角色不可删除",
|
||||
"menuLayout.unassignedWarn": "有 {n} 个模块未分配,请选择单独显示或加入某个组。",
|
||||
// 「允许成本价为 0」开关(分公司管理员可见,默认关闭)
|
||||
'config.navBadgeDays.title': '导航待办角标查询天数',
|
||||
'config.navBadgeDays.hint': '只影响侧边栏待办角标,按业务日滚动窗口统计(1~365,默认 30)。',
|
||||
'config.navBadgeDays.label': '查询天数',
|
||||
'config.navBadgeDays.saved': '导航角标天数已保存',
|
||||
'config.zeroCost.title': '允许成本价为 0',
|
||||
'config.zeroCost.desc': '开启后,自采、备货、供应商与独立入库可按 0 成本保存与推进;成本与毛利将按 0 计算(默认关闭)。',
|
||||
'config.zeroCost.saved': '已保存,将对该分公司生效',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const src = readFileSync(new URL('./SystemConfig.tsx', import.meta.url), 'utf8');
|
||||
const zh = readFileSync(new URL('../../i18n/locales/zh-CN/system.ts', import.meta.url), 'utf8');
|
||||
|
||||
describe('系统配置 · 导航角标查询天数', () => {
|
||||
it('仅分公司管理员可见/保存;超管不渲染卡片', () => {
|
||||
expect(src).toContain('isBranchAdmin && activeBranchCode');
|
||||
expect(src).toContain("config_key: 'nav_badge_days'");
|
||||
expect(src).toContain('branch_code: activeBranchCode');
|
||||
expect(src).toContain("findConfigByKeyScope(configs, 'nav_badge_days', activeBranchCode)");
|
||||
});
|
||||
|
||||
it('默认 30、范围 1~365,非法回退 30', () => {
|
||||
expect(src).toContain('function normalizeNavBadgeDaysInput(raw: unknown): number');
|
||||
expect(src).toContain('Number.isInteger(n) && n >= 1 && n <= 365 ? n : 30');
|
||||
expect(src).toContain('const [navBadgeDays, setNavBadgeDays] = useState(30)');
|
||||
});
|
||||
|
||||
it('保存走 system_configs,带 days 与分公司,更新已有行/插入新行', () => {
|
||||
expect(src).toContain('config_value: { days }');
|
||||
expect(src).toContain(".from('system_configs')");
|
||||
expect(src).toContain('.update({ config_value: { days }');
|
||||
expect(src).toContain("notify.success(t('system.config.navBadgeDays.saved'))");
|
||||
});
|
||||
|
||||
it('三语文案键存在', () => {
|
||||
expect(zh).toContain("'config.navBadgeDays.title'");
|
||||
expect(zh).toContain("'config.navBadgeDays.hint'");
|
||||
});
|
||||
});
|
||||
@@ -82,6 +82,11 @@ function freeCostMpDraftKey(scope: string) {
|
||||
return `${FREE_COST_MP_DRAFT_KEY}:${scope || '__platform__'}`;
|
||||
}
|
||||
|
||||
function normalizeNavBadgeDaysInput(raw: unknown): number {
|
||||
const n = Number(raw);
|
||||
return Number.isInteger(n) && n >= 1 && n <= 365 ? n : 30;
|
||||
}
|
||||
|
||||
function findConfigByKeyScope(
|
||||
rows: ConfigItem[],
|
||||
configKey: string,
|
||||
@@ -132,6 +137,7 @@ const HIDDEN_CONFIG_KEYS = new Set([
|
||||
'free_cost_types',
|
||||
'picking_task_mode',
|
||||
'picking_workflow_enabled',
|
||||
'nav_badge_days',
|
||||
'quality_report_hard_gate_enabled',
|
||||
'quality_report_quarantine_valid_days',
|
||||
'supplier_prep_price_amend_enabled',
|
||||
@@ -156,6 +162,8 @@ export const SystemConfig: React.FC = () => {
|
||||
const [allowZeroCost, setAllowZeroCost] = useState(false);
|
||||
const [allowZeroCostLoaded, setAllowZeroCostLoaded] = useState(false);
|
||||
const [savingAllowZeroCost, setSavingAllowZeroCost] = useState(false);
|
||||
const [navBadgeDays, setNavBadgeDays] = useState(30);
|
||||
const [savingNavBadgeDays, setSavingNavBadgeDays] = useState(false);
|
||||
|
||||
const [selectedScope, setSelectedScope] = useState(() => {
|
||||
if (profile?.branch_code) return profile.branch_code;
|
||||
@@ -307,6 +315,18 @@ export const SystemConfig: React.FC = () => {
|
||||
? ''
|
||||
: selectedScope;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isBranchAdmin || !activeBranchCode) {
|
||||
setNavBadgeDays(30);
|
||||
return;
|
||||
}
|
||||
const row = findConfigByKeyScope(configs, 'nav_badge_days', activeBranchCode);
|
||||
const value = row?.config_value && typeof row.config_value === 'object'
|
||||
? (row.config_value as Record<string, unknown>).days
|
||||
: undefined;
|
||||
setNavBadgeDays(normalizeNavBadgeDaysInput(value));
|
||||
}, [configs, activeBranchCode, isBranchAdmin]);
|
||||
|
||||
const freeCostEditBranchCode = isBranchAdmin
|
||||
? profile?.branch_code || ''
|
||||
: isPlatformMenuScope(selectedScope)
|
||||
@@ -314,6 +334,45 @@ export const SystemConfig: React.FC = () => {
|
||||
: selectedScope || null;
|
||||
const freeCostMpScopeKey = freeCostEditBranchCode || '__platform__';
|
||||
const freeCostMpDraftId = freeCostMpDraftKey(freeCostMpScopeKey);
|
||||
const saveNavBadgeDays = async () => {
|
||||
if (!isBranchAdmin || !activeBranchCode) return;
|
||||
const days = normalizeNavBadgeDaysInput(navBadgeDays);
|
||||
setSavingNavBadgeDays(true);
|
||||
try {
|
||||
const existing = findConfigByKeyScope(configs, 'nav_badge_days', activeBranchCode);
|
||||
if (existing) {
|
||||
const { error } = await supabase
|
||||
.from('system_configs')
|
||||
.update({ config_value: { days }, updated_at: new Date().toISOString(), updated_by: profile?.id || null })
|
||||
.eq('id', existing.id);
|
||||
if (error) throw error;
|
||||
setConfigs((prev) => prev.map((item) => item.id === existing.id ? { ...item, config_value: { days } } : item));
|
||||
} else {
|
||||
const { data, error } = await supabase
|
||||
.from('system_configs')
|
||||
.insert({
|
||||
config_key: 'nav_badge_days',
|
||||
config_value: { days },
|
||||
config_group: 'other',
|
||||
description: '导航待办角标滚动查询天数(1~365,默认30)',
|
||||
branch_code: activeBranchCode,
|
||||
updated_at: new Date().toISOString(),
|
||||
updated_by: profile?.id || null,
|
||||
})
|
||||
.select('*')
|
||||
.single();
|
||||
if (error) throw error;
|
||||
setConfigs((prev) => [...prev, data as ConfigItem]);
|
||||
}
|
||||
setNavBadgeDays(days);
|
||||
notify.success(t('system.config.navBadgeDays.saved'));
|
||||
} catch (error: any) {
|
||||
notify(error?.message || t('system.config.toast.saveFail'));
|
||||
} finally {
|
||||
setSavingNavBadgeDays(false);
|
||||
}
|
||||
};
|
||||
|
||||
const showFreeCostMpSection = isSuperAdmin || (isBranchAdmin && Boolean(profile?.branch_code));
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1248,6 +1307,38 @@ export const SystemConfig: React.FC = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isBranchAdmin && activeBranchCode && (
|
||||
<div className="app-surface rounded-xl border p-4 space-y-3">
|
||||
<div>
|
||||
<h2 className="text-base font-semibold text-gray-900 dark:text-white">{t('system.config.navBadgeDays.title')}</h2>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mt-1">{t('system.config.navBadgeDays.hint')}</p>
|
||||
</div>
|
||||
<div className="flex items-end gap-3">
|
||||
<label className="block">
|
||||
<span className="text-xs text-gray-500">{t('system.config.navBadgeDays.label')}</span>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
max={365}
|
||||
step={1}
|
||||
value={navBadgeDays}
|
||||
onChange={(e) => setNavBadgeDays(normalizeNavBadgeDaysInput(e.target.value))}
|
||||
className="app-input mt-1 w-28 rounded-lg border px-3 py-2 text-sm"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void saveNavBadgeDays()}
|
||||
disabled={savingNavBadgeDays}
|
||||
className="inline-flex items-center gap-2 rounded-lg bg-emerald-600 px-3 py-2 text-sm text-white hover:bg-emerald-700 disabled:opacity-50"
|
||||
>
|
||||
{savingNavBadgeDays ? <Loader2 className="w-4 h-4 animate-spin" /> : <Save className="w-4 h-4" />}
|
||||
{t('common.save')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isBranchAdmin && (
|
||||
<div className="app-surface rounded-xl border p-4 space-y-3">
|
||||
<div>
|
||||
|
||||
@@ -7506,7 +7506,7 @@ export async function confirmReturnQualityApi(returnCode: string, qualified: boo
|
||||
* 默认关闭时后端返回 `{data:{},disabled:true}`;调用方据此不显示角标。
|
||||
*/
|
||||
export async function fetchNavBadgeCountsApi(
|
||||
scope: 'today' | 'month' | 'all' = 'month',
|
||||
scope: 'today' | 'month' | 'all' | 'days' = 'days',
|
||||
menus?: string[],
|
||||
refresh = false
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user