feat(web): 统一平台管理员判定与 AI 工作台申请预览动作接入

- authUser 抽出 resolveAuthUserAdminFlag,统一 isAdmin 解析(含 superadmin、role_codes、中英文角色名),accessControl 复用同一逻辑
- 登录态、应用外壳路由、系统状态接入统一管理员判定,LoginView 与相关 composable 配套调整
- AI 工作台申请提交改为调用新的 /application-preview-action 接口,草稿保存仍走 orchestrator;预审模型补充重叠冲突提示与阻断判断
- 同步更新 accessControl/api-request/ai 预览动作等前端测试
This commit is contained in:
caoxiaozhu
2026-06-20 14:42:04 +08:00
parent 729d833edb
commit 96c2e1099a
21 changed files with 1364 additions and 331 deletions

View File

@@ -1,3 +1,4 @@
import { apiRequest } from './api.js'
import { runOrchestrator } from './orchestrator.js'
import {
buildApplicationPreviewRows,
@@ -126,11 +127,20 @@ export function buildAiApplicationPreviewActionPayload({
}
export function runAiApplicationPreviewAction(params = {}, options = {}) {
return runOrchestrator(buildAiApplicationPreviewActionPayload(params), {
timeoutMs: params.actionType === AI_APPLICATION_ACTION_SUBMIT ? 120000 : 75000,
timeoutMessage: params.actionType === AI_APPLICATION_ACTION_SUBMIT
? '申请提交处理超时,请稍后重试。'
: '申请草稿保存超时,请稍后重试。',
const payload = buildAiApplicationPreviewActionPayload(params)
if (params.actionType === AI_APPLICATION_ACTION_SUBMIT) {
return apiRequest('/reimbursements/application-preview-action', {
method: 'POST',
body: JSON.stringify(payload),
timeoutMs: 45000,
timeoutMessage: '申请提交处理超时,请稍后重试。',
...options
})
}
return runOrchestrator(payload, {
timeoutMs: 75000,
timeoutMessage: '申请草稿保存超时,请稍后重试。',
...options
})
}

View File

@@ -1,4 +1,4 @@
import { normalizeAuthUserSnapshot } from '../utils/authUser.js'
import { normalizeAuthUserSnapshot, resolveAuthUserAdminFlag } from '../utils/authUser.js'
const API_BASE_STORAGE_KEY = 'x-financial-api-base-url'
const AUTH_USER_STORAGE_KEY = 'x-financial-auth-user'
@@ -49,7 +49,7 @@ function readCurrentUserHeaders() {
const username = user.username
const name = user.name || username
const roleCodes = user.roleCodes
const isAdmin = resolveStoredUserAdminFlag(payload, roleCodes)
const isAdmin = resolveAuthUserAdminFlag(payload, roleCodes)
const department = user.department || user.departmentName
const costCenter = user.costCenter
const position = user.position
@@ -112,22 +112,7 @@ function readCurrentUserHeaders() {
}
}
function resolveStoredUserAdminFlag(payload, roleCodes = []) {
const username = String(payload?.username || payload?.account || '').trim().toLowerCase()
const role = String(payload?.role || '').trim().toLowerCase()
const normalizedRoleCodes = roleCodes.map((item) => String(item || '').trim().toLowerCase()).filter(Boolean)
return (
Boolean(payload?.isAdmin)
|| username === 'admin'
|| role === 'admin'
|| role === '管理员'
|| role === '系统管理员'
|| normalizedRoleCodes.includes('admin')
)
}
function normalizeApiBaseUrl(value) {
function normalizeApiBaseUrl(value) {
return String(value || '/api/v1').replace(/\/$/, '')
}