feat(ui): remove in-app entity switcher, entity fixed at login

- MainLayout/ReportCenter: drop switch-entity switcher, keep read-only entity tag
- KPIList/PredictDashboard/GrowthQuality: entity selectors locked to session entity
- api/index.ts: drop switchEntity/myEntities wrappers (endpoint kept for compat)
- sidebar brand now shows logged-in entity name

(cma-remove-inapp-entity-switcher-20260914)
This commit is contained in:
Hermes CI Fix
2026-09-14 10:15:23 +08:00
parent 53c642b644
commit 1b73dbb272
6 changed files with 38 additions and 186 deletions
+15 -42
View File
@@ -4,12 +4,8 @@
<div class="gq-header">
<h3 class="gq-title">📊 增长质量诊断</h3>
<div class="gq-controls">
<el-select v-model="selectedEntityId" placeholder="选择企业" size="small" style="width:160px" @change="loadQuality">
<el-option v-for="e in entities" :key="e.id" :label="e.short_name || e.name" :value="e.id" />
</el-select>
<el-select v-model="compareEntityId" placeholder="对比企业(可选)" size="small" style="width:160px" clearable @change="loadQuality">
<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="primary" effect="plain">{{ currentEntityLabel }}</el-tag>
<el-button size="small" type="primary" @click="loadQuality" :loading="loading">诊断</el-button>
</div>
</div>
@@ -58,7 +54,6 @@
<div class="diag-text">{{ result.diagnosis }}</div>
<div class="diag-actions">
<el-button size="small" @click="openDetail('revenueStructure')">查看明细</el-button>
<el-button size="small" v-if="!showCompare && entities.length >= 2" @click="enableCompare">双实体对比</el-button>
</div>
</div>
@@ -100,7 +95,7 @@
</div>
<!-- 空状态 -->
<el-empty v-else-if="!loading" description="请选择企业进行增长质量诊断" />
<el-empty v-else-if="!loading" description="点击「诊断」查看当前账套增长质量" />
<!-- 明细下钻弹窗 -->
<el-dialog v-model="showDetail" :title="currentDimLabel + ' — ' + (result?.entity_name || '')" width="550px">
@@ -140,16 +135,15 @@
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { ref, computed } from 'vue'
import VChart from 'vue-echarts'
import 'echarts'
import { predictApi, entityApi } from '../api/index'
import { predictApi } from '../api/index'
import { ElMessage } from 'element-plus'
const loading = ref(false)
const entities = ref<any[]>([])
const selectedEntityId = ref<number | null>(null)
const compareEntityId = ref<number | null>(null)
const compareEntityId = ref<number | null>(null) // 跨企业对比已下线(登录即定企业),保留占位
const result = ref<any>(null)
const compareResult = ref<any>(null)
const showCompare = ref(false)
@@ -162,6 +156,14 @@ const fallbackEntities = [
{ id: -2, short_name: '陕西博海', name: '陕西博海网络科技' },
]
// 实体列表固定为内置演示实体;当前实体跟随登录账套(1=酣客 / 2=博海),组件内不可切换
const entities = ref<any[]>(fallbackEntities)
selectedEntityId.value = Number(localStorage.getItem('cma_entity_id') || 1) === 2 ? -2 : -1
const currentEntityLabel = computed(() => {
const e = entities.value.find((x: any) => x.id === selectedEntityId.value)
return e ? (e.short_name || e.name) : '当前企业'
})
// 预设测试数据(酣客 + 博海)
const testDataMap: Record<number, any> = {
[-1]: {
@@ -286,24 +288,7 @@ const radarOption = computed(() => {
}
})
async function loadEntities() {
try {
const r = await entityApi.list()
if (r?.data?.length) {
entities.value = r.data
// 如果有数据库实体,尝试预设选择
if (!selectedEntityId.value && entities.value.length >= 1) {
selectedEntityId.value = entities.value[0].id
}
} else {
entities.value = fallbackEntities
selectedEntityId.value = -1
}
} catch {
entities.value = fallbackEntities
selectedEntityId.value = -1
}
}
// ── 实体列表已固定(不再按登录用户拉取可选企业,也不提供切换)──
async function loadQuality() {
if (!selectedEntityId.value) return
@@ -366,18 +351,6 @@ function openDetail(dimKey: string) {
showDetail.value = true
}
function enableCompare() {
// 自动选择第一个不同的实体作为对比
const other = entities.value.find((e: any) => e.id !== selectedEntityId.value)
if (other) {
compareEntityId.value = other.id
loadQuality()
}
}
onMounted(() => {
loadEntities()
})
</script>
<style scoped>