feat(前端): 公司 tab(store+组件+G1 双向对账)+ §9.3 引导文案承载
批次 1 的 tab 机制半边:默认选中 id 最小的启用公司、不允许「全部」;「该不该画 tab 条」只住 store 一处(组件里再数一遍 length 就是第二把尺子);两家全停用时 activeId 为 null ⇒ 整条不渲染,不画出按钮为零的空 tab 条。 G1 双向对账 + 跨端常量钉子(后端 SUPER_ADMIN_ONLY_KEYS ↔ 前端 SUPER_ADMIN_ONLY_MENU_KEYS 由代码执行地相等,读不到/抽不到/空集三种都判红) + pageFiles↔routes.ts load() 对账,把 Task 8-12 的接线欠债钉成会红的尺子。 §9.3 的「行数会随 tab 变」由既有引导文案承载(8 页 + C 类 2 页各一句,句子抽成 常量防手抄差异),不新做页头控件/提示条。 已知一条刻意红灯:company-tab-wiring.test.ts 的正向半支在 Task 12 接线完成前必红 (plan 19 Step 8 明令),下一条补齐接线的提交收敛它。全量 1726 例仅此 1 红, vue-tsc --noEmit 通过。 AdminLayout.vue / operation-guides.ts / company-config-entry-super-only.test.ts 三支文件此刻同时带着另一路会话的未提交改动,本提交按 hunk 逐行只入自己的部分。
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,选中哪家由哪一枚 tab 带 is-active 表达——
|
||||
* 这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
||||
* 观感说明走 operation-guides 的引导文案。 */
|
||||
import { computed, watch } from 'vue'
|
||||
import { COMPANY_STATUS_ACTIVE } from '@/api/companies-dto'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
|
||||
const tab = useCompanyTabStore()
|
||||
const session = useAdminSessionStore()
|
||||
const tabs = computed(() => tab.companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE))
|
||||
const show = computed(() => tab.visibleForOperator)
|
||||
|
||||
watch(() => session.isSuperAdmin, (v) => { if (v) void tab.initialize() }, { 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>
|
||||
Reference in New Issue
Block a user