e119abba1f
后台「当前页面操作提示」按 menuKey 取、不分支角色,而文案里塞了三族只描述 超管观感的句子(公司 tab 切换后行数会变/本页全平台共享不按公司区分/店铺归 哪家由负责人决定),普通账号进同一页就被摊到脸上。19 页共撤 21 句,各页回到 旧版 admin-interactions.js 原文;tab 本身与它的接线、取数口径一律没动。 护栏跟着反向:align-operation-guide 原先逐页要求"必须带上这句",现在钉"不得 回流"。禁句用 git show HEAD: 从提交里那一版取回、不手抄,另设一把纯 ASCII 的 tab 尺子——中文串被工具链插一个字就永远匹配不上,而负向断言照样绿。 验:变异自证(把原句塞回视频任务记录页判红、按内存里的原始字节还原 sha256 等值、干净态复跑绿);node --test 全量 1819 例 0 失败;vue-tsc --noEmit rc=0; 出包产物正反对照(4 句撤掉的 0 命中、2 句保留的各 1 命中)。
73 lines
3.6 KiB
Vue
73 lines
3.6 KiB
Vue
<script setup lang="ts">
|
||
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,而且只画在**注册表里真的按公司取数的那些页**上——
|
||
* 选中哪家由哪一枚 tab 带 is-active 表达,这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
||
* 提示条只讲这一页怎么办,不讲 tab(2026-10-14 公司观感那句已从引导文案撤掉,见 operation-guides 文件头)。 */
|
||
import { computed, watch } from 'vue'
|
||
import { useRoute } from 'vue-router'
|
||
import { COMPANY_STATUS_ACTIVE } from '@/api/companies-dto'
|
||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||
import { companyTabAppliesTo, companyTabInitFailureMessage } from '@/layout/company-tab-model'
|
||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||
|
||
const route = useRoute()
|
||
const tab = useCompanyTabStore()
|
||
const session = useAdminSessionStore()
|
||
const tabs = computed(() => tab.companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE))
|
||
const show = computed(() => tab.visibleForOperator && companyTabAppliesTo(route.meta.menuKey))
|
||
|
||
watch(() => session.isSuperAdmin, (v) => {
|
||
if (!v) return
|
||
// 2026-10-05 修复轮 1:改前这里是 `void tab.initialize()`,store 里也只有 try/finally ⇒
|
||
// GET /companies 抛错时异常变成 unhandled rejection(全仓 src 无 errorHandler/unhandledrejection 兜底),
|
||
// 现场只剩"tab 条没画出来",Task 13 人工清单第一项无从判断是权限问题还是接口挂了。
|
||
// 取不到目录 ⇒ fail-closed 不画 tab 条:store 不翻转 loaded,visibleForOperator 仍为 false,观感与改前一致。
|
||
// store 照 admin-session.ts:37-39 的口径 catch 出 error 之后仍然 rethrow,所以这一侧必须 .catch 接住。
|
||
// 模板里仍不长出任何新的常驻文字/提示条/图标(§12 第 5 条未批的暴露),但失败不许只剩 console.warn:
|
||
// 文案由 company-tab-model 出,可见出口统一走 admin-feedback-ui 的 showAdminFeedback(一次性提示)。
|
||
tab.initialize().catch((error: unknown) => {
|
||
console.warn('[company-tab] 公司目录没取到,tab 条不渲染', error)
|
||
showAdminFeedback(companyTabInitFailureMessage(error), 'warning')
|
||
})
|
||
}, { immediate: true })
|
||
</script>
|
||
|
||
<template>
|
||
<div v-if="show" class="company-tabs" role="tablist" aria-label="按公司查看数据">
|
||
<button
|
||
v-for="item in tabs"
|
||
:key="item.id"
|
||
type="button"
|
||
role="tab"
|
||
class="company-tab"
|
||
:class="{ 'is-active': item.id === tab.activeId }"
|
||
:aria-selected="item.id === tab.activeId"
|
||
@click="tab.setActiveId(item.id)"
|
||
>{{ item.companyName }}</button>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
/* 只给上面那几枚 tab 上样式:tab 条本身不产出任何文字节点,公司名一律来自 item.companyName。 */
|
||
.company-tabs {
|
||
display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px;
|
||
margin: 0 0 14px; padding: 0 2px;
|
||
border-bottom: 1px solid var(--admin-border);
|
||
}
|
||
.company-tab {
|
||
padding: 6px 16px;
|
||
border: 1px solid transparent; border-bottom: 0;
|
||
border-radius: 10px 10px 0 0;
|
||
background: none; cursor: pointer;
|
||
font: inherit; font-size: 13px; line-height: 1.7;
|
||
color: var(--admin-sidebar-text);
|
||
}
|
||
.company-tab:hover { color: var(--admin-primary-strong); background: var(--admin-primary-soft); }
|
||
.company-tab.is-active {
|
||
border-color: var(--admin-border);
|
||
background: #fff;
|
||
color: var(--admin-primary-strong); font-weight: 650;
|
||
box-shadow: inset 0 -2px 0 var(--admin-primary);
|
||
}
|
||
</style>
|