feat: 账套模式全量接入 — 12个API entity_id统一走token解析链 + 前端登录选公司/切换器重签token

- 后端: kpis/bsc_layers/cash/predict/growth_quality/tax_compliance/data 的 entity_id 参数统一改为 Depends(get_entity_id)
- 前端: 拦截器删除自动附加X-Entity-Id/entity_id; 登录页公司选择器(按用户名授权过滤); 切换器改POST /auth/switch-entity重新签发token+整页刷新; ReportCenter同步改造
- 修复前后端不匹配: login-entities路由→/auth/entities; login响应entity_id取user.entity_id
This commit is contained in:
Hermes CI Fix
2026-08-11 11:29:39 +08:00
parent 12f9ae520b
commit 9986f38faa
11 changed files with 116 additions and 58 deletions
+4 -6
View File
@@ -8,12 +8,7 @@ const api = axios.create({
api.interceptors.request.use((config) => {
const token = localStorage.getItem('cma_token')
if (token) config.headers.Authorization = `Bearer ${token}`
// 多租户实时切换:统一附加当前企业ID(解决29个页面未传entity_id的问题)
const entityId = Number(localStorage.getItem('cma_entity_id') || 1)
config.headers['X-Entity-Id'] = String(entityId)
if (config.method === 'get' || config.method === 'GET') {
config.params = { ...(config.params || {}), entity_id: entityId }
}
// 账套模式:entity_id 由 token 绑定,前端不再自动附加 X-Entity-Id / entity_id
return config
})
@@ -32,6 +27,9 @@ api.interceptors.response.use(
export const authApi = {
login: (data: any) => api.post('/auth/login', data),
register: (data: any) => api.post('/auth/register', data),
switchEntity: (data: any) => api.post('/auth/switch-entity', data),
myEntities: () => api.get('/auth/my-entities'),
loginEntities: (username: string) => api.get('/auth/login-entities', { params: { username } }),
}
export const kpiApi = {