feat(菜单权限): 每家公司一套菜单树(V149)+ 公司 tab 只在注册表页渲染
本批两件事,加上随本批一起入仓的并行会话在制品: 一、菜单权限按公司隔离(批次 6) - V149 给 columns 加 company_id:先可空加列(末位、ALGORITHM=INSTANT)→ 回填公司 1 → MODIFY 收紧 NOT NULL;三段式缺一即撞 1048。同时建 (company_id, column_key) 复合键、 把公司 2 的 16 笔授权按 column_key 改指向它自己的副本,三类 menu_type 全复制, admin_companies 作为角色内生闸门行不复制(D3)。 - 第三道归属门 PermissionMenuService.resolveScopeCompanyId:站点超管可带 company_id 读写任意公司,非超管锁本公司、越界 403。它注册进 CompanyIdParamGoesThroughReadScopeTest 的 SCOPE_DOORS,四条判据与 readScope / readCompanyIdOrOwn 共用——护栏在代码出口,不靠清单。 - 旁路种子 PermissionMenuSchemaInitializer 只种公司 1:31 段种子逐条钉公司, 按 column_key 点查的 14 段全部带 company_id,否则摘了 DEFAULT 就是跨公司串写。 - CompanyService.create 同一次写入里给新公司复制模板树(D4)。 二、公司 tab 收口(批次 b) tab 条挂在壳层,对 22 页全画;改为按正列表 companyTabAppliesTo(menuKey) 判定, 只有注册表页渲染。护栏钉在用户看见的那个出口。 三、并行会话在制品(控制方「全部提交」,未单独拆分——见下) - V150 店铺密钥 biz_shop_key 按公司(readCompanyIdOrOwn + writeCompanyId 两道门) - V151 品牌库/商品类目推翻为全平台共享:只退唯一键、company_id DEFAULT 保留为 NOT NULL 承重约束(摘了每条 1364);删掉 ProductCategoryControllerCompanyScopeTest 那支"按公司隔离"的旧护栏,readCompanyId 方法一并移除 - invalidasin 字段与外观专利合批的连带改动 为什么不拆笔:后端 3891 例 / 0 红、前端 1731 例 / 0 红这两个读数是"合起来的树"的读数, 拆成多笔会让每一笔落到从未一起验过的组合上,而这一版要直接上两台。 回滚脚本在 backend-java/docs/rollback-V149/V150/V151-*.sql,不放进 Flyway 扫描路径。 设计记录:docs/ops/menu-company-tree-design-2026-10-06.md
This commit is contained in:
@@ -12,7 +12,7 @@ const PAGES: Array<{ title: string; path: string; heading: string }> = [
|
||||
{ title: '用户管理', path: '/admin-vue/account/users', heading: '用户列表' },
|
||||
{ title: '菜单管理', path: '/admin-vue/account/menus', heading: '菜单' },
|
||||
{ title: '密钥管理', path: '/admin-vue/account/user-secrets', heading: '用户密钥列表' },
|
||||
{ title: '不符合ASIN数据', path: '/admin-vue/asin-center/invalid', heading: '品牌数据列表' },
|
||||
{ title: '品牌数据库', path: '/admin-vue/asin-center/invalid', heading: '品牌数据列表' },
|
||||
{ title: '数据去重总数据', path: '/admin-vue/asin-center/registry', heading: '数据去重总数据' },
|
||||
{ title: '查询ASIN', path: '/admin-vue/asin-center/query', heading: '查询' },
|
||||
{ title: '最低价ASIN', path: '/admin-vue/asin-center/skip-price', heading: '最低价' },
|
||||
|
||||
@@ -29,11 +29,12 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
|
||||
// 这一批把前端接线补齐。apiFiles 只列**真的把 company_id 拼进请求**的模块:
|
||||
// 各页的 *-filter.ts 与 asin-filter.ts 只带 camel 的 companyId 字段(类型 + 白名单构造都不点名它),
|
||||
// 列进来会让正向判据去盯一个本来就不该出现 snake_case 的文件。
|
||||
// 【这两页已于 2026-10-06 退出注册表】admin_invalid_asin_data(品牌数据库)与 admin_product_categories
|
||||
// (商品类目)按控制方定案退回**全平台共享**,摘的不只是 tab:后端读写两侧的 company_id 谓词一起删
|
||||
// (V151 退唯一键)。反向钉在 tests/company-tab-wiring.test.ts——把它们再加回来必须先推翻那条定案。
|
||||
{ menuKey: 'admin_dedupe_total_data', apiFiles: ['src/pages/asin/dedupe-total-api.ts', 'src/pages/asin/dedupe-total-export.ts'], pageFiles: ['src/pages/asin/DedupeRegistryPage.vue'] },
|
||||
{ menuKey: 'admin_invalid_asin_data', apiFiles: ['src/pages/invalidasin/invalid-asin-api.ts'], pageFiles: ['src/pages/asin/AsinInvalidPage.vue'] },
|
||||
{ menuKey: 'admin_query_asin', apiFiles: ['src/pages/asin/query-asin-api.ts', 'src/pages/asin/query-asin-export.ts'], pageFiles: ['src/pages/asin/QueryAsinPage.vue'] },
|
||||
{ menuKey: 'admin_skip_price_asin', apiFiles: ['src/pages/asin/skip-price-api.ts', 'src/pages/asin/skip-price-export.ts'], pageFiles: ['src/pages/asin/SkipPricePage.vue'] },
|
||||
{ menuKey: 'admin_product_categories', apiFiles: ['src/pages/asin/product-category-api.ts', 'src/pages/asin/product-category-export.ts'], pageFiles: ['src/pages/asin/ProductCategoryPage.vue'] },
|
||||
// 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。这两页的可见集不是按 company_id 列筛的,
|
||||
// 而是「本公司账号名下的店铺」:后端由 DataReadScope 把公司 → 成员账号 → biz_shop_manage.created_by_id 逐级推导,
|
||||
// 前端只负责把 activeId 当 company_id 送下去。
|
||||
@@ -42,5 +43,16 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
|
||||
// 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
|
||||
// 这一页的后端早就认 company_id(AdminUserService 只在**站点超管**身上用它筛,公司超管恒锁本公司),
|
||||
// 断的是前端:users-dto 的 UserListQuery 里连这个字段都没有 ⇒ 三家 tab 看到的是同一份全量列表。
|
||||
{ menuKey: 'admin_users', apiFiles: ['src/api/users.ts'], pageFiles: ['src/pages/account/UsersPage.vue'] },
|
||||
{ menuKey: 'admin_users', apiFiles: ['src/api/users.ts', 'src/pages/account/user-menu-auth-api.ts'], pageFiles: ['src/pages/account/UsersPage.vue'] },
|
||||
// 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。biz_shop_key 原先零归属列,
|
||||
// 拿到这一页菜单的任意管理员读的是同一池全平台紫鸟令牌,而列表 VO 把令牌原文整列下发(悬停即得全文)。
|
||||
// V150 加 company_id;后端读门是 readCompanyIdOrOwn ⇒ 非超管连 company_id 都不带也一律锁本公司,
|
||||
// 这一页的 tab 只对超管改变行数(与其余页同形,见 COMPANY_TAB_GUIDE_NOTE 开头那句「超级管理员」)。
|
||||
{ menuKey: 'admin_shop_keys', apiFiles: ['src/pages/shop/shop-key-api.ts'], pageFiles: ['src/pages/shop/ShopKeysPage.vue'] },
|
||||
// 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」,并选了「每家公司一套菜单树」那一档)。
|
||||
// V149 给 columns 加 company_id 并把 52 行复制成每家一套 ⇒ 同一 column_key 在别家有另一份 id:
|
||||
// 不带 company_id 时超管拿到的是两家混在一起的目录(两排同名菜单),勾出来的 id 又会撞
|
||||
// 「无效的菜单权限项」。写侧(编辑/删除/重排)不带参数——归属由那一行的 id 与操作者公司共同判定,
|
||||
// 跨公司写后端 403(见 docs/ops/menu-company-tree-design-2026-10-06.md §5)。
|
||||
{ menuKey: 'admin_columns', apiFiles: ['src/pages/account/menu-manage-api.ts'], pageFiles: ['src/pages/account/MenusPage.vue'] },
|
||||
]
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,选中哪家由哪一枚 tab 带 is-active 表达——
|
||||
* 这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
||||
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,而且只画在**注册表里真的按公司取数的那些页**上——
|
||||
* 选中哪家由哪一枚 tab 带 is-active 表达,这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
||||
* 观感说明走 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 } from '@/layout/company-tab-model'
|
||||
|
||||
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)
|
||||
const show = computed(() => tab.visibleForOperator && companyTabAppliesTo(route.meta.menuKey))
|
||||
|
||||
watch(() => session.isSuperAdmin, (v) => {
|
||||
if (!v) return
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
/** 公司 tab 的两支纯函数(store 与护栏用例共用,不依赖 pinia / 组件)。
|
||||
/** 公司 tab 的三支纯函数(store 与护栏用例共用,不依赖 pinia / 组件)。
|
||||
* import 用相对路径 + 显式 `.ts`:本文件被 tests 以 `node --test` 直接 import,而测试侧没有
|
||||
* vite 的 `@` 别名解析器,写成 `@/api/...` 会 ERR_MODULE_NOT_FOUND(护栏因此读源码而非常规 import,
|
||||
* 见 tests/company-tab-wiring.test.ts 用 readSource 的原因)。 */
|
||||
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '../api/companies-dto.ts'
|
||||
import { COMPANY_SCOPED_PAGES } from '../config/company-scope.ts'
|
||||
|
||||
/** 参与公司隔离的页(注册表那份 menuKey 的集合形态)。判据**只有这一份来源**:
|
||||
* 另立一张"哪些页不画 tab"的黑名单,下一个新页会默认长出一条点了没反应的 tab(2026-10-06 的成因)。 */
|
||||
const SCOPED_MENU_KEYS: ReadonlySet<string> = new Set(COMPANY_SCOPED_PAGES.map((page) => page.menuKey))
|
||||
|
||||
/**
|
||||
* 这一页切了公司**有没有用**。与 store 的 `visibleForOperator` 是两个正交问题,不是同一问的两把尺子:
|
||||
* 那一条答「目录取到了吗、这名下有几家可切」,这一条答「当前这页吃不吃公司维度」。
|
||||
* 壳层把 tab 挂在所有页上时,公司管理页头顶就压着一排点了不重取数的 tab(控制方 2026-10-06 点名)。
|
||||
*/
|
||||
export function companyTabAppliesTo(menuKey: unknown): boolean {
|
||||
return typeof menuKey === 'string' && SCOPED_MENU_KEYS.has(menuKey)
|
||||
}
|
||||
|
||||
/** 超管的读范围公司。非超管恒 null——它的公司是固定的,下传一个常数只会让人以为这页在按公司筛。 */
|
||||
export function companyIdForRequest(isSuperAdmin: boolean, activeId: number | null): number | null {
|
||||
|
||||
@@ -21,7 +21,7 @@ export const OPERATION_GUIDE_STORAGE_KEY = 'shufuAdminGuideCollapsed'
|
||||
* (§12 第 5 条把那种提示条算未批的界面暴露;当前哪一家由 is-active 的 tab 表达,一处事实不留两处)。
|
||||
* 这句必须以「超级管理员」开头、不能写成祈使式的「由上方 tab 决定」:引导文案按 menuKey 取、
|
||||
* 不分支角色,而非超管根本看不到 tab 条(company-tab store 的 visibleForOperator 里有 isSuperAdmin)。
|
||||
* 这一句由参与 tab 的 13 页共用、不各抄一遍——文案差一个字,护栏就只盯得住其中一页。
|
||||
* 这一句由参与 tab 的 14 页共用、不各抄一遍——文案差一个字,护栏就只盯得住其中一页。
|
||||
* 由 tests/align-operation-guide.test.ts 的 guide_copy_carries_company_tab_note_for_every_scoped_page
|
||||
* 按 COMPANY_SCOPED_PAGES 逐页盯着(分母取注册表,加一页忘了补文案会当场红)。 */
|
||||
const COMPANY_TAB_GUIDE_NOTE = ' 超级管理员可用页面上方的公司 tab 切换公司,切换后行数会变化——行数变少不是数据丢了。'
|
||||
@@ -42,7 +42,10 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
steps: ['筛选账号', '编辑权限', '确认保存'],
|
||||
},
|
||||
admin_columns: {
|
||||
text: '菜单会影响后台和软件端的可见范围。先填写名称并选择对应页面,再设置上级菜单;顺序直接拖动列表左侧手柄调整。',
|
||||
// 2026-10-06 批次 6:V149 起每家公司一套菜单树 ⇒ 这页参与公司 tab,必须带上 §9.3 那句
|
||||
// (align-operation-guide 按注册表数分母,缺了它当场红)。
|
||||
text: '菜单会影响后台和软件端的可见范围。先填写名称并选择对应页面,再设置上级菜单;顺序直接拖动列表左侧手柄调整。'
|
||||
+ COMPANY_TAB_GUIDE_NOTE,
|
||||
steps: ['新增或调整菜单', '设置层级', '拖动排序'],
|
||||
},
|
||||
admin_group_manage: {
|
||||
@@ -69,7 +72,7 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
},
|
||||
admin_invalid_asin_data: {
|
||||
text: '维护不符合规则的 ASIN 或品牌。添加后可使用上方筛选快速回查。'
|
||||
+ COMPANY_TAB_GUIDE_NOTE,
|
||||
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||
steps: ['填写 ASIN/品牌', '选择分组', '保存并回查'],
|
||||
},
|
||||
admin_query_asin: {
|
||||
@@ -79,7 +82,7 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
},
|
||||
admin_product_categories: {
|
||||
text: '类目树支持展开查看层级。搜索、编辑和删除都在同一列表中完成。'
|
||||
+ COMPANY_TAB_GUIDE_NOTE,
|
||||
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||
steps: ['搜索类目', '展开层级', '新增或编辑'],
|
||||
},
|
||||
admin_skip_price_asin: {
|
||||
@@ -88,8 +91,10 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
steps: ['筛选店铺', '打开配置抽屉', '保存或批量导入'],
|
||||
},
|
||||
admin_shop_keys: {
|
||||
// 2026-10-06 批次 5:这页由「全平台共享」改按公司区分(V150 给 biz_shop_key 加 company_id),
|
||||
// 所以摘掉 COMPANY_SCOPE_NOT_APPLIED_NOTE、换上共用那一句 §9.3。
|
||||
text: '紫鸟令牌属于敏感配置。白名单状态可悬停查看检测详情,编辑前请先核对账号名称。'
|
||||
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||
+ COMPANY_TAB_GUIDE_NOTE,
|
||||
steps: ['新增或筛选密钥', '查看白名单状态', '编辑或删除'],
|
||||
},
|
||||
admin_shop_manage: {
|
||||
@@ -117,11 +122,13 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
steps: ['设置时间范围', '筛选记录', '查看结果预览'],
|
||||
},
|
||||
admin_version: {
|
||||
text: '上传版本后请核对版本号和下载链接,再通知用户更新。',
|
||||
text: '上传版本后请核对版本号和下载链接,再通知用户更新。'
|
||||
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||
steps: ['上传压缩包', '检查版本记录', '维护历史版本'],
|
||||
},
|
||||
admin_tutorial: {
|
||||
text: '上传新的教程压缩包后即刻生效:工具台首页「立即下载教程」以下载最新上传的包为准。确认旧包不再需要后再删除。',
|
||||
text: '上传新的教程压缩包后即刻生效:工具台首页「立即下载教程」以下载最新上传的包为准。确认旧包不再需要后再删除。'
|
||||
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||
steps: ['上传教程压缩包', '到工具台核对下载', '清理历史包'],
|
||||
},
|
||||
digital_human_version: {
|
||||
|
||||
@@ -155,7 +155,7 @@ async function create(): Promise<void> {
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" :company-id="form.companyId" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -9,7 +9,9 @@ import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
||||
|
||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean }>()
|
||||
/** companyId 由 UsersPage 把 companyTab.requestCompanyId 透传进来(本页的用户列表本来就由它筛 ⇒ 目标账号的公司
|
||||
* 就是 tab 选中的那家);弹窗自己不读 store,公司 tab 的取值口只留在页面组件那一处。 */
|
||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean; companyId?: number | null }>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'updated'): void }>()
|
||||
|
||||
const form = reactive<EditUserForm>({ uid: 0, username: '', password: '', role: 'normal', columnIds: [], originalRole: '', expiresAt: '' })
|
||||
@@ -48,7 +50,7 @@ async function refreshAuth(): Promise<void> {
|
||||
if (!props.user) return
|
||||
loadingAuth.value = true
|
||||
try {
|
||||
const { checkedIds } = await loadUserMenuAuth(props.user.id)
|
||||
const { checkedIds } = await loadUserMenuAuth(props.user.id, props.companyId)
|
||||
form.columnIds = checkedIds
|
||||
authReady.value = true
|
||||
} catch (error) {
|
||||
@@ -133,7 +135,7 @@ async function save(): Promise<void> {
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" :company-id="props.companyId" />
|
||||
<div v-if="loadingAuth" class="auth-loading">菜单权限加载中…</div>
|
||||
<div v-else-if="!authReady" class="auth-loading auth-loading-error">
|
||||
菜单权限加载失败,保存已禁用;请关闭后重试
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 菜单权限配置页 · 像素复刻旧版 admin.html panel-columns(自绘:面板头+新增菜单、拖拽手柄 ⠿、树形缩进+└、旧式表格、全量无分页同旧版)。
|
||||
* script 逻辑沿用现有 Vue 实现(拖拽分组/落点/重排保存、弹窗表单)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { createMenu, deleteMenu, loadMenuManageTree, reorderMenus, updateMenu } from './menu-manage-api'
|
||||
import {
|
||||
MENU_TYPE_OPTIONS,
|
||||
@@ -28,6 +29,7 @@ interface MenuRow extends MenuManageNode {
|
||||
depth: number
|
||||
}
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<MenuManageNode[]>([])
|
||||
/** 筛选:菜单名称/类型(用户要求账户域子菜单补筛选条件)。 */
|
||||
@@ -84,7 +86,7 @@ function parentNameOf(node: MenuManageNode): string {
|
||||
async function loadMenus() {
|
||||
loading.value = true
|
||||
try {
|
||||
rows.value = await loadMenuManageTree()
|
||||
rows.value = await loadMenuManageTree(companyTab.requestCompanyId)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '菜单列表加载失败')
|
||||
} finally {
|
||||
@@ -175,7 +177,7 @@ async function saveMenu() {
|
||||
await updateMenu(editingNode.value.id, menuForm)
|
||||
ElMessage.success('保存成功')
|
||||
} else {
|
||||
await createMenu(menuForm)
|
||||
await createMenu(menuForm, companyTab.requestCompanyId)
|
||||
ElMessage.success('创建成功')
|
||||
}
|
||||
createVisible.value = false
|
||||
@@ -204,6 +206,11 @@ async function removeMenu(node: MenuManageNode) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 切公司:菜单名称/类型是客户端筛选(在 filteredMenuRows 上筛,不进请求),留着上一家填的值
|
||||
* 就是拿别家的字符串去筛新一家那一套树 ⇒ 首屏「暂无匹配菜单」而输入框里还显示着它;页码回 1
|
||||
* 是因为新一家的行数不同。末尾的 void loadMenus() 才是本页唯一的数据出口。 */
|
||||
watch(() => companyTab.activeId, () => { filterName.value = ''; filterType.value = ''; page.value = 1; void loadMenus() })
|
||||
|
||||
onMounted(loadMenus)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { MenuOptionNode } from './user-menu-auth'
|
||||
import { compactDirectGrantIds } from './user-menu-auth'
|
||||
import { fetchGrantableMenus } from './user-menu-auth-api'
|
||||
|
||||
const props = defineProps<{ checked?: number[] }>()
|
||||
const props = defineProps<{ checked?: number[]; companyId?: number | null }>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:checked', ids: number[]): void
|
||||
(e: 'load', ok: boolean): void
|
||||
@@ -42,7 +42,7 @@ function onCheck(): void {
|
||||
|
||||
async function load(): Promise<void> {
|
||||
try {
|
||||
data.value = await fetchGrantableMenus()
|
||||
data.value = await fetchGrantableMenus(props.companyId)
|
||||
loaded.value = true
|
||||
emit('load', true)
|
||||
// el-tree 的 store 通过异步 watch 同步 props.data,setCheckedKeys 必须等树
|
||||
@@ -62,6 +62,12 @@ watch(
|
||||
if (loaded.value) applyChecked()
|
||||
},
|
||||
)
|
||||
/** 公司换了要整棵重取:勾选集里存的是 column id,别家同名菜单是另一份 id(V149 每公司一套树),
|
||||
* 拿别家的树勾出来的 id 提交会被后端判「无效的菜单权限项」,而已授权项也因为 id 不在这棵树上勾不上。 */
|
||||
watch(
|
||||
() => props.companyId,
|
||||
() => { void load() },
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -260,7 +260,7 @@ onMounted(() => {
|
||||
:company-options="companyOptions"
|
||||
@created="loadUsers"
|
||||
/>
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" @updated="loadUsers" />
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" :company-id="companyTab.requestCompanyId" @updated="loadUsers" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -14,20 +14,27 @@ import {
|
||||
export const MENUS_ENDPOINT = '/api/admin/permission-menus'
|
||||
export const REORDER_ENDPOINT = '/api/admin/column/reorder'
|
||||
|
||||
/** 拉取扁平可编辑菜单节点(全量类型,对齐 admin.js loadColumns 的 /api/admin/columns 语义)。 */
|
||||
export async function fetchMenuManageNodes(): Promise<MenuManageNode[]> {
|
||||
const { data } = await http.get<unknown>(MENUS_ENDPOINT)
|
||||
/** 拉取扁平可编辑菜单节点(全量类型,对齐 admin.js loadColumns 的 /api/admin/columns 语义)。
|
||||
* 公司 tab 的值由调用方(MenusPage)传 companyTab.requestCompanyId:菜单字典 2026-10-06 起每家公司一套树,
|
||||
* 不带 company_id 时非超管恒锁本公司、超管拿到的是全部公司的行(两排同名菜单)。 */
|
||||
export async function fetchMenuManageNodes(companyId?: number | null): Promise<MenuManageNode[]> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get<unknown>(MENUS_ENDPOINT, { params: query })
|
||||
return parseMenuManageList(data)
|
||||
}
|
||||
|
||||
/** 拉取并按 parentId 组装成展示树。 */
|
||||
export async function loadMenuManageTree(): Promise<MenuManageNode[]> {
|
||||
return buildMenuManageTree(await fetchMenuManageNodes())
|
||||
export async function loadMenuManageTree(companyId?: number | null): Promise<MenuManageNode[]> {
|
||||
return buildMenuManageTree(await fetchMenuManageNodes(companyId))
|
||||
}
|
||||
|
||||
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。 */
|
||||
export async function createMenu(form: MenuManageForm): Promise<MenuManageNode> {
|
||||
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form))
|
||||
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。
|
||||
* 归属由端点的 company_id 决定(缺省=操作者本公司),前端不靠从树里猜。 */
|
||||
export async function createMenu(form: MenuManageForm, companyId?: number | null): Promise<MenuManageNode> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form), { params: query })
|
||||
const created = parseMenuManageItem(unwrap<unknown>(data))
|
||||
if (!created) throw new Error('创建菜单响应异常:缺少菜单数据')
|
||||
return created
|
||||
|
||||
@@ -18,11 +18,18 @@ export const USER_PERMISSION_COLUMNS_ENDPOINT = '/api/admin/permission-users'
|
||||
/**
|
||||
* 拉取可授权菜单树(后台 admin + 前端客户端 app 两类合并,按 sort 排序)。
|
||||
* grantableOnly:非超管只拿到自己已持有的菜单,范围外的项后端不再下发。
|
||||
* <p>companyId 传 companyTab.requestCompanyId:2026-10-06 起每家公司一套菜单树,同一 column_key 在
|
||||
* 别家有一份**不同 id** 的副本。这一页的授权载荷提交的是 column id,树取错公司就等于
|
||||
* 把别家的 id 授给本公司账号(后端按「id 必须在被授权账号自己的树里」拒 ⇒ 保存必然失败,
|
||||
* 而已授权项因为 id 对不上树根本勾不上,看上去像"这个人一条权限都没有")。
|
||||
* null(非超管、或建号时没指定公司)由后端锁到操作者本公司。
|
||||
*/
|
||||
export async function fetchGrantableMenus(): Promise<MenuOptionNode[]> {
|
||||
export async function fetchGrantableMenus(companyId?: number | null): Promise<MenuOptionNode[]> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const [adminRes, appRes] = await Promise.all([
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { menuType: ADMIN_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { menuType: APP_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { ...query, menuType: ADMIN_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { ...query, menuType: APP_MENU_TYPE, grantableOnly: true } }),
|
||||
])
|
||||
const nodes = [
|
||||
...parseMenuOptionList(adminRes.data, ADMIN_MENU_TYPE),
|
||||
@@ -53,8 +60,8 @@ export interface UserMenuAuthData {
|
||||
checkedIds: number[]
|
||||
}
|
||||
|
||||
export async function loadUserMenuAuth(userId: number): Promise<UserMenuAuthData> {
|
||||
const [tree, checkedIds] = await Promise.all([fetchGrantableMenus(), fetchUserGrantedColumnIds(userId)])
|
||||
export async function loadUserMenuAuth(userId: number, companyId?: number | null): Promise<UserMenuAuthData> {
|
||||
const [tree, checkedIds] = await Promise.all([fetchGrantableMenus(companyId), fetchUserGrantedColumnIds(userId)])
|
||||
return { tree, checkedIds }
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { formatDateTime } from '@/utils/datetime'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { createInvalidAsin, deleteInvalidAsin, fetchInvalidAsinPage, updateInvalidAsin } from '../invalidasin/invalid-asin-api.ts'
|
||||
import type { InvalidAsinItem } from '../invalidasin/invalid-asin-model.ts'
|
||||
import { invalidAsinDeleteText, invalidAsinLockedGroupId, recordSourceLabel } from '../invalidasin/invalid-asin-model.ts'
|
||||
@@ -15,7 +14,6 @@ import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<InvalidAsinItem[]>([])
|
||||
const total = ref(0)
|
||||
@@ -46,7 +44,7 @@ const groupOptions = computed<ShopGroupOption[]>(() => {
|
||||
|
||||
async function loadGroups() {
|
||||
try {
|
||||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||||
groups.value = await fetchShopManageGroups()
|
||||
} catch {
|
||||
groups.value = []
|
||||
}
|
||||
@@ -65,7 +63,6 @@ async function load() {
|
||||
dataValue: filter.dataValue.trim() || undefined,
|
||||
brand: filter.brand.trim() || undefined,
|
||||
groupId: filter.groupId,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
@@ -163,10 +160,6 @@ watch(isSuperAdmin, () => {
|
||||
if (isSuperAdmin.value) filter.groupId = null
|
||||
})
|
||||
|
||||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||||
// groupId 必须一起清掉:上一家选中的分组在新一家根本不存在,留着会把切 tab 后的首屏筛成空列表。
|
||||
watch(() => companyTab.activeId, () => { filter.groupId = null; void loadGroups(); void load() })
|
||||
|
||||
onMounted(() => {
|
||||
loadGroups()
|
||||
load()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
/** 商品类目 · 像素复刻旧版 admin.html panel-product-categories(自绘:面板头搜索框组+新增类目 同行、原生树表格[+/−]折叠+懒加载「加载更多 已加载 x/y」、搜索态旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(懒加载树/编辑删除/导出/弹窗)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { fetchProductCategoryChildren, searchProductCategories } from './product-category-api.ts'
|
||||
import { createProductCategory, deleteProductCategory, updateProductCategory } from './product-category-editor-api.ts'
|
||||
@@ -17,9 +17,7 @@ import { categoryDraftError, createProductCategoryDraft, toCategorySaveRequest,
|
||||
import { buildProductCategoryExportUrl } from './product-category-export.ts'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const tree = ref<ProductCategoryNode[]>([])
|
||||
const keyword = ref('')
|
||||
@@ -70,7 +68,7 @@ const rootTotal = ref(0)
|
||||
async function loadTree(): Promise<void> {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value, companyTab.requestCompanyId)
|
||||
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value)
|
||||
const state = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
||||
childrenState.set(ROOT_KEY, state)
|
||||
// 顶层当前页直接作为树根(不含合成「加载更多」节点,翻页由 OldPagination 承担)。
|
||||
@@ -146,7 +144,7 @@ async function loadChildrenPage(parent: ProductCategoryNode | null, page: number
|
||||
if (state?.loading) return
|
||||
childrenState.set(key, { page: state?.page ?? 0, total: state?.total ?? 0, hasMore: state?.hasMore ?? false, loading: true })
|
||||
try {
|
||||
const result = await fetchProductCategoryChildren(parent?.id ?? null, page, PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE, companyTab.requestCompanyId)
|
||||
const result = await fetchProductCategoryChildren(parent?.id ?? null, page, PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE)
|
||||
const loaded = append ? (state?.page ?? 0) + result.items.length : result.items.length
|
||||
const nextState = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
||||
childrenState.set(key, nextState)
|
||||
@@ -197,7 +195,7 @@ function changeSearchSize(size: number) {
|
||||
async function runSearch(page: number): Promise<void> {
|
||||
searchLoading.value = true
|
||||
try {
|
||||
const result = await searchProductCategories(keyword.value, page, searchPageSize.value, companyTab.requestCompanyId)
|
||||
const result = await searchProductCategories(keyword.value, page, searchPageSize.value)
|
||||
searchRows.value = result.items
|
||||
searchTotal.value = result.total
|
||||
searchPage.value = result.page
|
||||
@@ -299,17 +297,13 @@ async function submit(): Promise<void> {
|
||||
|
||||
function exportCategories(): void {
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = buildProductCategoryExportUrl(keyword.value, companyTab.requestCompanyId)
|
||||
anchor.href = buildProductCategoryExportUrl(keyword.value)
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
ElMessage.success('类目导出已开始下载')
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数。childrenState/expandedIds 必须一起清:这两份是**上一家**的懒加载分页缓存与展开集,
|
||||
// 留着会把别家的子级行画进新一家的树里(同一个父级 id 在两家的子集不同),而请求本身是对的。
|
||||
watch(() => companyTab.activeId, () => { childrenState.clear(); expandedIds.value = new Set(); selected.value = null; rootPage.value = 1; void (searching.value ? runSearch(1) : loadTree()) })
|
||||
|
||||
onMounted(loadTree)
|
||||
</script>
|
||||
|
||||
@@ -332,14 +326,14 @@ onMounted(loadTree)
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 34%">类目</th>
|
||||
<th>层级路径</th>
|
||||
<th style="width: 90px">排序</th>
|
||||
<th style="width: 120px">来源</th>
|
||||
<th>备注</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 150px">操作</th>
|
||||
<th style="width: 220px">类目</th>
|
||||
<th style="width: 230px">层级路径</th>
|
||||
<th style="width: 66px">排序</th>
|
||||
<th style="width: 82px">来源</th>
|
||||
<th style="width: 170px">备注</th>
|
||||
<th style="width: 154px">创建时间</th>
|
||||
<th style="width: 154px">更新时间</th>
|
||||
<th style="width: 148px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-if="!searching">
|
||||
@@ -598,7 +592,10 @@ h3 {
|
||||
table-layout: fixed;
|
||||
}
|
||||
.category-table-scroll > table {
|
||||
min-width: 860px;
|
||||
/* table-layout:fixed 下,没写宽度的列在容器变窄时第一个被压到 0(10-06 截图:层级路径只剩一个字、
|
||||
备注只剩破折号)。承重的是 thead 里 8 列全部显式 px 定宽;这个下限与它们成对维护,
|
||||
数值由 tests/align-product-category.test.ts 从 markup 现算比对,改列宽要同时改这里。 */
|
||||
min-width: 1224px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/** 商品类目树/搜索适配(任务 78):GET /api/admin/product-categories(+keyword) 与 /product-categories/search。 */
|
||||
/** 商品类目树/搜索适配(任务 78):GET /api/admin/product-categories(+keyword) 与 /product-categories/search。
|
||||
* 2026-10-06 起这一页全平台共享:三个取数口都不带 company_id。 */
|
||||
import { http } from '@/api/http'
|
||||
import {
|
||||
parseProductCategoryList,
|
||||
@@ -11,10 +12,9 @@ import {
|
||||
export const PRODUCT_CATEGORY_ENDPOINT = '/api/admin/product-categories'
|
||||
|
||||
/** 拉取类目树(keyword 非空时由服务端过滤并保留父路径)。 */
|
||||
export async function fetchProductCategoryTree(keyword = '', companyId?: number | null): Promise<ProductCategoryListResult> {
|
||||
export async function fetchProductCategoryTree(keyword = ''): Promise<ProductCategoryListResult> {
|
||||
const trimmed = keyword.trim()
|
||||
const params: Record<string, string | number> = trimmed ? { keyword: trimmed } : {}
|
||||
if (companyId != null) params.company_id = companyId
|
||||
const { data } = await http.get<unknown>(PRODUCT_CATEGORY_ENDPOINT, { params })
|
||||
return parseProductCategoryList(data)
|
||||
}
|
||||
@@ -24,12 +24,10 @@ export async function searchProductCategories(
|
||||
keyword: string,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
companyId?: number | null,
|
||||
): Promise<ProductCategorySearchPage> {
|
||||
const params: Record<string, string | number> = { page, page_size: pageSize }
|
||||
const trimmed = keyword.trim()
|
||||
if (trimmed) params.keyword = trimmed
|
||||
if (companyId != null) params.company_id = companyId
|
||||
const { data } = await http.get<unknown>(`${PRODUCT_CATEGORY_ENDPOINT}/search`, { params })
|
||||
return parseProductCategorySearchPage(data)
|
||||
}
|
||||
@@ -47,11 +45,9 @@ export async function fetchProductCategoryChildren(
|
||||
parentId: number | null,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
companyId?: number | null,
|
||||
): Promise<ProductCategoryChildrenPage> {
|
||||
const params: Record<string, string | number> = { page, page_size: pageSize }
|
||||
if (parentId != null) params.parent_id = parentId
|
||||
if (companyId != null) params.company_id = companyId
|
||||
const { data } = await http.get<unknown>(`${PRODUCT_CATEGORY_ENDPOINT}/children`, { params })
|
||||
const parsed = parseProductCategorySearchPage(data)
|
||||
return { items: parsed.items, total: parsed.total, page: parsed.page, hasMore: parsed.hasMore }
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
export const PRODUCT_CATEGORY_EXPORT_ENDPOINT = '/api/admin/product-categories/export'
|
||||
|
||||
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载。
|
||||
* company_id 与列表同源:导出走的是同一个服务口径,不带它就是把别家类目写进同一份 XLSX。 */
|
||||
export function buildProductCategoryExportUrl(keyword: string, companyId?: number | null): string {
|
||||
* 与列表同源:导出走的是同一个服务口径。这一页 2026-10-06 起全平台共享,不带 company_id。 */
|
||||
export function buildProductCategoryExportUrl(keyword: string): string {
|
||||
const params: string[] = []
|
||||
const trimmed = (keyword || '').trim()
|
||||
if (trimmed) params.push(`keyword=${encodeURIComponent(trimmed)}`)
|
||||
if (companyId != null) params.push(`company_id=${companyId}`)
|
||||
return params.length ? `${PRODUCT_CATEGORY_EXPORT_ENDPOINT}?${params.join('&')}` : PRODUCT_CATEGORY_EXPORT_ENDPOINT
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ export interface InvalidAsinQuery {
|
||||
dataValue?: string
|
||||
brand?: string
|
||||
groupId?: number | null
|
||||
/** 公司 tab 的值;toQuery 是白名单构造、不点名它,所以由发送口从原始 query 读。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
function trimOrUndefined(value: unknown): string | undefined {
|
||||
@@ -31,11 +29,8 @@ function toQuery(query: InvalidAsinQuery): Record<string, string | number> {
|
||||
}
|
||||
|
||||
export async function fetchInvalidAsinPage(query: InvalidAsinQuery): Promise<InvalidAsinPageResult> {
|
||||
// 公司值落在 toQuery 之后、发请求之前的唯一一处:toQuery 是白名单构造(只点名 page/data_value/brand/group_id),
|
||||
// 所以这里必须从原始 query 读 companyId——从 toQuery 的结果里读是 undefined,请求照发、参数没有。
|
||||
const params = toQuery(query)
|
||||
if (query.companyId != null) params.company_id = query.companyId
|
||||
const { data } = await http.get<unknown>(INVALID_ASIN_ENDPOINT, { params })
|
||||
// 这一页 2026-10-06 起全平台共享:请求里不许出现 company_id(后端唯一键退回全局见 V151)。
|
||||
const { data } = await http.get<unknown>(INVALID_ASIN_ENDPOINT, { params: toQuery(query) })
|
||||
return parseInvalidAsinPage(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 店铺密钥管理页 · 像素复刻旧版 admin.html panel-shop-keys(自绘:面板头+新增店铺密钥、序号列、令牌掩码、白名单状态药丸+悬停详情、旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(编辑留空令牌=沿用);弹窗保留现有组件。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { fetchShopKeyList, submitCreateShopKey, updateShopKey, deleteShopKey, checkShopKeyWhitelist } from './shop-key-api.ts'
|
||||
import { emptyShopKeyForm, normalizeZiniaoToken, validateProxyUrl } from './shop-key-form-model.ts'
|
||||
import type { ShopKeyItem } from './shop-dto.ts'
|
||||
import { whitelistStatusMeta } from './shop-key-model.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref<ShopKeyItem[]>([])
|
||||
const total = ref(0)
|
||||
@@ -56,7 +58,11 @@ function whitelistTooltip(row: ShopKeyItem): string {
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await fetchShopKeyList({ page: page.value, pageSize: pageSize.value })
|
||||
const result = await fetchShopKeyList({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
page.value = result.page
|
||||
@@ -172,6 +178,8 @@ function goJump() {
|
||||
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
watch(() => companyTab.activeId, () => { filterKeyword.value = ''; page.value = 1; void load() })
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -81,10 +81,12 @@ export interface ShopGroupOption {
|
||||
leaderUsername?: string
|
||||
}
|
||||
|
||||
/** 店铺密钥列表分页参数(该接口只支持分页)。 */
|
||||
/** 店铺密钥列表分页参数(分页 + 公司 tab;归一是白名单构造,不点名 companyId)。 */
|
||||
export interface ShopKeyListParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 公司 tab 的值;normalizeKeyListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 店铺列表分页/筛选参数。 */
|
||||
@@ -100,6 +102,8 @@ export interface ShopManageListParams {
|
||||
export interface ShopKeyPageQuery {
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
||||
company_id?: number
|
||||
}
|
||||
|
||||
export interface ShopManagePageQuery {
|
||||
|
||||
@@ -19,7 +19,11 @@ export const SHOP_KEYS_ENDPOINT = '/api/admin/shop-keys'
|
||||
|
||||
export async function fetchShopKeyList(params: Partial<ShopKeyListParams> = {}): Promise<ShopKeyPageResult> {
|
||||
const normalized = normalizeKeyListParams(params)
|
||||
const { data } = await http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: toKeyPageQuery(normalized) })
|
||||
// normalizeKeyListParams 与 toKeyPageQuery 都是白名单构造(不点名 companyId),
|
||||
// 所以公司值只能从原始 params 读:写成 normalized.companyId 是 TS 绿、运行时恒 undefined。
|
||||
const query = toKeyPageQuery(normalized)
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: query })
|
||||
return parseShopKeyPage(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,26 +19,26 @@ export interface AdminPageDef extends AdminPageMeta {
|
||||
/** 业务域路由注册表(任务 8):首批 account 域;后续按业务域在此登记页面。 */
|
||||
export const adminPages: AdminPageDef[] = [
|
||||
{ path: 'account/users', menuKey: 'admin_users', title: '用户管理', companyScoped: true, load: () => import('@/pages/account/UsersPage.vue') },
|
||||
{ path: 'account/menus', menuKey: 'admin_columns', title: '菜单管理', load: () => import('@/pages/account/MenusPage.vue') },
|
||||
{ path: 'account/menus', menuKey: 'admin_columns', title: '菜单管理', companyScoped: true, load: () => import('@/pages/account/MenusPage.vue') },
|
||||
{ path: 'account/groups', menuKey: 'admin_group_manage', title: '数据权限分组', companyScoped: true, load: () => import('@/pages/account/GroupsPage.vue') },
|
||||
{ path: 'account/user-secrets', menuKey: 'admin_user_secrets', title: '密钥管理', companyScoped: true, load: () => import('@/pages/account/UserSecretsPage.vue') },
|
||||
{ path: 'account/user-secret-usage', menuKey: 'admin_user_secret_usage', title: '密钥用量统计', companyScoped: true, load: () => import('@/pages/account/UserSecretUsagePage.vue') },
|
||||
{ path: 'account/companies', menuKey: 'admin_companies', title: '公司管理', superAdminOnly: true, load: () => import('@/pages/account/CompaniesPage.vue') },
|
||||
{ path: 'shop-center/duplicate-check', menuKey: 'admin_shop_data_duplicate_check', title: '店铺撞款监控', companyScoped: true, load: () => import('@/pages/tasks/DuplicateCheckPage.vue') },
|
||||
{ path: 'shop-center/keys', menuKey: 'admin_shop_keys', title: '店铺密钥管理', companyScoped: false, load: () => import('@/pages/shop/ShopKeysPage.vue') },
|
||||
{ path: 'shop-center/keys', menuKey: 'admin_shop_keys', title: '店铺密钥管理', companyScoped: true, load: () => import('@/pages/shop/ShopKeysPage.vue') },
|
||||
{ path: 'shop-center/shops', menuKey: 'admin_shop_manage', title: '店铺管理', companyScoped: true, load: () => import('@/pages/shop/ShopManagePage.vue') },
|
||||
{ path: 'records/history', menuKey: 'admin_history', title: '生成记录', companyScoped: true, load: () => import('@/pages/records/RecordsHistoryPage.vue') },
|
||||
{ path: 'records/software-version', menuKey: 'admin_version', title: '软件版本管理', load: () => import('@/pages/records/RecordsSoftwareVersionPage.vue') },
|
||||
{ path: 'records/tutorial', menuKey: 'admin_tutorial', title: '教程管理', load: () => import('@/pages/records/RecordsTutorialPage.vue') },
|
||||
{ path: 'records/software-version', menuKey: 'admin_version', title: '软件版本管理', companyScoped: false, load: () => import('@/pages/records/RecordsSoftwareVersionPage.vue') },
|
||||
{ path: 'records/tutorial', menuKey: 'admin_tutorial', title: '教程管理', companyScoped: false, load: () => import('@/pages/records/RecordsTutorialPage.vue') },
|
||||
{ path: 'records/device-logs', menuKey: 'admin_device_logs', title: '日志管理', companyScoped: true, load: () => import('@/pages/records/DeviceLogsPage.vue') },
|
||||
{ path: 'task-center/board', menuKey: 'admin_task_center', title: '客户端任务管理', companyScoped: true, load: () => import('@/pages/task-center/TaskCenterBoardPage.vue') },
|
||||
{ path: 'records/digital-human-version', menuKey: 'digital_human_version', title: '数字人版本管理', load: () => import('@/pages/records/RecordsDigitalHumanVersionPage.vue') },
|
||||
{ path: 'records/image-video-tasks', menuKey: 'admin_image_video_tasks', title: '视频任务记录', companyScoped: true, load: () => import('@/pages/tasks/ImageVideoTasksPage.vue') },
|
||||
{ path: 'shop-center/data-tasks', menuKey: 'admin_shop_data_crawl_tasks', title: '店铺数据记录', companyScoped: true, load: () => import('@/pages/tasks/ShopDataTasksPage.vue') },
|
||||
{ path: 'asin-center/registry', menuKey: 'admin_dedupe_total_data', title: '数据去重总数据', companyScoped: true, load: () => import('@/pages/asin/DedupeRegistryPage.vue') },
|
||||
{ path: 'asin-center/invalid', menuKey: 'admin_invalid_asin_data', title: '不符合ASIN数据', companyScoped: true, load: () => import('@/pages/asin/AsinInvalidPage.vue') },
|
||||
{ path: 'asin-center/invalid', menuKey: 'admin_invalid_asin_data', title: '品牌数据库', companyScoped: false, load: () => import('@/pages/asin/AsinInvalidPage.vue') },
|
||||
{ path: 'asin-center/query', menuKey: 'admin_query_asin', title: '查询ASIN', companyScoped: true, load: () => import('@/pages/asin/QueryAsinPage.vue') },
|
||||
{ path: 'asin-center/categories', menuKey: 'admin_product_categories', title: '商品类目', companyScoped: true, load: () => import('@/pages/asin/ProductCategoryPage.vue') },
|
||||
{ path: 'asin-center/categories', menuKey: 'admin_product_categories', title: '商品类目', companyScoped: false, load: () => import('@/pages/asin/ProductCategoryPage.vue') },
|
||||
{ path: 'asin-center/skip-price', menuKey: 'admin_skip_price_asin', title: '最低价ASIN', companyScoped: true, load: () => import('@/pages/asin/SkipPricePage.vue') },
|
||||
]
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ test('guide_copy_carries_company_tab_note_for_every_scoped_page', () => {
|
||||
// 新页缺文案仍会红(operationGuideFor 对没登记的 key 返回 null ⇒ assert.ok(g) 当场红,没有兜底可糊)。
|
||||
const scopedKeys = COMPANY_SCOPED_PAGES.map((p) => p.menuKey)
|
||||
const need = scopedKeys.filter((k) => k !== EXCEPTED_KEY)
|
||||
assert.ok(need.length >= 15, `取样集非空自检:注册表今天有 ${scopedKeys.length} 页进了 tab 范围(批次 1 的 8 页 + 批次 2 的 5 页 + 批次 3 的 2 页 + 批次 4 的 1 页),减去唯一豁免页后只剩 ${need.length} 页`)
|
||||
assert.ok(need.length >= 15, `取样集非空自检:注册表今天有 ${scopedKeys.length} 页进了 tab 范围(批次 1 的 8 页 + 批次 2 剩下的 3 页 + 批次 3 的 2 页 + 批次 4 的 1 页 + 批次 5 的 1 页 + 批次 6 的 1 页),减去唯一豁免页后只剩 ${need.length} 页`)
|
||||
assert.ok(scopedKeys.includes(EXCEPTED_KEY),
|
||||
'取样集前提自检:撞款监控已不在 COMPANY_SCOPED_PAGES 里,上面那道豁免就成了空豁免——把它连同 EXCEPTED_KEY 一起删掉')
|
||||
for (const key of need) {
|
||||
@@ -101,11 +101,15 @@ test('guide_copy_carries_company_tab_note_for_every_scoped_page', () => {
|
||||
}
|
||||
// C 类页(spec §5):它们要的是**另一句**——"这页不参与",不是"会随 tab 变"。
|
||||
// 分母**取注册表里显式写 companyScoped:false 的页**,不抄名单:漏写一条 ⇒ 这支在自检那句红。
|
||||
// 批次 2 之前这里是 2 页(店铺密钥 + 商品类目),商品类目已接上公司口径 ⇒ 今天只剩 admin_shop_keys
|
||||
// 一条,所以自检降到 1;再往下掉就是有人把注册表里那条 false 改成不写(不写 = 不参与但没人说)。
|
||||
// 批次 2 之前这里是 2 页(店铺密钥 + 商品类目),商品类目一度接上了公司口径;
|
||||
// 2026-10-06 控制方定案「品牌数据库 / 商品类目 / 教程管理 / 软件版本管理都做成共享的,不区分」,
|
||||
// 于是这一族一度变成 5 页(店铺密钥 + 品牌库 + 商品类目 + 软件版本 + 教程);
|
||||
// 同日批次 5 又把店铺密钥改回按公司区分(V150 给 biz_shop_key 加 company_id),今天剩 4 页。
|
||||
// 后四页是**新登记**的:教程管理与软件版本管理的后端本来就没有公司引用,此前既不在清单也没写 false
|
||||
// =「不参与但没人说」,现在显式写出来,这句文案与下面那条 deepEqual 才盖得到它们。
|
||||
const scoped = new Set(COMPANY_SCOPED_PAGES.map((p) => p.menuKey))
|
||||
const cClass = adminPages.filter((p) => p.companyScoped === false).map((p) => p.menuKey)
|
||||
assert.ok(cClass.length >= 1, '取样集非空自检:注册表里显式 companyScoped:false 的一条都不剩了——那这句判据就是空跑')
|
||||
assert.ok(cClass.length >= 4, `取样集非空自检:注册表里显式 companyScoped:false 只剩 ${cClass.length} 页——那这句判据就是空跑`)
|
||||
for (const key of cClass) {
|
||||
assert.equal(scoped.has(key), false, `${key} 既声明 false 又在清单里,两处口径打架`)
|
||||
const g = operationGuideFor(key)
|
||||
|
||||
@@ -85,3 +85,63 @@ test('align_category_page_tree_and_search_wiring', () => {
|
||||
assert.match(page, /来源/, '搜索表格补来源列')
|
||||
assert.match(page, /childCount/, '删除按钮按有子禁用')
|
||||
})
|
||||
|
||||
/**
|
||||
* 列宽算术闸门(2026-10-06 控制方圈出:层级路径整列只剩一个字、备注只剩一个破折号)。
|
||||
* `.table-scroll table` 是 table-layout:fixed —— 首行 th 定宽后,列宽之和一旦超过表格实宽,
|
||||
* 浏览器把各列等比压缩,而没写宽度的 auto 列第一个被压到 0px。旧写法(类目 34% + 两个 auto 列 +
|
||||
* 700px 固定列)在表格宽度 < 1061px 时就是这么塌的;min-width 当时是 860px,比列宽之和还小,
|
||||
* 等于下限自己把塌缩区放进了合法区间。
|
||||
*
|
||||
* 闸门只认三条,其中真正承重的是前两条(浏览器实测,同一份 CSS 与真实 thead 生成的复现页):
|
||||
* 旧写法在表格宽度 1224px 时把 层级路径 与 备注 量成 0px,而 8 列全显式定宽后在 1920/1440/1100/900
|
||||
* 四档没有一列低于 90px —— 也就是"把 min-width 抬到 1224"单独并不能救旧写法,auto 列才是塌的那一根。
|
||||
* 第三条(min-width >= 列宽之和)管的是成对维护:加一列却忘了抬下限会直接红。
|
||||
* 求和从 markup 现算,不是抄常量——把某列从 220px 改成 400px 而忘了同步会直接红。
|
||||
* (注:单元格左右各 12px padding 是加在列宽之外的,所以渲染出的表格自然宽度是"列宽之和 + 24×8 = 1416px",
|
||||
* 与这里比对的 1224 不是同一个数,别混。)
|
||||
*/
|
||||
function categoryHeaderColumns(page: string): Array<{ label: string; px: number | null }> {
|
||||
const theadBlocks = page.match(/<thead>[\s\S]*?<\/thead>/g) ?? []
|
||||
assert.equal(theadBlocks.length, 1, '类目页应只有一个 thead(本闸门按单个表头求列宽之和)')
|
||||
const columns: Array<{ label: string; px: number | null }> = []
|
||||
for (const cell of theadBlocks[0].matchAll(/<th\b[^>]*>([^<]*)<\/th>/g)) {
|
||||
const style = cell[0].match(/style="([^"]*)"/)?.[1] ?? ''
|
||||
const px = /width:\s*(\d+)px/.exec(style)?.[1]
|
||||
columns.push({ label: cell[1].trim(), px: px === undefined ? null : Number(px) })
|
||||
}
|
||||
return columns
|
||||
}
|
||||
|
||||
function categoryTableMinWidth(page: string): number | null {
|
||||
const block = page.match(/\.category-table-scroll\s*>\s*table\s*\{([^}]*)\}/)?.[1] ?? ''
|
||||
const px = /min-width:\s*(\d+)px/.exec(block)?.[1]
|
||||
return px === undefined ? null : Number(px)
|
||||
}
|
||||
|
||||
test('align_category_fixed_layout_never_leaves_a_column_to_be_squeezed', () => {
|
||||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
// 前提也要钉:这条闸门只在 fixed 布局下成立,改成 auto 布局时它该喊,而不是安静地继续绿。
|
||||
// 窗口用 [^}] 而不是定长字符数:本页 CSS 注释里就写着 "table-layout:fixed 下……" 这句话,
|
||||
// 定长窗口能跨过 } 把注释喂成"前提成立"(变异自证时实测过一次 SURVIVED)。
|
||||
assert.match(page, /\.table-scroll\s+table\s*\{[^}]*table-layout:\s*fixed/, '本闸门的前提:表格是 table-layout:fixed')
|
||||
|
||||
const columns = categoryHeaderColumns(page)
|
||||
assert.equal(columns.length, 8, `表头应有 8 列(与 <td colspan="8"> 对齐),实际 ${columns.length}:${JSON.stringify(columns)}`)
|
||||
const unwidthed = columns.filter((c) => c.px === null).map((c) => c.label)
|
||||
assert.deepEqual(unwidthed, [], 'fixed 布局下没写宽度的列会在容器变窄时被第一个压到 0px:' + unwidthed.join('/'))
|
||||
assert.equal(/width:\s*\d+%/.test(page.match(/<thead>[\s\S]*?<\/thead>/)?.[0] ?? ''), false,
|
||||
'表头不许用百分比:百分比与 px 混排时列宽之和随表格宽度变,下限就无从比对')
|
||||
|
||||
const sum = columns.reduce((acc, c) => acc + (c.px ?? 0), 0)
|
||||
const minWidth = categoryTableMinWidth(page)
|
||||
assert.notEqual(minWidth, null, '.category-table-scroll > table 必须有 px 下限,否则塌缩区又合法了')
|
||||
assert.ok((minWidth ?? 0) >= sum,
|
||||
`min-width(${minWidth}px) 必须 >= 8 列宽度之和(${sum}px):否则表格落在 [min-width, 列宽和] 这一段时列被等比压缩`)
|
||||
|
||||
// 控制方圈出的那两列是这次的直接症状:它们是文字列,宽度下限给死,别被"重新调配比"顺手砍回去。
|
||||
for (const label of ['层级路径', '备注']) {
|
||||
const col = columns.find((c) => c.label === label)
|
||||
assert.ok(col && (col.px ?? 0) >= 120, `${label} 列宽不得低于 120px,实际 ${col?.px ?? '未定义'}px`)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -102,8 +102,18 @@ test('align_user_menu_grantable_wired_end_to_end', () => {
|
||||
)
|
||||
assert.match(
|
||||
controller,
|
||||
/permissionMenuService\.list\(requireAdmin\(request\), menuType, grantableOnly\)/,
|
||||
'列表接口传入操作者与授权树开关',
|
||||
/permissionMenuService\.resolveScopeCompanyId\(operator, companyId\)/,
|
||||
'列表接口先把请求里的 company_id 过一遍归属判据(非超管带别家当场 403),传下去的是判定结果而不是 tab 原文',
|
||||
)
|
||||
assert.match(
|
||||
controller,
|
||||
/permissionMenuService\.list\(\s*operator, menuType, grantableOnly, scopeCompanyId\s*\)/,
|
||||
'列表接口传入操作者、授权树开关与**已判定**的那一家(2026-10-06 每家公司一套树:授权树取错公司=已授权勾不上)',
|
||||
)
|
||||
assert.doesNotMatch(
|
||||
controller,
|
||||
/menuType, grantableOnly, companyId\s*\)/,
|
||||
'反向钉:不许把 tab 原文直接透传给 list(),否则"前端传什么都不算"这条口径在这一口断掉',
|
||||
)
|
||||
|
||||
const service = readSource(
|
||||
|
||||
@@ -88,8 +88,10 @@ test('吃公司 tab 的页面集合恰好等于 COMPANY_SCOPED_PAGES 的 pageFil
|
||||
.filter((rel) => readSource(rel).includes(STORE_USE_TOKEN))
|
||||
.sort()
|
||||
const declared = COMPANY_SCOPED_PAGES.flatMap((entry) => entry.pageFiles).sort()
|
||||
assert.ok(declared.length >= 16, `清单的 pageFiles 只剩 ${declared.length} 条 ⇒ 分母被删空,深比较会退化成空集自比`)
|
||||
assert.ok(consumers.length >= 16, `真实消费者只有 ${consumers.length} 页 ⇒ 扫描谓词(${STORE_USE_TOKEN})或页面文件本身出了问题`)
|
||||
// 分母 15 = 今天注册表的 pageFiles 条数(批次 1 的 8 + 批次 2 剩下的 3 + 批次 3 的 2 + 批次 4 的 1 + 批次 5 的 1;
|
||||
// 品牌库与商品类目 2026-10-06 退回全平台共享后不在其中,见 company-tab-wiring 末尾那条反向钉)。
|
||||
assert.ok(declared.length >= 15, `清单的 pageFiles 只剩 ${declared.length} 条 ⇒ 分母被删空,深比较会退化成空集自比`)
|
||||
assert.ok(consumers.length >= 15, `真实消费者只有 ${consumers.length} 页 ⇒ 扫描谓词(${STORE_USE_TOKEN})或页面文件本身出了问题`)
|
||||
assert.deepEqual(consumers, declared,
|
||||
'公司 tab 的消费者与清单对不上:多出来的一页=悄悄给一页不参与隔离的页上了 tab(公司管理就属于这类),'
|
||||
+ '少掉的一页=清单声明它隔离但页面根本没取值')
|
||||
|
||||
@@ -48,9 +48,10 @@ test('剪枝是纯函数且幂等(store 里会反复调用)', () => {
|
||||
test('不参与 tab 的页必须显式声明 companyScoped: false(spec §5:声明,不是遗漏)', () => {
|
||||
// 留空和 false 运行时等价,但只有 false 是"读过普查、决定不参与"的证据。
|
||||
// 名单批次 1 是两页(店铺密钥 + 商品类目);商品类目在批次 2(2026-10-05)接上了公司口径,
|
||||
// 今天只剩紫鸟令牌这一页真的是"全平台共享、与公司无关"。
|
||||
// 2026-10-06 控制方定案品牌库/教程管理/软件版本管理一律全平台共享,同日批次 5 又把店铺密钥
|
||||
// 改回按公司区分(V150)⇒ 今天这一族是 4 页,一句「与公司无关」都没写给它们的页不许进这张表。
|
||||
// 想再往这页上加 false 的对向(把某页改回 false)不用改这里:上面那条双向对账会红。
|
||||
for (const key of ['admin_shop_keys']) {
|
||||
for (const key of ['admin_invalid_asin_data', 'admin_product_categories', 'admin_version', 'admin_tutorial']) {
|
||||
const page = adminPages.find((p) => p.menuKey === key)
|
||||
assert.ok(page, `注册表里找不到 ${key}`) // 取样非空自检
|
||||
assert.equal(page.companyScoped, false, `${key} 必须显式写 companyScoped: false,不能留空`)
|
||||
|
||||
@@ -4,6 +4,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
||||
import { occurrences, readSource } from './helpers.ts'
|
||||
import { adminPages } from '../src/router/routes.ts'
|
||||
import { COMPANY_SCOPED_PAGES, SUPER_ADMIN_ONLY_MENU_KEYS } from '../src/config/company-scope.ts'
|
||||
import { companyTabAppliesTo } from '../src/layout/company-tab-model.ts'
|
||||
|
||||
const read = (p: string) => {
|
||||
assert.ok(existsSync(p), `护栏读不到 ${p}:api 文件改名了,清单必须同步(别把用例改成"不存在就跳过")`)
|
||||
@@ -69,9 +70,12 @@ function escapeRegExp(text: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部 22 个字面发送口:批次 1 的任务看板 5 处 + 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页)12 处
|
||||
* 全部 21 个字面发送口:批次 1 的任务看板 5 处 + 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页)7 处
|
||||
* + 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」那两页)4 处
|
||||
* + 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」里的用户管理)1 处。
|
||||
* + 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」里的用户管理)1 处
|
||||
* + 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)1 处
|
||||
* + 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」)3 处:菜单目录 / 新建菜单 / 用户管理里的授权树。
|
||||
* 批次 2 原 12 处里的品牌库 1 处 + 商品类目 4 处,随 2026-10-06「这两页退回全平台共享」一并摘掉。
|
||||
*
|
||||
* <p>`window` 的取法:本轮实扫的 own(到自己那行的距离)+ ≥150 余量,且当同文件还有下一个同名发送口时必须
|
||||
* `window < next`。own/next 不写死在这里——下面「窗口与真文件对平」那条用例逐处从真文件重算,
|
||||
@@ -94,15 +98,10 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
|
||||
{ menuKey: 'admin_dedupe_total_data', file: 'src/pages/asin/dedupe-total-api.ts', fn: 'fetchDedupeTotalList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 400, title: 'GET /dedupe-total-data 列表' },
|
||||
{ menuKey: 'admin_dedupe_total_data', file: 'src/pages/asin/dedupe-total-api.ts', fn: 'fetchDedupeTotalGroups', line: 'http.get<unknown>(DEDUPE_GROUPS_ENDPOINT, { params: companyId != null ? { company_id: companyId } : {} })', window: 400, title: 'GET /shop-manages/groups 分组候选(与店铺管理同源,两页口径要对得上)' },
|
||||
{ menuKey: 'admin_dedupe_total_data', file: 'src/pages/asin/dedupe-total-export.ts', fn: 'buildDedupeExportParams', line: 'if (companyId != null) params.company_id = String(companyId)', window: 800, title: 'GET /dedupe-total-data/export 导出' },
|
||||
{ menuKey: 'admin_invalid_asin_data', file: 'src/pages/invalidasin/invalid-asin-api.ts', fn: 'fetchInvalidAsinPage', line: 'if (query.companyId != null) params.company_id = query.companyId', window: 400, title: 'GET /invalid-asin-data 列表(品牌数据库)' },
|
||||
{ menuKey: 'admin_query_asin', file: 'src/pages/asin/query-asin-api.ts', fn: 'fetchQueryAsinList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 400, title: 'GET /query-asins 列表' },
|
||||
{ menuKey: 'admin_query_asin', file: 'src/pages/asin/query-asin-export.ts', fn: 'buildQueryAsinExportParams', line: 'if (companyId != null) params.company_id = String(companyId)', window: 700, title: 'GET /query-asins/export 导出' },
|
||||
{ menuKey: 'admin_skip_price_asin', file: 'src/pages/asin/skip-price-api.ts', fn: 'fetchSkipPriceList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 400, title: 'GET /skip-price-asins 列表(最低价 ASIN)' },
|
||||
{ menuKey: 'admin_skip_price_asin', file: 'src/pages/asin/skip-price-export.ts', fn: 'buildSkipPriceExportParams', line: 'if (companyId != null) params.company_id = String(companyId)', window: 1000, title: 'GET /skip-price-asins/export 导出(本批新建:原先 href 不带任何参数=恒导全平台)' },
|
||||
{ menuKey: 'admin_product_categories', file: 'src/pages/asin/product-category-api.ts', fn: 'fetchProductCategoryTree', line: 'if (companyId != null) params.company_id = companyId', window: 450, title: 'GET /product-categories 类目树' },
|
||||
{ menuKey: 'admin_product_categories', file: 'src/pages/asin/product-category-api.ts', fn: 'searchProductCategories', line: 'if (companyId != null) params.company_id = companyId', window: 450, title: 'GET /product-categories/search 搜索' },
|
||||
{ menuKey: 'admin_product_categories', file: 'src/pages/asin/product-category-api.ts', fn: 'fetchProductCategoryChildren', line: 'if (companyId != null) params.company_id = companyId', window: 450, title: 'GET /product-categories/children 懒加载子级' },
|
||||
{ menuKey: 'admin_product_categories', file: 'src/pages/asin/product-category-export.ts', fn: 'buildProductCategoryExportUrl', line: 'if (companyId != null) params.push(`company_id=${companyId}`)', window: 400, title: 'GET /product-categories/export 导出(字符串拼接而非对象,锚整条 push)' },
|
||||
// ↓ 批次 3 的两页(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。
|
||||
// 撞款三处各锚一个左值名(query/params/itemsQuery),店铺数据记录一处。
|
||||
{ menuKey: 'admin_shop_data_duplicate_check', file: 'src/pages/tasks/duplicate-console-api.ts', fn: 'fetchDuplicateConsole', line: 'if (companyId != null) query.company_id = companyId', window: 400, title: 'GET /duplicate-check-console 指标/店铺/撞款全集/分组统计' },
|
||||
@@ -111,6 +110,16 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
|
||||
{ menuKey: 'admin_shop_data_crawl_tasks', file: 'src/pages/tasks/shop-data-api.ts', fn: 'fetchShopDataTaskList', line: 'if (companyId != null) query.company_id = companyId', window: 400, title: 'GET /shop-data-crawl-tasks 店铺数据记录列表' },
|
||||
// ↓ 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
|
||||
{ menuKey: 'admin_users', file: 'src/api/users.ts', fn: 'fetchUserList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 400, title: 'GET /users 用户列表(后端早就认这个参数,断的是前端没发)' },
|
||||
// ↓ 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。
|
||||
{ menuKey: 'admin_shop_keys', file: 'src/pages/shop/shop-key-api.ts', fn: 'fetchShopKeyList', line: 'if (params.companyId != null) query.company_id = params.companyId', window: 400, title: 'GET /shop-keys 紫鸟令牌列表(不带 company_id 时非超管仍由后端会话裁剪,超管点了 tab 才会变)' },
|
||||
// ↓ 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分,现在的默认归到 admin 下」,定案「每家公司一套树」)。
|
||||
// 三处都锚同一串 TASK_CENTER_SEND_LINE,但分属两个文件 ⇒ (文件, 整行) 分组各成一组,钉数与条数仍逐处对平。
|
||||
// 窗口取 300:两处 menu-manage 的 own 是 110/130,而 fetchMenuManageNodes 到 createMenu 那行的 next 是 611
|
||||
// ⇒ 300 够得着自己、够不到隔壁(这三个数由下面「窗口与真文件对平」那条用例逐处从真文件重测,注释过期即红)。
|
||||
// user-menu-auth-api 那处一条发送口喂两个 GET(admin/app 两类各一支,共用同一个 query 展开)⇒ 一函数一钉。
|
||||
{ menuKey: 'admin_columns', file: 'src/pages/account/menu-manage-api.ts', fn: 'fetchMenuManageNodes', line: TASK_CENTER_SEND_LINE, window: 300, title: 'GET /permission-menus 目录(超管不带就把两家的同名行混成一排下发)' },
|
||||
{ menuKey: 'admin_columns', file: 'src/pages/account/menu-manage-api.ts', fn: 'createMenu', line: TASK_CENTER_SEND_LINE, window: 300, title: 'POST /permission-menus 新建:归属由端点参数决定,前端不从树里猜' },
|
||||
{ menuKey: 'admin_users', file: 'src/pages/account/user-menu-auth-api.ts', fn: 'fetchGrantableMenus', line: TASK_CENTER_SEND_LINE, window: 300, title: 'GET /permission-menus?grantableOnly 授权树:一家一套树后取错公司=已授权勾不上、提交必判无效' },
|
||||
]
|
||||
|
||||
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径)。 */
|
||||
@@ -206,17 +215,24 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
|
||||
note: '列表窄了而下拉不窄 = 两页口径对不上,且下拉能选到别家的组',
|
||||
},
|
||||
],
|
||||
// 批次 2 的五页:取值口钉全部由 SEND_POINTS 现算(一页几处发送口就几条钉),
|
||||
// 批次 2 剩下的三页:取值口钉全部由 SEND_POINTS 现算(一页几处发送口就几条钉),
|
||||
// 手写一份就会和表漂开——那正是复评 I-1 拆条要避免的形状。
|
||||
// admin_invalid_asin_data / admin_product_categories 两页 2026-10-06 退回全平台共享,
|
||||
// 已不在注册表里 ⇒ 这里的条目一并摘掉(留着是死表项,"不得回流"由文件末尾那条反向钉看守)。
|
||||
admin_dedupe_total_data: pinsFor('admin_dedupe_total_data'),
|
||||
admin_invalid_asin_data: pinsFor('admin_invalid_asin_data'),
|
||||
admin_query_asin: pinsFor('admin_query_asin'),
|
||||
admin_skip_price_asin: pinsFor('admin_skip_price_asin'),
|
||||
admin_product_categories: pinsFor('admin_product_categories'),
|
||||
// 批次 3 的两页同样由 SEND_POINTS 现算(撞款控制台三处发送口 = 三条钉)。
|
||||
admin_shop_data_duplicate_check: pinsFor('admin_shop_data_duplicate_check'),
|
||||
admin_shop_data_crawl_tasks: pinsFor('admin_shop_data_crawl_tasks'),
|
||||
admin_users: pinsFor('admin_users'),
|
||||
// 批次 5(店铺密钥)同样由 SEND_POINTS 现算:这一页只有一个发送口(列表),
|
||||
// 新增/编辑/删除/白名单检测四支都不带公司参数——归属由后端从操作者会话推导(writeCompanyId 闸门)。
|
||||
admin_shop_keys: pinsFor('admin_shop_keys'),
|
||||
// 批次 6(菜单权限):菜单目录 + 新建两处,都由 SEND_POINTS 现算。
|
||||
// 编辑/删除/重排三支**故意不带**参数——归属由那一行的 id 与操作者公司共同判定,跨公司写后端 403
|
||||
// (见 docs/ops/menu-company-tree-design-2026-10-06.md §5),给它们发 company_id 反而是第三处口径。
|
||||
admin_columns: pinsFor('admin_columns'),
|
||||
}
|
||||
|
||||
/** 严格判据的分母由本轮实扫得出(修完不许恒绿也不许恒红):求值了几条 shape、其中几条通过。 */
|
||||
@@ -303,11 +319,13 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
|
||||
// 不许让另一支用例替我证明"这串本来就会被匹配到")。
|
||||
// ⚠ 身份要说清:下面这几条是对**字面量字符串**求值的探针,只证明判据形状没写坏
|
||||
// (正样本匹配得出 ⇒ 不恒红;窗口外的负样本不匹配 ⇒ 窗口真有界,删一处不会靠隔壁过关),
|
||||
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那 17 条 shape 对真实文件的求值 + 变异自证。
|
||||
// ⚠ 分母是本轮实扫的表条数(批次 1 的 5 + 批次 2 的 12 + 批次 3 的 4 + 批次 4 的 1)。这条只防"整表被摘空/被改窄",
|
||||
// 逐处脱管由下面两条(对平闸门 + 窗口对平)负责。
|
||||
assert.ok(SEND_POINTS.length >= 22,
|
||||
`发送口表只剩 ${SEND_POINTS.length} 条(批次 1+2+3+4 实扫 22 条)⇒ 有人把钉从表里摘了,取值口看守成空`)
|
||||
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那批 shape(条数由 strictPinsEvaluated 当场自证)
|
||||
// 对真实文件的求值 + 变异自证。
|
||||
// ⚠ 分母是本轮实扫的表条数(批次 1 的 5 + 批次 2 的 7 + 批次 3 的 4 + 批次 4 的 1 + 批次 5 的 1 + 批次 6 的 3;
|
||||
// 批次 2 原 12 条里的品牌库 1 条 + 商品类目 4 条随 2026-10-06「这两页退回全平台共享」摘掉)。
|
||||
// 这条只防"整表被摘空/被改窄",逐处脱管由下面两条(对平闸门 + 窗口对平)负责。
|
||||
assert.ok(SEND_POINTS.length >= 21,
|
||||
`发送口表只剩 ${SEND_POINTS.length} 条(批次 1+2+3+4+5+6 实扫 21 条)⇒ 有人把钉从表里摘了,取值口看守成空`)
|
||||
for (const p of SEND_POINTS) {
|
||||
const shape = pointShape(p)
|
||||
const compliant = pointCompliant(p)
|
||||
@@ -330,7 +348,7 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
|
||||
// 这一条杀的是「把 TASK_CENTER_SEND_POINTS 删剩 4 行」——少一条钉就等于少一处看守,而 5 条 shape 谁都不会红。
|
||||
// 路线 ②(occurrences 计数)在这里只当"钉数与发送口条数对平"的闸门,不当"是哪一处"的判据:
|
||||
// 计数回答不了"哪三处"(把一处重复写三遍、另一处删掉,计数照样对平),所以主判据仍是路线 ① 的函数名锚 + 有界窗口。
|
||||
// 分母按 (文件, 整行) 而不是按文件:批次 2 的 product-category-api.ts 一个文件三处发送口、三处是逐字同一行,
|
||||
// 分母按 (文件, 整行) 而不是按文件:任务看板的 task-center.ts 一个文件三处发送口、三处是逐字同一行,
|
||||
// 按文件计只钉得出"3 条"这个数,按行计才和 occurrences 同一粒度;三个 *-export.ts 的行各只出现 1 次,同理。
|
||||
const grouped = new Map<string, { readonly file: string; readonly line: string; pinned: number }>()
|
||||
for (const p of SEND_POINTS) {
|
||||
@@ -340,7 +358,7 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
|
||||
else grouped.set(key, { file: p.file, line: p.line, pinned: 1 })
|
||||
}
|
||||
assert.equal(grouped.size, 17,
|
||||
`发送口表按 (文件, 整行) 应聚成 17 组(22 处发送口),现在却有 ${grouped.size} 组 —— 表被改形状了,对平判据失去分母`)
|
||||
`发送口表按 (文件, 整行) 应聚成 17 组(21 处发送口),现在却有 ${grouped.size} 组 —— 表被改形状了,对平判据失去分母`)
|
||||
for (const g of grouped.values()) {
|
||||
const actual = occurrences(stripComments(read(g.file)), g.line)
|
||||
assert.equal(g.pinned, actual,
|
||||
@@ -357,7 +375,8 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
|
||||
// own = 从 `function <fn>(` 的括号后到自己那一行的距离 ⇒ 必须 < window(函数体写长 = 假红,fail-closed 可接受);
|
||||
// next = 到同文件**下一条同名发送行**开头的距离 ⇒ 存在时必须 > window(否则删一处还有隔壁顶着,这条钉就是摆设)。
|
||||
// 隔壁的"名字"用的是自己的整行,所以 next 只在同文件有逐字同行的另一处时才有意义:
|
||||
// product-category-api.ts 三处同行(next 实测 705/929/无)是这一族唯一的真冲突面,其余 14 处 own 唯一。
|
||||
// product-category-api.ts 那组(三处同行)2026-10-06 随「商品类目退回全平台共享」摘掉了;
|
||||
// 这一族剩下的真冲突面只有任务看板:task-center.ts 三处逐字同行、task-center-model.ts 两处,其余各文件唯一。
|
||||
for (const p of SEND_POINTS) {
|
||||
const src = stripComments(read(p.file))
|
||||
const anchor = 'function ' + p.fn + '('
|
||||
@@ -477,6 +496,48 @@ test('发送口的第二实参:task-center 五处 http.get 必须把 query 交
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 1b ④ 的那一半缺口(批次 5 补,2026-10-06 变异自证 M9 实测存活):上面那支按**端点 URL 字面量**锚,
|
||||
* 取样文件只有 `src/api/task-center.ts`。店铺密钥这一页的 GET 写的是 `http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: query })`
|
||||
* ——端点是模块常量、调用还带泛型,那条正则两头都锚不到。把 `{ params: query }` 整段删掉后,
|
||||
* `if (params.companyId != null) query.company_id = params.companyId` 那一行逐字还在 ⇒ 取值口五判据全绿、
|
||||
* 编译器一声不响、URL 里没有 company_id:正是 1b ④ 当初要杀的那一形,只是换了一个文件。
|
||||
*
|
||||
* <p>判据换成「整行字面量 + 同文件 GET 总条数对平」:锚整行是因为常量名就是这一处的稳定身份,
|
||||
* 对平是因为只钉一行的话,第二处新 GET 忘了带 params 也照样没人红(与上面「同一 URL 只许一处调用」同理)。</p>
|
||||
*/
|
||||
const CONSTANT_ENDPOINT_GET_PINS: ReadonlyArray<{ readonly file: string; readonly fn: string; readonly call: string }> = [
|
||||
{ file: 'src/pages/shop/shop-key-api.ts', fn: 'fetchShopKeyList', call: 'http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: query })' },
|
||||
]
|
||||
|
||||
test('非字面量端点的发送口:query 必须交给带 params 的第二实参,且同文件 GET 条数与登记表对平(1b ④ 的另一半)', () => {
|
||||
assert.ok(CONSTANT_ENDPOINT_GET_PINS.length >= 1, '常量端点登记表为空 ⇒ 这一族的第二实参没人看守')
|
||||
const byFile = new Map<string, number>()
|
||||
for (const p of CONSTANT_ENDPOINT_GET_PINS) byFile.set(p.file, (byFile.get(p.file) ?? 0) + 1)
|
||||
for (const p of CONSTANT_ENDPOINT_GET_PINS) {
|
||||
const src = stripComments(read(p.file))
|
||||
// ① 判据自证(正样本):登记的那一行本身必须含 params,否则下面的对平是在钉一个坏形状。
|
||||
assert.ok(p.call.includes(', { params'), `登记表里「${p.call}」不含 params 第二实参 ⇒ 这条判据恒红`)
|
||||
// ② 判据自证(负样本):删掉第二实参后必须匹配不出自己,否则"带没带 params"都算过。
|
||||
assert.equal(p.call.replace(', { params: query }', '').includes(p.call), false,
|
||||
`删掉 { params: query } 之后「${p.call}」仍然自匹配 ⇒ 判据只看得到端点,杀不了这一记变异`)
|
||||
// ③ 函数身份:这一处 GET 必须由它自己的函数发出。
|
||||
assert.equal(occurrences(src, `function ${p.fn}(`), 1,
|
||||
`${p.file} 里「function ${p.fn}(」出现 ${occurrences(src, `function ${p.fn}(`)} 次(要求 1):函数改名或被复制,这一行锚对不上是谁发的`)
|
||||
// ④ 真文件求值:这一行必须逐字在场一次。
|
||||
const hits = occurrences(src, p.call)
|
||||
assert.equal(hits, 1,
|
||||
`${p.file} 里带 params 实参的「${p.call}」匹配到 ${hits} 处(要求 1):`
|
||||
+ '0 处 = 发送口把 query 丢了(后端收不到 company_id、接口照旧 200、切 tab 一动不动),多于 1 处 = 有第二处同形调用没人钉')
|
||||
}
|
||||
// ⑤ 同文件 GET 总条数对平:新增一处 http.get 而没登记 ⇒ 当场红,不留"新那处还没人管"的默认分支。
|
||||
for (const [file, pinned] of byFile) {
|
||||
const src = stripComments(read(file))
|
||||
const actual = occurrences(src, 'http.get')
|
||||
assert.equal(actual, pinned,
|
||||
`${file} 实扫到 ${actual} 处 http.get,登记表只有 ${pinned} 条 —— 有一处 GET 的第二实参没人看守`)
|
||||
}
|
||||
})
|
||||
test('反向:把 company_id 当查询参数用的取数模块必须被清单认领(防止"筛了但没人知道这页参与")', () => {
|
||||
const claimed = new Set(COMPANY_SCOPED_PAGES.flatMap((p) => p.apiFiles))
|
||||
const scanned = requestModules()
|
||||
@@ -506,7 +567,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
|
||||
* 症状回到裁决 1 想避免的那一型。</p>
|
||||
*
|
||||
* <p>判据形状:从 `watch(() => companyTab.activeId, …)` 那**一条语句**取文本(正则在第一个
|
||||
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;表里这九页今天都没有那种写法,由下面的取样自检兜着)。
|
||||
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;表里这十页今天都没有那种写法,由下面的取样自检兜着)。
|
||||
* 反向钉与正样本同支(全局约束 15,三条前提不成立就是探针失效、当场红,不许静默空跑),**每一对**都各跑一遍:
|
||||
* ① 合规样本必须匹配得出且含两把 token ⇒ 判据不恒红;
|
||||
* ② 删掉那一句的样本必须不含 ⇒ 判据能红(变异自证走的就是这一条);
|
||||
@@ -521,7 +582,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
|
||||
const WATCH_ACTIVE_ID = /watch\(\(\)\s*=>\s*companyTab\.activeId\s*,\s*\(\)\s*=>\s*\{([\s\S]*?)\}\s*\)/
|
||||
|
||||
/**
|
||||
* (文件, 必须出现在 watch 体内的赋值) 九对,同一条 test 里逐对钉(批次 1 两对 + 批次 2 五对 + 批次 3 两对)。
|
||||
* (文件, 必须出现在 watch 体内的赋值) 十对,同一条 test 里逐对钉(批次 1 两对 + 批次 2 三对 + 批次 3 两对 + 批次 4 一对 + 批次 5 一对 + 批次 6 一对)。
|
||||
* `premise` 是这一对的反向钉前提:这一页的发送口今天还在发 `company_id`,清筛选项才有意义;
|
||||
* 哪天发送口退回不带参,watch 看守就变成"清了一个没人用的筛选项",必须一起红。
|
||||
*/
|
||||
@@ -551,7 +612,8 @@ const WATCH_BODY_PINS: ReadonlyArray<{
|
||||
{ file: 'src/pages/task-center/task-center-model.ts', shapes: [/company_id\s*=\s*companyId\b/] },
|
||||
],
|
||||
},
|
||||
// ↓ 批次 2 的五页(控制方 2026-10-05 点名「切 tab 数据还一样」那一批)。
|
||||
// ↓ 批次 2 剩下的三页(控制方 2026-10-05 点名「切 tab 数据还一样」那一批;
|
||||
// 品牌库、商品类目两页 2026-10-06 退回全平台共享,条目一并摘掉)。
|
||||
// token 在两页上同形(`filter.groupId = null` 出现三次),这**不是**漏洞:判据按 (file, token) 成对求值,
|
||||
// 每一对都各自去读它自己那一页的源码,别家页缺了这行不会红在这一页,反之这一页删掉了也不会被隔壁顶住
|
||||
// (负样本 ③「挪到 watch 之外」钉的就是位置)。
|
||||
@@ -563,14 +625,6 @@ const WATCH_BODY_PINS: ReadonlyArray<{
|
||||
{ file: 'src/pages/asin/dedupe-total-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
|
||||
],
|
||||
},
|
||||
{
|
||||
file: 'src/pages/asin/AsinInvalidPage.vue',
|
||||
token: 'filter.groupId = null',
|
||||
why: '品牌库的分组下拉按公司收窄,留着上一家的 groupId 就是拿一个新一家看不见的组去筛列表',
|
||||
premise: [
|
||||
{ file: 'src/pages/invalidasin/invalid-asin-api.ts', shapes: [/company_id\s*=\s*query\.companyId\b/] },
|
||||
],
|
||||
},
|
||||
{
|
||||
file: 'src/pages/asin/QueryAsinPage.vue',
|
||||
token: "filter.groupId = null; filter.shopName = ''",
|
||||
@@ -588,15 +642,6 @@ const WATCH_BODY_PINS: ReadonlyArray<{
|
||||
{ file: 'src/pages/asin/skip-price-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
|
||||
],
|
||||
},
|
||||
{
|
||||
file: 'src/pages/asin/ProductCategoryPage.vue',
|
||||
token: 'childrenState.clear()',
|
||||
why: '类目树是**懒加载缓存**:childrenState 里存着上一家每个父级的子页与页码,切公司不清它,展开同一父级就'
|
||||
+ '直接把别家的子类目画出来(这一处根本不发请求,比"筛成空页"更静默)',
|
||||
premise: [
|
||||
{ file: 'src/pages/asin/product-category-api.ts', shapes: [/company_id\s*=\s*companyId\b/] },
|
||||
],
|
||||
},
|
||||
// ↓ 批次 3 的两页(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。
|
||||
// 这两页的 token 一直写到 reload 那两句为止(批次 1/2 的老条目仍只钉清筛选项,不动它们):
|
||||
// 变异自证发现「删掉 void loadConsole()」当时全绿——清筛选项那半守住了,重新取数那半没人守。
|
||||
@@ -633,6 +678,28 @@ const WATCH_BODY_PINS: ReadonlyArray<{
|
||||
{ file: 'src/api/users.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
|
||||
],
|
||||
},
|
||||
// ↓ 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。
|
||||
{
|
||||
file: 'src/pages/shop/ShopKeysPage.vue',
|
||||
token: "filterKeyword.value = ''; page.value = 1; void load()",
|
||||
why: '这一页的「备注名 / 紫鸟账号」是客户端过滤(filteredRows 在本页 rows 上筛,不进请求):'
|
||||
+ '留着上一家填的关键字,切到新一家就是拿别家的字符串去筛本公司那几行 ⇒ 首屏「暂无符合条件的密钥」而筛选框里还显示着它;'
|
||||
+ '页码回 1 是因为新一家的令牌更少,末尾的 void load() 才让切 tab 真的换数据',
|
||||
premise: [
|
||||
{ file: 'src/pages/shop/shop-key-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
|
||||
],
|
||||
},
|
||||
// ↓ 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」,定案「每家公司一套树」)。
|
||||
{
|
||||
file: 'src/pages/account/MenusPage.vue',
|
||||
token: "filterName.value = ''; filterType.value = ''; page.value = 1; void loadMenus()",
|
||||
why: '菜单名称/类型是客户端筛选(filteredMenuRows 在本页已取的 rows 上筛,不进请求):留着上一家填的值'
|
||||
+ '就是拿别家的字符串去筛新一家那一套树 ⇒ 首屏「暂无匹配菜单」,而输入框里还显示着那个值。页码回 1 是因为'
|
||||
+ '新一家的行数不同,末尾的 void loadMenus() 才是本页唯一的数据出口',
|
||||
premise: [
|
||||
{ file: 'src/pages/account/menu-manage-api.ts', shapes: [/company_id\s*=\s*companyId\b/] },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
/** 取「`watch(() => companyTab.activeId, () => { … })`」这一条语句的原文;匹配不出返回 null(由调用方判探针失效)。 */
|
||||
@@ -641,9 +708,9 @@ function watchStatement(source: string): string | null {
|
||||
return m ? m[0] : null
|
||||
}
|
||||
|
||||
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 五页 + 批次 3 两页 + 批次 4 一页)', () => {
|
||||
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 三页 + 批次 3 两页 + 批次 4 一页 + 批次 5 一页 + 批次 6 一页)', () => {
|
||||
assert.ok(WATCH_BODY_PINS.length >= 10,
|
||||
`watch 体看守只剩 ${WATCH_BODY_PINS.length} 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/品牌库/查询ASIN/最低价ASIN/商品类目 + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理共 10 对)`
|
||||
`watch 体看守只剩 ${WATCH_BODY_PINS.length} 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/查询ASIN/最低价ASIN + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理 + 批次 5 的店铺密钥 + 批次 6 的菜单管理共 10 对)`
|
||||
+ '⇒ 这一族又退回"只钉少数几页",被摘掉那一页的"切公司不清筛选项"再次没人看守')
|
||||
const pinnedFiles = new Set(WATCH_BODY_PINS.map((pin) => pin.file))
|
||||
for (const pin of WATCH_BODY_PINS) {
|
||||
@@ -810,3 +877,108 @@ test('挂载与单一尺子:tab 条挂在壳层、公司名读 companyName、
|
||||
assert.match(tabs, /initialize\(\)\.catch\(/,
|
||||
'组件侧必须 .catch 接住 store 的 rethrow,否则又变回 unhandled rejection')
|
||||
})
|
||||
|
||||
test('渲染范围:tab 条只画在按公司取数的页上,公司管理那排点了没反应的 tab 摘掉', () => {
|
||||
// 2026-10-06 控制方:「公司管理不要有 tab」。10-05 那一轮只钉住了「CompaniesPage 不消费 store」
|
||||
// (company-config-entry-super-only 最后那条),而 tab 条本身挂在壳层 AdminLayout、对全部页都画
|
||||
// ⇒ 界面一个字都没变,同一天被第二次点名。这条补的是**渲染侧**那一半。
|
||||
// 判据取 COMPANY_SCOPED_PAGES 这一张注册表:写黑名单的话,下一个新页默认长出一条装饰 tab。
|
||||
const pageKeys = adminPages.map((p) => p.menuKey)
|
||||
assert.ok(pageKeys.length >= 22, `路由注册表只取到 ${pageKeys.length} 页 ⇒ 分母被删空,下面的差集会假绿`)
|
||||
const scoped = new Set(COMPANY_SCOPED_PAGES.map((p) => p.menuKey))
|
||||
const unscoped = pageKeys.filter((k) => !scoped.has(k))
|
||||
assert.ok(scoped.size >= 15, `注册表只剩 ${scoped.size} 页 ⇒ 正向那半的循环没东西可验`)
|
||||
assert.ok(unscoped.includes('admin_companies'),
|
||||
'admin_companies 竟在公司 tab 注册表里:与「公司管理仅超管、不做 tab」直接冲突')
|
||||
|
||||
const model = stripComments(readSource('src/layout/company-tab-model.ts'))
|
||||
assert.match(model, /new Set\(COMPANY_SCOPED_PAGES\.map/,
|
||||
'companyTabAppliesTo 必须从 COMPANY_SCOPED_PAGES 派生,不是另立一张名单')
|
||||
assert.equal(model.includes("'admin_companies'"), false,
|
||||
'渲染判据里不许写死菜单名:那是第二张清单,与注册表迟早漂移')
|
||||
|
||||
// 真值双向:注册表内 ⇒ 画(漏了就是取值口与渲染口分家),注册表外每一页 ⇒ 不画(点了不重取数)
|
||||
for (const key of scoped) assert.equal(companyTabAppliesTo(key), true, `${key} 在注册表里却不画 tab`)
|
||||
for (const key of unscoped) assert.equal(companyTabAppliesTo(key), false, `${key} 没接公司隔离却画着 tab`)
|
||||
assert.equal(companyTabAppliesTo(undefined), false, '没有 menuKey 的开放页(登录页等)默认不画')
|
||||
|
||||
// 组件真把这一条串进了 show:只导出函数不接线=这条护栏恒绿
|
||||
const tabs = stripComments(readSource('src/layout/CompanyTabs.vue'))
|
||||
const showLine = tabs.split('\n').find((line) => line.includes('const show ='))
|
||||
assert.ok(showLine, 'CompanyTabs.vue 找不到 `const show =` 这一行:渲染开关换写法了,先确认它还在不在')
|
||||
assert.ok(showLine.includes('tab.visibleForOperator'), 'show 少了「目录可用」那条')
|
||||
assert.ok(showLine.includes('companyTabAppliesTo(route.meta.menuKey)'),
|
||||
'show 少了「这一页吃公司」那条 ⇒ 退回全页画 tab,公司管理页头顶又会长出那一排')
|
||||
})
|
||||
|
||||
/**
|
||||
* 2026-10-06 控制方定案:品牌数据库、商品类目「做成所有公司共享的,不区分」。
|
||||
*
|
||||
* <p>上面那几条正向判据全是从 {@code COMPANY_SCOPED_PAGES} 派生的,页一退出注册表就自动不再求值 ⇒
|
||||
* 「退出」这件事本身没有看守:谁把 {@code company_id} 重新塞回这三个取数口,全仓用例一支都不会红,
|
||||
* 而后端唯一键已经退回全局(V151),带公司参数的读会把共享库筛窄成「只看这一家」,
|
||||
* 写侧则把一张全平台共享的表按家拆开——两边都是静默改口径,不是报错。所以这一支必须存在。</p>
|
||||
*
|
||||
* <p>判据只认「剥完注释的代码」:这三份文件现在各自留有一句说明共享口径的注释,
|
||||
* 注释里的 {@code company_id} 三个字面字符不是接线(全局约束 6)。正样本用摘掉之前那三行原文,
|
||||
* 所以下面的 false 是测出来的,不是「正则本来就抓不到」。</p>
|
||||
*/
|
||||
const SHARED_PAGE_KEYS = ['admin_invalid_asin_data', 'admin_product_categories'] as const
|
||||
const SHARED_API_FILES = [
|
||||
'src/pages/invalidasin/invalid-asin-api.ts',
|
||||
'src/pages/asin/product-category-api.ts',
|
||||
'src/pages/asin/product-category-export.ts',
|
||||
] as const
|
||||
const SHARED_PAGE_FILES = [
|
||||
'src/pages/asin/AsinInvalidPage.vue',
|
||||
'src/pages/asin/ProductCategoryPage.vue',
|
||||
] as const
|
||||
|
||||
/** 公司参数的两种写法:下传用的 snake、形参/字段用的 camel。 */
|
||||
const COMPANY_PARAM_TOKEN = /(?:company_id|companyId)/
|
||||
|
||||
/** 本次摘掉的三行原发送口(逐字取自改动前的源码),做反向钉的同支正样本。 */
|
||||
const FORMER_SEND_LINES = [
|
||||
'if (query.companyId != null) params.company_id = query.companyId',
|
||||
'if (companyId != null) params.company_id = companyId',
|
||||
'if (companyId != null) params.push(`company_id=${companyId}`)',
|
||||
]
|
||||
|
||||
test('公司维度不得回流:品牌库与商品类目已定案全平台共享,取数口与页面都不许再带公司参数', () => {
|
||||
// 判据自证(全局约束 15:反向钉不许独自成立)——改动前那三行必须抓得到,否则下面的 false 是空判据。
|
||||
for (const line of FORMER_SEND_LINES) {
|
||||
assert.ok(COMPANY_PARAM_TOKEN.test(line), `反向钉判据连原来的发送口「${line}」都匹配不出 ⇒ 这一族恒绿`)
|
||||
}
|
||||
// watch 探针同理:它今天还在 WATCH_BODY_PINS 那十对上起作用,这里再就地复验一次形状,
|
||||
// 免得「页面里没有 watch」是因为正则换了写法而失明。
|
||||
assert.ok(WATCH_ACTIVE_ID.test('watch(() => companyTab.activeId, () => { void load() })'),
|
||||
'WATCH_ACTIVE_ID 连合规样本都匹配不出 ⇒ 下面「不许再长出 watch」那条恒绿')
|
||||
// 注册表本身非空自证:表被删空时 some() 会对所有 key 返回 false,看着像「都退出了」。
|
||||
assert.ok(COMPANY_SCOPED_PAGES.length >= 15,
|
||||
`注册表只剩 ${COMPANY_SCOPED_PAGES.length} 页 ⇒ 分母被删空,下面的 some() 会假绿`)
|
||||
|
||||
for (const key of SHARED_PAGE_KEYS) {
|
||||
assert.equal(COMPANY_SCOPED_PAGES.some((p) => p.menuKey === key), false,
|
||||
`${key} 又回到 COMPANY_SCOPED_PAGES:2026-10-06 已定案这两页全平台共享,不区分公司`)
|
||||
const page = adminPages.find((p) => p.menuKey === key)
|
||||
assert.ok(page, `${key} 在路由注册表里找不到:菜单名改了,反向钉对不上页`)
|
||||
assert.equal(page.companyScoped, false,
|
||||
`${key} 的 meta.companyScoped 不再是 false:tab 条会画出来,而这一页的取数口没有公司参数 ⇒ 点了没反应)`)
|
||||
}
|
||||
|
||||
for (const file of [...SHARED_API_FILES, ...SHARED_PAGE_FILES]) {
|
||||
const src = stripComments(read(file))
|
||||
assert.equal(COMPANY_PARAM_TOKEN.test(src), false,
|
||||
`${file} 又出现了公司参数:这两页读的是全平台共享的库,带上 company_id 等于把共享口径偷偷改回按家筛`)
|
||||
assert.ok(COMPANY_PARAM_TOKEN.test(`${src}\n${FORMER_SEND_LINES[0]}`),
|
||||
`(同支正样本)${file} 的源码喂进判据后连拼上原发送口都匹配不出 ⇒ 上面那条 false 无从判定`)
|
||||
}
|
||||
|
||||
for (const file of SHARED_PAGE_FILES) {
|
||||
const src = stripComments(read(file))
|
||||
assert.equal(WATCH_ACTIVE_ID.test(src), false,
|
||||
`${file} 又 watch 了 companyTab.activeId:这一页不按公司取数,切 tab 重取数只会把用户正在看的页刷掉`)
|
||||
assert.equal(/useCompanyTabStore|companyTab\.requestCompanyId/.test(src), false,
|
||||
`${file} 重新引回了公司 tab store,而它对应的 tab 条已经摘掉`)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user