fix: 角色权限与数据范围修复

- 添加 RoleRoute 路由守卫组件,防止越权访问页面
- 菜单配置:区域经理加'区域对比',店长加'态势感知'
- database.ts: scope注入时检测主表别名避免store_code歧义
- analytics-enhanced.ts: KPI region模式手动注入scope过滤
- situational-awareness.ts: health-score手动注入scope,alerts加skipScope
- smart-scheduling.ts: position-salary-compare店长角色降低HAVING阈值
This commit is contained in:
freedakgmail
2026-08-02 21:28:25 +08:00
parent cfa12c9b7f
commit a011729fc9
13 changed files with 474 additions and 110 deletions
+3 -2
View File
@@ -776,6 +776,7 @@ router.get('/position-salary-compare', async (req: AuthRequest, res) => {
const month = parseMonth(req)
const [yr, mo] = month.split('-')
const periodLabel = `${parseInt(yr)}${parseInt(mo)}`
const minCount = req.user?.role === 'store' ? 1 : 5
const result = await query(`
SELECT position,
count(*) AS emp_count,
@@ -792,9 +793,9 @@ router.get('/position-salary-compare', async (req: AuthRequest, res) => {
AND position IS NOT NULL AND position != ''
AND salary_period = $1
GROUP BY position
HAVING count(*) >= 5
HAVING count(*) >= $2
ORDER BY avg_gross DESC
`, [periodLabel])
`, [periodLabel, minCount])
sendSuccess(res, result.rows)
} catch (err: any) {
sendError(res, err.message)