feat(frontend): Phase C 固定企业模式 - VITE_FIXED_ENTITY_ID 支持登录无下拉/隐藏切换器
- 新增 src/utils/entity.ts: isFixedEntity/getFixedEntityId/effectiveEntityId - Login.vue: 固定企业版隐藏企业下拉显示只读徽标, 登录直接带固定 entity_id - MainLayout.vue: 切换器加 !isFixedEntity() 守卫, 固定版顶部显示企业 tag, logo 带企业名 - ReportCenter.vue: 页内企业切换下拉加守卫, getEntityId 固定版恒取构建锁定值 - .env.example: VITE_FIXED_ENTITY_ID 示例与说明 - 验证脚本 backend/scripts/verify_phase_c_fixed_entity_e2e.py (22项, 双build E2E全过)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<el-aside :width="isCollapse ? '64px' : '220px'" :class="{ 'mobile-show': mobileMenuOpen }">
|
||||
<div class="aside-mask" v-if="mobileMenuOpen" @click="mobileMenuOpen = false"></div>
|
||||
<div class="logo">
|
||||
<span v-show="!isCollapse">管理会计OS</span>
|
||||
<span v-show="!isCollapse">{{ logoText }}</span>
|
||||
</div>
|
||||
<el-menu :default-active="activeMenu" :collapse="isCollapse" router background-color="#304156" text-color="#bfcbd9" active-text-color="#409EFF" @select="onMenuSelect">
|
||||
<template v-for="group in menuGroups" :key="group.label">
|
||||
@@ -28,8 +28,10 @@
|
||||
<span class="page-title">{{ pageTitle }}</span>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<!-- 企业切换器:仅多企业用户显示(授权企业≥2时),单企业用户隐藏避免UI噪音 -->
|
||||
<el-select v-if="entities.length >= 2" v-model="currentEntityId" @change="onEntityChange" size="small" style="width:120px;margin-right:8px;">
|
||||
<!-- 固定企业版(Phase C):显示当前企业 tag 代替切换器 -->
|
||||
<el-tag v-if="isFixedEntity()" size="small" type="primary" effect="plain" class="entity-tag">{{ currentEntityName }}</el-tag>
|
||||
<!-- 企业切换器:仅非固定版且授权企业≥2时显示(多企业用户),固定版/单企业用户隐藏避免UI噪音 -->
|
||||
<el-select v-else-if="entities.length >= 2" v-model="currentEntityId" @change="onEntityChange" size="small" style="width:120px;margin-right:8px;">
|
||||
<el-option v-for="e in entities" :key="e.id" :label="e.short_name || e.name" :value="e.id" />
|
||||
</el-select>
|
||||
<el-tag size="small" :type="roleTagType">{{ roleLabel }}</el-tag>
|
||||
@@ -57,12 +59,19 @@ import {
|
||||
DataBoard, Tools, Collection, Edit, Reading, Opportunity, PieChart,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { MENU_ITEMS, ROLE_LABELS } from '../permission'
|
||||
import { isFixedEntity } from '../utils/entity'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const isCollapse = ref(false)
|
||||
const mobileMenuOpen = ref(false)
|
||||
|
||||
// 侧边栏品牌:固定企业版带企业名(如「陕西酣客 · 管理会计OS」),切换版保持原名
|
||||
const logoText = computed(() => {
|
||||
if (isFixedEntity() && currentEntityName.value) return `${currentEntityName.value} · 管理会计OS`
|
||||
return '管理会计OS'
|
||||
})
|
||||
|
||||
// ── 全局企业切换(账套模式:switch-entity 重新签发token + 整页刷新) ──
|
||||
const entities = ref<any[]>([])
|
||||
const currentEntityId = ref(Number(localStorage.getItem('cma_entity_id') || 1))
|
||||
@@ -89,7 +98,8 @@ async function onEntityChange(id: number) {
|
||||
}
|
||||
}
|
||||
onMounted(async () => {
|
||||
// 账套模式:切换器只显示当前用户被授权的企业
|
||||
// 账套模式:切换器只显示当前用户被授权的企业;固定企业版无切换需求,跳过列表加载
|
||||
if (isFixedEntity()) return
|
||||
try {
|
||||
const r: any = await api.get('/auth/my-entities')
|
||||
entities.value = r.data || r || []
|
||||
|
||||
Reference in New Issue
Block a user