feat(公司tab): 批次 2/3/4 再接 8 页,注册表收到 16 页——用户页回流 company_id 按新边界改写反向钉

「切 tab 数据还一样」的根因一直是分母小于现实:批次 1 只登记 8 页,本轮按控制方
三次点名扩到 16 页(company-scope.ts 是唯一清单,routes.ts 的 companyScoped 逐页对平)。

批次 2(五页 ASIN 中心):去重总数据 / 不符合ASIN / 查询ASIN / 最低价ASIN / 商品类目。
批次 3(两页店铺中心):撞款监控、店铺数据记录。这两页没有归属列可筛,归属口径是
「本公司账号名下的店铺」——后端由 DataReadScope 推公司 → 成员账号 → biz_shop_manage.
created_by_id,前端只把 activeId 当 company_id 送下去。空成员集必须交空集合,绝不能
退化成 null(null 在这里=全量,那样第二家会看到全部数据)。
批次 4(用户管理):后端早就认 company_id(只对站点超管生效,公司超管恒锁本公司),
断的是前端——UserListQuery 里连这个字段都没有,三家 tab 看的是同一份全量列表。

三处口径改动,逐条说明:
1)company-user-list.test.ts 的反向钉被改写。2026-10-04 定案把公司维度从用户页整体摘掉,
   那条钉的原文是「列表查询/筛选/行渲染不允许出现公司维度」。控制方 2026-10-05 明确要
   用户管理区分公司 tab,所以钉的边界收窄成两半:渲染层(行级公司列、「所属公司」标签、
   筛选状态、顶栏公司名)仍不得回流;请求层的 company_id 是这次加回来的,尺子换成
   「取值口唯一」——页面每处 companyId 都必须等于 companyTab.requestCompanyId,且
   normalizeUserPageParams/toUserListQuery 两只白名单构造器体内不许出现公司值。
   新增一支行为钉:往归一化里传 companyId 必须被丢掉,这是 users.ts 读原始入参的全部理由
   (写成 normalized.companyId 时 TS 照样绿、运行时恒 undefined)。
2)align-dup-console 那条 watch 看守的 token 扩到含 reload。变异自证里「删掉 void
   loadConsole()」当场全绿:体里的清筛选项守住了,重新取数那半没人守。批次 3/4 三对
   token 一起写到 reload 为止(批次 1/2 的老条目不动)。
3)公司管理页补正/反向两把尺子:company-config-entry-super-only 新增「吃公司 tab 的页面
   集合恰好等于 COMPANY_SCOPED_PAGES 的 pageFiles」——按代码真值比,不按清单比,所以
   清单不改一字而往 CompaniesPage.vue 里塞 store 也会红。谓词带括号,否则 import 行也算消费者。

菜单权限(admin_columns)本轮不动:MenusPage 只消费 /api/admin/permission-menus 这一份全局
菜单字典,切 tab 一样是数据本身全局,不是筛选坏了。真问题在写侧——PermissionMenuService
create/update/delete 只有 ensureAdminOperatorIfPresent(isAdmin 即放行),公司管理员改的是
全平台的菜单行。收窄为仅站点超管 vs 给 permission_menu 加归属列,两种改法代价差一个量级,
留给控制方定档。

护栏:G1 发送口 22 个 / 页面分组 17、watch 体看守 10 对、operation-guide 的 tab 文案 15 页
(撞款监控是显式豁免,另有一条自检盯「豁免落空」)。
变异自证 12/12 全杀(前端 10 + 公司管理反向钉 2),分母钉死在 27 例。
门禁:后端全量 3823 例 / 0 失败 / 0 错误 / 7 skipped,BUILD SUCCESS;admin-frontend-vue
1741 例 / 0 红;vue-tsc rc=0。首轮后端 4 红是另一路 task_partial 改动与本轮编译抢跑,
单跑 13 例已绿,本笔不含他们的任何文件。

未上线:jar 与 admin-vue 都没出包,V147 未在生产执行。
This commit is contained in:
2026-10-06 02:32:59 +08:00
parent bff7068421
commit 2cae0d742c
87 changed files with 3519 additions and 459 deletions
+4
View File
@@ -15,6 +15,9 @@ export interface UserListParams {
adminId?: number | null
/** 角色过滤(''=全部)。 */
role?: string
/** 公司 tab 的当前公司;由页面从 store 传入,**不住在 UserFilterState 里**
* (normalizeUserPageParams 白名单构造会把它丢掉,取值口只认 fetchUserList 的原始入参)。 */
companyId?: number | null
}
/** 序列化到 GET /api/admin/users 的查询参数(Java snake_case)。 */
@@ -26,6 +29,7 @@ export interface UserListQuery {
created_by_id?: number
admin_id?: number
role?: string
company_id?: number
}
/** 用户列表项即 AdminUser(与 Java AdminUserItemVo 字段对齐)。 */
+5 -1
View File
@@ -11,7 +11,11 @@ import {
/** 分页查询用户列表:归一化参数 → GET /api/admin/users → 解析 Java 分页负载。 */
export async function fetchUserList(params: Partial<UserListParams> = {}): Promise<UserPageResult> {
const normalized = normalizeUserPageParams(params)
const { data } = await http.get('/api/admin/users', { params: toUserListQuery(normalized) })
const query = toUserListQuery(normalized)
// normalizeUserPageParams 是白名单构造(只点名 page/pageSize/keyword/createdById/adminId/role),
// 公司值必须从原始 params 读:写成 normalized.companyId 会 TS 绿、运行时恒 undefined。
if (params.companyId != null) query.company_id = params.companyId
const { data } = await http.get('/api/admin/users', { params: query })
return parseUserPage(data)
}
@@ -25,4 +25,22 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
{ menuKey: 'admin_device_logs', apiFiles: ['src/api/device-logs.ts'], pageFiles: ['src/pages/records/DeviceLogsPage.vue'] },
{ menuKey: 'admin_group_manage', apiFiles: ['src/pages/account/shop-group-api.ts'], pageFiles: ['src/pages/account/GroupsPage.vue'] },
{ menuKey: 'admin_shop_manage', apiFiles: ['src/pages/shop/shop-manage-api.ts'], pageFiles: ['src/pages/shop/ShopManagePage.vue'] },
// 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页):读门已在后端接上(V145 补归属 / V147 加列),
// 这一批把前端接线补齐。apiFiles 只列**真的把 company_id 拼进请求**的模块:
// 各页的 *-filter.ts 与 asin-filter.ts 只带 camel 的 companyId 字段(类型 + 白名单构造都不点名它),
// 列进来会让正向判据去盯一个本来就不该出现 snake_case 的文件。
{ 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 送下去。
{ menuKey: 'admin_shop_data_duplicate_check', apiFiles: ['src/pages/tasks/duplicate-console-api.ts'], pageFiles: ['src/pages/tasks/DuplicateCheckPage.vue'] },
{ menuKey: 'admin_shop_data_crawl_tasks', apiFiles: ['src/pages/tasks/shop-data-api.ts'], pageFiles: ['src/pages/tasks/ShopDataTasksPage.vue'] },
// 批次 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'] },
]
@@ -21,9 +21,9 @@ export const OPERATION_GUIDE_STORAGE_KEY = 'shufuAdminGuideCollapsed'
* (§12 第 5 条把那种提示条算未批的界面暴露;当前哪一家由 is-active 的 tab 表达,一处事实不留两处)。
* 这句必须以「超级管理员」开头、不能写成祈使式的「由上方 tab 决定」:引导文案按 menuKey 取、
* 不分支角色,而非超管根本看不到 tab 条(company-tab store 的 visibleForOperator 里有 isSuperAdmin)。
* 这一句由参与 tab 的 8 页共用、不各抄一遍——文案差一个字,护栏就只盯得住其中一页。
* 这一句由参与 tab 的 13 页共用、不各抄一遍——文案差一个字,护栏就只盯得住其中一页。
* 由 tests/align-operation-guide.test.ts 的 guide_copy_carries_company_tab_note_for_every_scoped_page
* 按 COMPANY_SCOPED_PAGES 逐页盯着(分母取注册表,加第 9 页忘了补文案会当场红)。 */
* 按 COMPANY_SCOPED_PAGES 逐页盯着(分母取注册表,加一页忘了补文案会当场红)。 */
const COMPANY_TAB_GUIDE_NOTE = ' 超级管理员可用页面上方的公司 tab 切换公司,切换后行数会变化——行数变少不是数据丢了。'
/** §5 的承载:注册表里显式 companyScoped:false 的 C 类页要的是**另一句**——"这页不参与",
@@ -35,7 +35,10 @@ const SHOP_OWNER_COMPANY_NOTE = ' 店铺归哪家公司由「负责人」决定
export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
admin_users: {
text: '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。',
// 2026-10-05 批次 4:与 group-manage 同型偏离——参与公司 tab 的页必须在原文之后带上那句 §9.3,
// 所以这一条不再与旧版 guides 逐字相等(护栏改为 match 原句子串,见 align_guide_users_matches_reference_text)。
text: '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。'
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['筛选账号', '编辑权限', '确认保存'],
},
admin_columns: {
@@ -60,24 +63,28 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
steps: ['查看公司列表', '新建公司', '改名或启停'],
},
admin_dedupe_total_data: {
text: '支持按关键词、用户、分组和国家筛选;导入前先确认所选分组,导出会按日期范围生成文件。',
text: '支持按关键词、用户、分组和国家筛选;导入前先确认所选分组,导出会按日期范围生成文件。'
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['选择分组', '筛选或导入', '核对并导出'],
},
admin_invalid_asin_data: {
text: '维护不符合规则的 ASIN 或品牌。添加后可使用上方筛选快速回查。',
text: '维护不符合规则的 ASIN 或品牌。添加后可使用上方筛选快速回查。'
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['填写 ASIN/品牌', '选择分组', '保存并回查'],
},
admin_query_asin: {
text: '查询 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN。',
text: '查询 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN。'
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['筛选店铺', '打开配置抽屉', '保存或导出'],
},
admin_product_categories: {
text: '类目树支持展开查看层级。搜索、编辑和删除都在同一列表中完成。'
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['搜索类目', '展开层级', '新增或编辑'],
},
admin_skip_price_asin: {
text: '最低价 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN 与最低价。',
text: '最低价 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN 与最低价。'
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['筛选店铺', '打开配置抽屉', '保存或批量导入'],
},
admin_shop_keys: {
@@ -92,10 +99,13 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
steps: ['选择分组', '维护店铺信息', '筛选核对结果'],
},
admin_shop_data_crawl_tasks: {
text: '店铺数据任务按状态和时间筛选。批量操作前请核对已选任务。',
text: '店铺数据任务按状态和时间筛选。批量操作前请核对已选任务。'
+ COMPANY_TAB_GUIDE_NOTE,
steps: ['筛选任务', '检查状态', '执行批量操作'],
},
// admin_shop_data_duplicate_check(店铺撞款监控)为例外页:不展示全局提示条,不参与对齐。
// 它进了公司 tab 范围(COMPANY_SCOPED_PAGES)却没有文案可挂,所以那句 §9.3 的看守在这一页由
// tests/align-operation-guide.test.ts 显式豁免;这一页的「切 tab 行数会变」写在页面自身的说明里。
admin_image_video_tasks: {
text: '可先使用筛选缩小任务范围,再查看任务状态、结果和权限范围。'
+ COMPANY_TAB_GUIDE_NOTE,
@@ -2,11 +2,12 @@
import { formatDateTime } from '@/utils/datetime'
/** 用户管理页 · 像素复刻旧版 admin.html panel-users(自绘:panel-box + 页头按钮 + 筛选 form-row + 旧式表格/分页 + 原生 confirm 删除)。
* script 逻辑沿用现有 Vue 实现;创建/编辑弹窗保留现有组件(含用户菜单权限树)。 */
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import type { AdminUser } from '@/types/admin'
import { roleLabel } from '@/types/admin'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
import { deleteUser, fetchUserList } from '@/api/users'
import { fetchCompanies } from '@/api/companies'
import { createUserFilterState, toUserListParams, type UserFilterState } from './users-filter'
@@ -20,6 +21,7 @@ import EditUserDialog from './EditUserDialog.vue'
import OldPagination from '@/components/OldPagination.vue'
const session = useAdminSessionStore()
const companyTab = useCompanyTabStore()
const loading = ref(false)
const loadError = ref('')
const rows = ref<AdminUser[]>([])
@@ -54,11 +56,17 @@ function editableOf(row: AdminUser): boolean {
return editableBy(row.role, operatorRole.value)
}
/** 列表请求参数 = 用户填的筛选态 + 当前公司。公司值每次现取、不写进 filters:
* 它由上方 tab 决定而不是用户填的筛选项,住进 filters 就等于多出第二个取值口径(Store 之外再长一个)。 */
function listParams() {
return { ...toUserListParams(filters), companyId: companyTab.requestCompanyId }
}
async function loadUsers() {
loading.value = true
loadError.value = ''
try {
const page = await fetchUserList(toUserListParams(filters))
const page = await fetchUserList(listParams())
rows.value = page.items
total.value = page.total
if (Array.isArray(page.admins)) admins.value = page.admins
@@ -66,7 +74,7 @@ async function loadUsers() {
const last = totalPageCount(page.total, filters.pageSize)
if (last > 0 && filters.page > last) {
filters.page = last
const retried = await fetchUserList(toUserListParams(filters))
const retried = await fetchUserList(listParams())
rows.value = retried.items
total.value = retried.total
}
@@ -126,6 +134,11 @@ function goJump() {
changePage(Math.min(Math.max(n, 1), totalPages.value))
}
// 切公司 = 重新取数,并清掉两处上一家遗留:
// ①「所属管理员」下拉的候选(admins)随本公司的列表响应给出,上一家选中的 adminId 在新一家的下拉里不存在;
// ② 用户名全平台唯一(V143 的唯一索引),留着上一家填的关键字去筛新一家 ⇒ 必然空页,而输入框还显示着那个值。
watch(() => companyTab.activeId, () => { filters.createdByAdminId = null; filters.keyword = ''; filters.page = 1; void loadUsers() })
onMounted(() => {
void loadUsers()
// 公司目录仅站点超管拉取(建「公司超级管理员」时选公司用);非超管不发这个请求,后端 403 兜底
@@ -5,6 +5,7 @@ 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'
@@ -14,6 +15,7 @@ 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)
@@ -44,7 +46,7 @@ const groupOptions = computed<ShopGroupOption[]>(() => {
async function loadGroups() {
try {
groups.value = await fetchShopManageGroups()
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
} catch {
groups.value = []
}
@@ -63,6 +65,7 @@ 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
@@ -160,6 +163,10 @@ 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()
@@ -2,7 +2,7 @@
import { formatDateTime } from '@/utils/datetime'
/** 数据去重总数据(registry) · 像素复刻旧版 admin.html panel-dedupe-total-data(自绘:分组摘要 + 双行筛选 + 旧式表格/分页 + 编辑/导入弹窗 + 导出等待遮罩)。
* script 逻辑沿用现有 Vue 实现(查询/编辑/删除/导入轮询/导出秒表)。 */
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import {
fetchDedupeTotalList,
@@ -25,8 +25,10 @@ import type { DedupeImportProgress } from './dedupe-import-model.ts'
import { toExportUrl } from './dedupe-total-export.ts'
import OldPagination from '@/components/OldPagination.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
const session = useAdminSessionStore()
const companyTab = useCompanyTabStore()
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
const isSuperAdmin = computed(() => session.isSuperAdmin)
@@ -91,7 +93,7 @@ async function load(): Promise<void> {
loading.value = true
try {
const result = await fetchDedupeTotalList(
toDedupeListParams(filter, page.value, pageSize.value, pendingCursor),
toDedupeListParams(filter, page.value, pageSize.value, pendingCursor, companyTab.requestCompanyId),
)
rows.value = result.items
total.value = result.total
@@ -277,7 +279,7 @@ async function doExport(): Promise<void> {
startExportWait()
try {
// 对齐 admin.js:fetch 流式下载,带筛选参数;失败响应(JSON)解析错误提示。
const response = await window.fetch(toExportUrl(filter), { credentials: 'include' })
const response = await window.fetch(toExportUrl(filter, companyTab.requestCompanyId), { credentials: 'include' })
const contentType = response.headers.get('content-type') || ''
if (!response.ok || contentType.includes('application/json')) {
const body = (await response.json().catch(() => ({}))) as { error?: string; message?: string; msg?: string }
@@ -304,11 +306,22 @@ async function doExport(): Promise<void> {
}
}
async function loadGroups(): Promise<void> {
try {
groups.value = await fetchDedupeTotalGroups(companyTab.requestCompanyId)
} catch {
groups.value = []
}
}
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
// groupId 与 keyset 游标必须一起清:上一家选中的分组在新一家不存在,而上一家响应回传的 lastId
// 拿到新一家去翻页会把「游标之后」当成条件,首屏直接筛成空列表。
watch(() => companyTab.activeId, () => { filter.groupId = null; pageCursor.value = null; pendingCursor = null; void loadGroups(); void load() })
onMounted(() => {
void load()
fetchDedupeTotalGroups().then((items) => {
groups.value = items
})
void loadGroups()
})
</script>
@@ -1,7 +1,7 @@
<script setup lang="ts">
/** 商品类目 · 像素复刻旧版 admin.html panel-product-categories(自绘:面板头搜索框组+新增类目 同行、原生树表格[+/−]折叠+懒加载「加载更多 已加载 x/y」、搜索态旧式分页)。
* script 逻辑沿用现有 Vue 实现(懒加载树/编辑删除/导出/弹窗)。 */
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } 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,7 +17,9 @@ 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('')
@@ -68,7 +70,7 @@ const rootTotal = ref(0)
async function loadTree(): Promise<void> {
loading.value = true
try {
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value)
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value, companyTab.requestCompanyId)
const state = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
childrenState.set(ROOT_KEY, state)
// 顶层当前页直接作为树根(不含合成「加载更多」节点,翻页由 OldPagination 承担)。
@@ -144,7 +146,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)
const result = await fetchProductCategoryChildren(parent?.id ?? null, page, PRODUCT_CATEGORY_DEFAULT_PAGE_SIZE, companyTab.requestCompanyId)
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)
@@ -195,7 +197,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)
const result = await searchProductCategories(keyword.value, page, searchPageSize.value, companyTab.requestCompanyId)
searchRows.value = result.items
searchTotal.value = result.total
searchPage.value = result.page
@@ -297,13 +299,17 @@ async function submit(): Promise<void> {
function exportCategories(): void {
const anchor = document.createElement('a')
anchor.href = buildProductCategoryExportUrl(keyword.value)
anchor.href = buildProductCategoryExportUrl(keyword.value, companyTab.requestCompanyId)
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>
@@ -1,7 +1,7 @@
<script setup lang="ts">
/** 查询 ASIN · 像素复刻旧版 admin.html panel-query-asin(自绘:面板头操作组、筛选+导出 XLSX、原生 rowspan 表格+可复制 ASIN、旧式分页)。
* script 逻辑沿用现有 Vue 实现(新增级联/配置抽屉/导入轮询/导出)。 */
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import CopyText from '@/components/CopyText.vue'
import { formatDateTime } from '@/utils/datetime'
@@ -18,8 +18,10 @@ import { fetchShopManageGroups } from '../shop/shop-manage-api.ts'
import type { ShopGroupOption } from '../shop/shop-dto.ts'
import OldPagination from '@/components/OldPagination.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
const session = useAdminSessionStore()
const companyTab = useCompanyTabStore()
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
const isSuperAdmin = computed(() => session.isSuperAdmin)
@@ -146,7 +148,7 @@ async function onCreateGroupChange(): Promise<void> {
}
shopNamesLoading.value = true
try {
shopNames.value = await fetchShopNamesByGroup(createGroupId.value)
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
} catch (error) {
shopNames.value = []
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
@@ -279,7 +281,7 @@ async function submitImport(): Promise<void> {
function doExport(): void {
// 带当前筛选(分组/店铺名/ASIN/国家)导出,范围与列表筛选一致(此前不带参数导致导出恒为全量)。
const anchor = document.createElement('a')
anchor.href = toQueryAsinExportUrl(filter)
anchor.href = toQueryAsinExportUrl(filter, companyTab.requestCompanyId)
document.body.appendChild(anchor)
anchor.click()
anchor.remove()
@@ -288,7 +290,7 @@ function doExport(): void {
async function loadGroups() {
try {
groups.value = await fetchShopManageGroups()
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
} catch {
groups.value = []
}
@@ -304,6 +306,7 @@ async function load() {
shopName: filter.shopName.trim() || undefined,
asin: filter.asin.trim() || undefined,
country: filter.country || undefined,
companyId: companyTab.requestCompanyId,
})
rows.value = result.items
total.value = result.total
@@ -342,6 +345,11 @@ function goJump() {
changePage(Math.min(Math.max(n, 1), totalPages.value))
}
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
// groupId 与 shopName 必须一起清:上一家选中的分组/店铺名在新一家的可见集与候选字典里根本不存在,
// 留着会把切 tab 后的首屏筛成空列表(请求、后端、权限三处都没错,最难查的那一型)。
watch(() => companyTab.activeId, () => { filter.groupId = null; filter.shopName = ''; void loadGroups(); void load() })
onMounted(() => {
void loadGroups()
void load()
@@ -1,11 +1,12 @@
<script setup lang="ts">
/** 最低价 ASIN(跳过跟价)· 像素复刻旧版 admin.html panel-skip-price-asin(自绘:面板头操作组、筛选(分组/店铺/国家/ASIN/最低价≥≤)+导出 XLSX、原生 rowspan 表格、旧式分页)。
* script 逻辑沿用现有 Vue 实现(新增级联+最低价、配置抽屉双列、导入轮询、导出)。 */
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import CopyText from '@/components/CopyText.vue'
import { formatDateTime } from '@/utils/datetime'
import { createSkipPriceAsin, fetchSkipPriceList } from './skip-price-api.ts'
import { toSkipPriceExportUrl } from './skip-price-export.ts'
import { skipPriceDisplayRows, type SkipPriceItem } from './skip-price-model.ts'
import { asinCountryLabel } from './asin-country.ts'
import { createSkipPriceFilterState, toSkipPriceParams, type SkipPriceFilterState } from './skip-price-filter.ts'
@@ -17,8 +18,10 @@ import { fetchShopManageGroups } from '../shop/shop-manage-api.ts'
import type { ShopGroupOption } from '../shop/shop-dto.ts'
import OldPagination from '@/components/OldPagination.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
const session = useAdminSessionStore()
const companyTab = useCompanyTabStore()
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
const isSuperAdmin = computed(() => session.isSuperAdmin)
@@ -89,7 +92,7 @@ async function onCreateGroupChange(): Promise<void> {
}
shopNamesLoading.value = true
try {
shopNames.value = await fetchShopNamesByGroup(createGroupId.value)
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
} catch (error) {
shopNames.value = []
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
@@ -329,8 +332,9 @@ async function submitImport(): Promise<void> {
}
function doExport(): void {
// 带当前筛选(分组/店铺名/ASIN/国家/最低价区间)+ 公司范围导出:此前不带任何参数,导出恒为全平台全量。
const anchor = document.createElement('a')
anchor.href = '/api/admin/skip-price-asins/export'
anchor.href = toSkipPriceExportUrl(filter, companyTab.requestCompanyId)
document.body.appendChild(anchor)
anchor.click()
anchor.remove()
@@ -339,7 +343,7 @@ function doExport(): void {
async function loadGroups() {
try {
groups.value = await fetchShopManageGroups()
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
} catch {
groups.value = []
}
@@ -348,7 +352,7 @@ async function loadGroups() {
async function load() {
loading.value = true
try {
const result = await fetchSkipPriceList(toSkipPriceParams(filter, page.value, pageSize.value))
const result = await fetchSkipPriceList(toSkipPriceParams(filter, page.value, pageSize.value, companyTab.requestCompanyId))
rows.value = result.items
total.value = result.total
page.value = result.page
@@ -386,6 +390,11 @@ function goJump() {
changePage(Math.min(Math.max(n, 1), totalPages.value))
}
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
// groupId 与 shopName 必须一起清:上一家选中的分组/店铺名在新一家的可见集与候选字典里根本不存在,
// 留着会把切 tab 后的首屏筛成空列表(请求、后端、权限三处都没错,最难查的那一型)。
watch(() => companyTab.activeId, () => { filter.groupId = null; filter.shopName = ''; void loadGroups(); void load() })
onMounted(() => {
void loadGroups()
void load()
@@ -26,6 +26,10 @@ export interface AsinListParams {
country?: string
/** 顺序翻页游标(上一页返回的 nextLastId):传了就忽略 page 偏移,走 keyset。 */
lastId?: number
/** 公司 tab 的值。normalizeAsinPageParams 是白名单构造、**故意不点名它**
*(归一化函数不认识公司这一维,也不许认识:公司值由发送口自己下传),
* 所以取数函数必须从原始入参读这一项,读归一化结果会拿到 undefined。 */
companyId?: number | null
}
/** 序列化到 Java 分页接口的查询参数(snake_case)。 */
@@ -40,6 +44,8 @@ export interface AsinPageQuery {
country?: string
/** 顺序翻页游标(keyset):传了就忽略 page 偏移。 */
last_id?: number
/** 公司 tab:与 Java 各列表接口的 `@RequestParam(name = "company_id")` 逐字对齐。 */
company_id?: number
}
function finiteInt(value: unknown): number | null {
@@ -10,7 +10,11 @@ export const DEDUPE_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
export async function fetchDedupeTotalList(params: Partial<AsinListParams> = {}): Promise<DedupeTotalPageResult> {
const normalized = normalizeAsinPageParams(params)
const { data } = await http.get<unknown>(DEDUPE_TOTAL_ENDPOINT, { params: toAsinPageQuery(normalized) })
// normalizeAsinPageParams 是白名单构造(不点名 companyId),所以公司值只能从原始 params 读:
// 写成 normalized.companyId 是 TS 绿、运行时恒 undefined,请求里根本没这个参数。
const query = toAsinPageQuery(normalized)
if (params.companyId != null) query.company_id = params.companyId
const { data } = await http.get<unknown>(DEDUPE_TOTAL_ENDPOINT, { params: query })
return parseDedupeTotalPage(data)
}
@@ -32,7 +36,8 @@ export async function deleteDedupeTotal(id: number): Promise<void> {
}
/** 加载数据权限分组选项:GET /shop-manages/groups → {id,name,leaderUserId}[]。 */
export async function fetchDedupeTotalGroups(): Promise<DedupeGroupOption[]> {
const { data } = await http.get<unknown>(DEDUPE_GROUPS_ENDPOINT)
export async function fetchDedupeTotalGroups(companyId?: number | null): Promise<DedupeGroupOption[]> {
// null 由发送口自己丢掉(不依赖 axios 丢 null):非超管/未选 tab 时不发 company_id,后端按会话裁剪。
const { data } = await http.get<unknown>(DEDUPE_GROUPS_ENDPOINT, { params: companyId != null ? { company_id: companyId } : {} })
return parseDedupeGroupOptionList(data)
}
@@ -20,23 +20,33 @@ export function exportStageHint(stage: DedupeExportStage): string | undefined {
}
}
/** 按导出可用筛选(用户名/日期区间/分组/国家)构建查询串;空白/非法条件不下发。 */
export function buildDedupeExportQuery(state: DedupeTotalFilterState): string {
const params = new URLSearchParams()
/** 按导出可用筛选(用户名/日期区间/分组/国家)构建查询参数;空白/非法条件不下发。
* 公司 tab 也在参数里:导出与列表必须同一个范围,否则「tab 筛了表格、导出给全量」就是越权泄露。 */
export function buildDedupeExportParams(
state: DedupeTotalFilterState,
companyId?: number | null,
): Record<string, string> {
const params: Record<string, string> = {}
const username = (state.username || '').trim()
const country = (state.country || '').trim()
if (username) params.set('username', username)
if (country) params.set('country', country)
if (username) params.username = username
if (country) params.country = country
const startDate = validIsoDateOrUndefined(state.startDate)
const endDate = validIsoDateOrUndefined(state.endDate)
if (startDate) params.set('start_date', startDate)
if (endDate) params.set('end_date', endDate)
if (typeof state.groupId === 'number' && state.groupId >= 1) params.set('group_id', String(state.groupId))
return params.toString()
if (startDate) params.start_date = startDate
if (endDate) params.end_date = endDate
if (typeof state.groupId === 'number' && state.groupId >= 1) params.group_id = String(state.groupId)
if (companyId != null) params.company_id = String(companyId)
return params
}
/** 按导出可用筛选构建查询串;条件编码与 URLSearchParams 一致。 */
export function buildDedupeExportQuery(state: DedupeTotalFilterState, companyId?: number | null): string {
return new URLSearchParams(buildDedupeExportParams(state, companyId)).toString()
}
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载。 */
export function toExportUrl(state: DedupeTotalFilterState): string {
const query = buildDedupeExportQuery(state)
export function toExportUrl(state: DedupeTotalFilterState, companyId?: number | null): string {
const query = buildDedupeExportQuery(state, companyId)
return query ? `${DEDUPE_TOTAL_EXPORT_ENDPOINT}?${query}` : DEDUPE_TOTAL_EXPORT_ENDPOINT
}
@@ -31,9 +31,11 @@ export function toDedupeListParams(
page: number,
pageSize: number,
lastId?: number | null,
companyId?: number | null,
): AsinListParams {
const params: AsinListParams = { page, pageSize }
if (typeof lastId === 'number' && lastId > 0) params.lastId = lastId
if (companyId != null) params.companyId = companyId
const keyword = (state.keyword || '').trim()
const username = (state.username || '').trim()
const country = (state.country || '').trim()
@@ -11,11 +11,11 @@ import {
export const PRODUCT_CATEGORY_ENDPOINT = '/api/admin/product-categories'
/** 拉取类目树(keyword 非空时由服务端过滤并保留父路径)。 */
export async function fetchProductCategoryTree(keyword = ''): Promise<ProductCategoryListResult> {
export async function fetchProductCategoryTree(keyword = '', companyId?: number | null): Promise<ProductCategoryListResult> {
const trimmed = keyword.trim()
const { data } = await http.get<unknown>(PRODUCT_CATEGORY_ENDPOINT, {
params: trimmed ? { keyword: trimmed } : {},
})
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,10 +24,12 @@ 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)
}
@@ -45,9 +47,11 @@ 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 }
@@ -2,9 +2,12 @@
export const PRODUCT_CATEGORY_EXPORT_ENDPOINT = '/api/admin/product-categories/export'
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载。 */
export function buildProductCategoryExportUrl(keyword: string): string {
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载。
* company_id 与列表同源:导出走的是同一个服务口径,不带它就是把别家类目写进同一份 XLSX。 */
export function buildProductCategoryExportUrl(keyword: string, companyId?: number | null): string {
const params: string[] = []
const trimmed = (keyword || '').trim()
if (!trimmed) return PRODUCT_CATEGORY_EXPORT_ENDPOINT
return `${PRODUCT_CATEGORY_EXPORT_ENDPOINT}?keyword=${encodeURIComponent(trimmed)}`
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
}
@@ -13,7 +13,11 @@ export const QUERY_ASIN_ENDPOINT = '/api/admin/query-asins'
export async function fetchQueryAsinList(params: Partial<QueryAsinListParams> = {}): Promise<QueryAsinPageResult> {
const normalized = normalizeQueryAsinParams(params)
const { data } = await http.get<unknown>(QUERY_ASIN_ENDPOINT, { params: toQueryAsinQuery(normalized) })
// normalizeQueryAsinParams 是白名单构造(不点名 companyId)⇒ 公司值必须从原始 params 读,
// 从 normalized 读是 undefined:请求发了、tab 画了、参数没有。
const query = toQueryAsinQuery(normalized)
if (params.companyId != null) query.company_id = params.companyId
const { data } = await http.get<unknown>(QUERY_ASIN_ENDPOINT, { params: query })
return parseQueryAsinPage(data)
}
@@ -34,12 +38,13 @@ export async function createQueryAsin(payload: QueryAsinCreatePayload): Promise<
return message || '保存成功'
}
/** 按分组加载店铺名列表(对齐 admin.js loadAsinShopNameOptions:100/页翻页聚合去重,上限 20 页)。 */
export async function fetchShopNamesByGroup(groupId: number): Promise<string[]> {
/** 按分组加载店铺名列表(对齐 admin.js loadAsinShopNameOptions:100/页翻页聚合去重,上限 20 页)。
* companyId 透传给 /shop-manages:不传的话候选字典是全平台的,建号弹窗能选到别家的店铺名。 */
export async function fetchShopNamesByGroup(groupId: number, companyId?: number | null): Promise<string[]> {
const names: string[] = []
const seen = new Set<string>()
for (let page = 1; page <= 20; page += 1) {
const result = await fetchShopManageList({ page, pageSize: 100, groupId })
const result = await fetchShopManageList({ page, pageSize: 100, groupId, companyId })
for (const shop of result.items) {
const name = (shop.shopName || '').trim()
if (name && !seen.has(name)) {
@@ -3,22 +3,32 @@ import { normalizeQueryAsinCountry, type QueryAsinFilterState } from './query-as
export const QUERY_ASIN_EXPORT_ENDPOINT = '/api/admin/query-asins/export'
/** 按导出可用筛选(分组/店铺名/ASIN/国家)构建查询串;空白/非法条件不下发,避免导出范围被误解。 */
export function buildQueryAsinExportQuery(state: QueryAsinFilterState): string {
const params = new URLSearchParams()
/** 按导出可用筛选(分组/店铺名/ASIN/国家)构建查询参数;空白/非法条件不下发,避免导出范围被误解。
* 公司 tab 也在参数里:导出与列表必须同一个范围,否则「tab 筛了表格、导出给全量」就是越权泄露。 */
export function buildQueryAsinExportParams(
state: QueryAsinFilterState,
companyId?: number | null,
): Record<string, string> {
const params: Record<string, string> = {}
const groupId = state.groupId
if (typeof groupId === 'number' && groupId >= 1) params.set('group_id', String(Math.floor(groupId)))
if (typeof groupId === 'number' && groupId >= 1) params.group_id = String(Math.floor(groupId))
const shopName = (state.shopName || '').trim()
if (shopName) params.set('shop_name', shopName)
if (shopName) params.shop_name = shopName
const asin = (state.asin || '').trim()
if (asin) params.set('asin', asin)
if (asin) params.asin = asin
const country = normalizeQueryAsinCountry(state.country)
if (country) params.set('country', country)
return params.toString()
if (country) params.country = country
if (companyId != null) params.company_id = String(companyId)
return params
}
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载;无筛选时为全量导出。 */
export function toQueryAsinExportUrl(state: QueryAsinFilterState): string {
const query = buildQueryAsinExportQuery(state)
/** 按导出可用筛选构建查询串;条件编码与 URLSearchParams 一致。 */
export function buildQueryAsinExportQuery(state: QueryAsinFilterState, companyId?: number | null): string {
return new URLSearchParams(buildQueryAsinExportParams(state, companyId)).toString()
}
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载;无筛选时为该公司(或全平台)的导出。 */
export function toQueryAsinExportUrl(state: QueryAsinFilterState, companyId?: number | null): string {
const query = buildQueryAsinExportQuery(state, companyId)
return query ? `${QUERY_ASIN_EXPORT_ENDPOINT}?${query}` : QUERY_ASIN_EXPORT_ENDPOINT
}
@@ -21,6 +21,8 @@ export interface QueryAsinListParams {
shopName?: string
asin?: string
country?: string
/** 公司 tab 的值。normalizeQueryAsinParams 是白名单构造、不点名它 ⇒ 发送口必须从原始入参读。 */
companyId?: number | null
}
export interface QueryAsinQuery {
@@ -30,6 +32,8 @@ export interface QueryAsinQuery {
shop_name?: string
asin?: string
country?: string
/** 下划线形:与 Java `@RequestParam(name = "company_id")` 逐字对齐。 */
company_id?: number
}
export function createQueryAsinFilterState(): QueryAsinFilterState {
@@ -12,7 +12,11 @@ export const SKIP_PRICE_ENDPOINT = '/api/admin/skip-price-asins'
export async function fetchSkipPriceList(params: Partial<SkipPriceListParams> = {}): Promise<SkipPricePageResult> {
const normalized = normalizeSkipPriceParams(params)
const { data } = await http.get<unknown>(SKIP_PRICE_ENDPOINT, { params: toSkipPriceQuery(normalized) })
// normalizeSkipPriceParams 是白名单构造(不点名 companyId),所以公司值只能从原始 params 读:
// 写成 normalized.companyId 是 TS 绿、运行时恒 undefined,请求照发而参数没有。
const query = toSkipPriceQuery(normalized)
if (params.companyId != null) query.company_id = params.companyId
const { data } = await http.get<unknown>(SKIP_PRICE_ENDPOINT, { params: query })
return parseSkipPricePage(data)
}
@@ -0,0 +1,40 @@
/** 最低价 ASIN 导出 URL 构建:按当前筛选下发 group_id/shop_name/asin/country/最低价区间
* (对齐 Java SkipPriceAsinController export 的 snake_case @RequestParam),纯逻辑。 */
import { normalizeAsinCountry } from './asin-country.ts'
import { normalizePriceInput, type SkipPriceFilterState } from './skip-price-filter.ts'
export const SKIP_PRICE_EXPORT_ENDPOINT = '/api/admin/skip-price-asins/export'
/** 按导出可用筛选构建查询参数;空白/非法条件不下发。
* 公司 tab 也在参数里:导出与列表必须同一个范围,否则「tab 筛了表格、导出给全量」就是越权泄露。 */
export function buildSkipPriceExportParams(
state: SkipPriceFilterState,
companyId?: number | null,
): Record<string, string> {
const params: Record<string, string> = {}
const groupId = state.groupId
if (typeof groupId === 'number' && groupId >= 1) params.group_id = String(Math.floor(groupId))
const shopName = (state.shopName || '').trim()
if (shopName) params.shop_name = shopName
const asin = (state.asin || '').trim()
if (asin) params.asin = asin
const country = normalizeAsinCountry(state.country)
if (country) params.country = country
const minimumPriceFrom = normalizePriceInput(state.minimumPriceFrom)
if (minimumPriceFrom !== null) params.minimum_price_from = String(minimumPriceFrom)
const minimumPriceTo = normalizePriceInput(state.minimumPriceTo)
if (minimumPriceTo !== null) params.minimum_price_to = String(minimumPriceTo)
if (companyId != null) params.company_id = String(companyId)
return params
}
/** 按导出可用筛选构建查询串;条件编码与 URLSearchParams 一致。 */
export function buildSkipPriceExportQuery(state: SkipPriceFilterState, companyId?: number | null): string {
return new URLSearchParams(buildSkipPriceExportParams(state, companyId)).toString()
}
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载;无筛选时导出该范围全量。 */
export function toSkipPriceExportUrl(state: SkipPriceFilterState, companyId?: number | null): string {
const query = buildSkipPriceExportQuery(state, companyId)
return query ? `${SKIP_PRICE_EXPORT_ENDPOINT}?${query}` : SKIP_PRICE_EXPORT_ENDPOINT
}
@@ -25,6 +25,8 @@ export interface SkipPriceListParams {
country?: string
minimumPriceFrom?: number | null
minimumPriceTo?: number | null
/** 公司 tab 的值。normalizeSkipPriceParams 是白名单构造、不点名它 ⇒ 由 toSkipPriceParams 显式补回。 */
companyId?: number | null
}
export interface SkipPriceQuery {
@@ -36,6 +38,8 @@ export interface SkipPriceQuery {
country?: string
minimum_price_from?: number
minimum_price_to?: number
/** 下划线形:与 Java `@RequestParam(name = "company_id")` 逐字对齐。 */
company_id?: number
}
export function createSkipPriceFilterState(): SkipPriceFilterState {
@@ -91,8 +95,9 @@ export function toSkipPriceParams(
state: SkipPriceFilterState,
page: number,
pageSize: number,
companyId?: number | null,
): SkipPriceListParams {
return normalizeSkipPriceParams({
const params = normalizeSkipPriceParams({
page,
pageSize,
groupId: state.groupId,
@@ -102,6 +107,8 @@ export function toSkipPriceParams(
minimumPriceFrom: normalizePriceInput(state.minimumPriceFrom),
minimumPriceTo: normalizePriceInput(state.minimumPriceTo),
})
if (companyId != null) params.companyId = companyId
return params
}
/** 前端查询参数 → Java 查询参数;与 SkipPriceAsinController @RequestParam(snake) 对齐,仅下发非空字段。 */
@@ -12,6 +12,8 @@ export interface InvalidAsinQuery {
dataValue?: string
brand?: string
groupId?: number | null
/** 公司 tab 的值;toQuery 是白名单构造、不点名它,所以由发送口从原始 query 读。 */
companyId?: number | null
}
function trimOrUndefined(value: unknown): string | undefined {
@@ -29,7 +31,11 @@ function toQuery(query: InvalidAsinQuery): Record<string, string | number> {
}
export async function fetchInvalidAsinPage(query: InvalidAsinQuery): Promise<InvalidAsinPageResult> {
const { data } = await http.get<unknown>(INVALID_ASIN_ENDPOINT, { params: toQuery(query) })
// 公司值落在 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 })
return parseInvalidAsinPage(data)
}
@@ -6,6 +6,7 @@
*/
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
import type { DuplicateItem, DuplicateOccurrence, DuplicateMetrics, DuplicateShop } from './duplicate-model.ts'
import { fetchDuplicateConsole, fetchDuplicateLedger, requestDuplicateExportBlob, type LedgerSortKey } from './duplicate-console-api.ts'
import { aggregateDrawerRows, drawerSummaryOf, dupWithinGroup, indexShopGroups, type DrawerAggRow, type DrawerSummary, type ShopGroups } from './duplicate-console-logic.ts'
@@ -24,6 +25,7 @@ const filter = reactive({ asin: '', shop: '', group: '', country: '', dateFrom:
/** 角色范围:超管可看全部分组店铺并可跨分组筛选;管理员数据已由后端裁剪到自己分组,无需分组筛选。 */
const session = useAdminSessionStore()
const companyTab = useCompanyTabStore()
const isSuper = computed(() => session.isSuperAdmin)
const activeTab = ref<Tab>('dup')
@@ -207,7 +209,7 @@ async function loadConsole() {
loading.value = true
loadError.value = ''
try {
consoleData.value = await fetchDuplicateConsole({ view: '', ...activeFilterParams() })
consoleData.value = await fetchDuplicateConsole({ view: '', ...activeFilterParams() }, companyTab.requestCompanyId)
shopGroups.value = indexShopGroups(orderedShops.value)
if (groupStats.value.length && !groupStats.value.some((group) => group.name === selectedGroup.value)) {
selectedGroup.value = groupChips.value[0] ? groupChips.value[0].name : ''
@@ -227,7 +229,14 @@ async function loadLedger(page: number, resetSort = false) {
sortState.key = 'earliest'
sortState.dir = 'asc'
}
const result = await fetchDuplicateLedger({ view: '', ...activeFilterParams() }, page, ledgerPageSize.value, sortState.key, sortState.dir)
const result = await fetchDuplicateLedger(
{ view: '', ...activeFilterParams() },
page,
ledgerPageSize.value,
sortState.key,
sortState.dir,
companyTab.requestCompanyId,
)
ledgerItems.value = result.items
ledgerTotal.value = result.total
ledgerPage.value = result.page
@@ -374,7 +383,7 @@ async function exportXlsx() {
params.shopName = selectedGroup.value
}
try {
const blob = await requestDuplicateExportBlob({ view, ...params }, view)
const blob = await requestDuplicateExportBlob({ view, ...params }, view, companyTab.requestCompanyId)
saveBlob(blob, `店铺数据_${activeTab.value === 'ledger' ? '台账' : '撞款'}_${new Date().toISOString().slice(0, 10)}.xlsx`)
toast('已导出 Excel')
} catch (error) {
@@ -396,6 +405,11 @@ function siteColor(code: string): string {
return map[code.toUpperCase()] || '#98A1B1'
}
// 切公司 = 重新取数。店铺/分组两个筛选项的候选字典本身就按公司收窄(/duplicate-check-console 的 shops/groups),
// 留着上一家选中的值会把新一家首屏筛成空页;分组范围(scope)一并回全店,否则切到没有分组的公司在
// loadConsole 的重挑分支(groupStats 为空时不触发)里留着一个不属于本公司的 selectedGroup。
watch(() => companyTab.activeId, () => { filter.shop = ''; filter.group = ''; selectedGroup.value = ''; scope.value = 'global'; void loadConsole(); void loadLedger(1) })
onMounted(() => {
loadConsole()
// 台账 Tab 计数打开即显示:挂载时预取第一页拿 total(对齐 reference 渲染即见台账条数)。
@@ -2,7 +2,7 @@
import { formatDateTime } from '@/utils/datetime'
/** 店铺数据记录页 · 像素复刻旧版 admin.html panel-shop-data-crawl-tasks(自绘:form-box 筛选[h4 筛选条件] + panel-box toolbar[全选/批量下载/权限配置/汇总] + 每店卡片网格 + 旧式分页(店铺级+卡片级 9/页))。
* script 逻辑沿用现有 Vue 实现(批量打包/删除结果文件[保留]/权限授权)。 */
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { asinCountryLabel } from '../asin/asin-country.ts'
import { createShopDataFilter, type ShopDataFilter } from './shop-data-filter.ts'
@@ -25,9 +25,11 @@ import {
toggleShopDataSelection,
} from './shop-data-selection.ts'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
import OldPagination from '@/components/OldPagination.vue'
const session = useAdminSessionStore()
const companyTab = useCompanyTabStore()
const loading = ref(false)
const groups = ref<ShopDataTaskGroup[]>([])
const totalShops = ref(0)
@@ -120,7 +122,7 @@ function toFilter(): ShopDataFilter {
async function load() {
loading.value = true
try {
const result = await fetchShopDataTaskList(toFilter(), page.value, pageSize.value)
const result = await fetchShopDataTaskList(toFilter(), page.value, pageSize.value, companyTab.requestCompanyId)
groups.value = result.items
totalShops.value = result.total
page.value = result.page
@@ -296,6 +298,11 @@ async function savePermission() {
const grantedCount = computed(() => grantedUserIds(permissionItems.value).length)
// 切公司 = 重新取数,并把上一家的两处遗留一起清掉:
// ① 店铺名/分组名是自由文本筛选项,上一家填的值在新一家的可见集里不存在 ⇒ 首屏筛成空页;
// ② 勾选集住的是 resultId,跨公司留着会让「批量下载」把别家店铺的结果文件打进同一个 zip。
watch(() => companyTab.activeId, () => { filter.shopName = ''; filter.groupName = ''; selection.value = createShopDataSelection(); page.value = 1; cardPage.value = 1; void load() })
onMounted(load)
</script>
@@ -33,10 +33,15 @@ function toConsoleQuery(filter: DuplicateFilter): Record<string, string> {
export type LedgerSortKey = 'asin' | 'brand' | 'store_count' | 'record_count' | 'earliest' | 'latest'
/** 加载撞款控制台快照:GET /duplicate-check-console。 */
export async function fetchDuplicateConsole(filter: DuplicateFilter): Promise<DuplicateConsole> {
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-console`, {
params: toConsoleQuery(filter),
})
export async function fetchDuplicateConsole(
filter: DuplicateFilter,
companyId?: number | null,
): Promise<DuplicateConsole> {
// toConsoleQuery 是白名单构造(只点名 asin/shop_name/group/country/site/date_*),
// 公司值只许落在本函数自己的 companyId 形参上。
const query: Record<string, string | number> = toConsoleQuery(filter)
if (companyId != null) query.company_id = companyId
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-console`, { params: query })
return parseDuplicateConsole(data)
}
@@ -47,18 +52,26 @@ export async function fetchDuplicateLedger(
pageSize: number,
sortKey: LedgerSortKey | '',
sortDir: 'asc' | 'desc',
companyId?: number | null,
): Promise<LedgerPage> {
const params: Record<string, string | number> = { ...toConsoleQuery(filter), page, page_size: pageSize }
if (sortKey) params.sort_key = sortKey
params.sort_dir = sortDir
if (companyId != null) params.company_id = companyId
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-ledger`, { params })
return parseLedgerPage(data)
}
/** 导出 Excel(撞款 view=monitor / 台账 view=all):GET /duplicate-check-export → xlsx Blob。 */
export async function requestDuplicateExportBlob(filter: DuplicateFilter, view: string): Promise<Blob> {
export async function requestDuplicateExportBlob(
filter: DuplicateFilter,
view: string,
companyId?: number | null,
): Promise<Blob> {
const itemsQuery = toDuplicateItemsQuery({ ...filter, view }, 1, 100)
if (companyId != null) itemsQuery.company_id = companyId
const { data } = await http.get<Blob>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-export`, {
params: toDuplicateItemsQuery({ ...filter, view }, 1, 100),
params: itemsQuery,
responseType: 'blob',
})
return data
@@ -27,6 +27,7 @@ export interface DuplicateItemsQuery {
site?: string
date_from?: string
date_to?: string
company_id?: number
}
function textOrUndefined(value: unknown): string | undefined {
@@ -14,10 +14,13 @@ export async function fetchShopDataTaskList(
filter: ShopDataFilter,
page: number,
pageSize: number,
companyId?: number | null,
): Promise<ShopDataTaskPageResult> {
const { data } = await http.get<unknown>(SHOP_DATA_CRAWL_TASKS_ENDPOINT, {
params: toShopDataQuery(filter, page, pageSize),
})
// toShopDataQuery 是白名单构造(只点名 shop_name/group_name/country/created_*),
// 公司值只许落在本函数自己的 companyId 形参上。
const query = toShopDataQuery(filter, page, pageSize)
if (companyId != null) query.company_id = companyId
const { data } = await http.get<unknown>(SHOP_DATA_CRAWL_TASKS_ENDPOINT, { params: query })
return parseShopDataTaskPage(data)
}
@@ -23,6 +23,7 @@ export interface ShopDataQuery {
country?: string
created_from?: string
created_to?: string
company_id?: number
}
export function createShopDataFilter(): ShopDataFilter {
+8 -8
View File
@@ -18,13 +18,13 @@ export interface AdminPageDef extends AdminPageMeta {
/** 业务域路由注册表(任务 8):首批 account 域;后续按业务域在此登记页面。 */
export const adminPages: AdminPageDef[] = [
{ path: 'account/users', menuKey: 'admin_users', title: '用户管理', load: () => import('@/pages/account/UsersPage.vue') },
{ 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/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: '店铺撞款监控', load: () => import('@/pages/tasks/DuplicateCheckPage.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/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') },
@@ -34,12 +34,12 @@ export const adminPages: AdminPageDef[] = [
{ 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: '店铺数据记录', load: () => import('@/pages/tasks/ShopDataTasksPage.vue') },
{ path: 'asin-center/registry', menuKey: 'admin_dedupe_total_data', title: '数据去重总数据', load: () => import('@/pages/asin/DedupeRegistryPage.vue') },
{ path: 'asin-center/invalid', menuKey: 'admin_invalid_asin_data', title: '不符合ASIN数据', load: () => import('@/pages/asin/AsinInvalidPage.vue') },
{ path: 'asin-center/query', menuKey: 'admin_query_asin', title: '查询ASIN', load: () => import('@/pages/asin/QueryAsinPage.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', load: () => import('@/pages/asin/SkipPricePage.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/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/skip-price', menuKey: 'admin_skip_price_asin', title: '最低价ASIN', companyScoped: true, load: () => import('@/pages/asin/SkipPricePage.vue') },
]
export function routeOf(page: AdminPageDef): RouteRecordRaw {
@@ -88,7 +88,12 @@ test('align_dup_console_role_scope_group_controls_only_super', () => {
assert.match(page, /<div v-if="isSuper" class="scope-bar">/, '分组撞款分段仅超管可见')
assert.match(page, /v-if="isSuper" class="btn btn-ghost btn-sm" type="button" @click="groupInfoVisible = true"/, '分组说明按钮仅超管可见')
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/service/ShopDataDuplicateCheckQueryService.java')
assert.match(service, /if \(superAdmin\) \{\s*return null;/, '超管可见范围=全量(null)')
// 2026-10-05 批次 3 之后「超管全量」不再是 `if (superAdmin) return null`,而是"超管且没切公司 tab(成员集为 null)"。
// 逐字判据 + 空成员集那支一起钉:后者一旦退化成 null,第二家公司会看到全部店铺(语义由
// ShopDataDuplicateCheckCompanyScopeTest 用真调用验,这里只保证源码形状没被顺手改回去)。
assert.match(service, /if \(companyMemberIds == null\) \{\s*return null;/, '超管未切公司 tab=全量(null)')
assert.match(service, /companyMemberIds\.isEmpty\(\)\s*\?\s*new LinkedHashSet<>\(\)/,
'公司一个账号都没有=空可见集,不许退化成 null')
assert.match(service, /selectManagedShopNames\(operatorId\)/, '管理员可见范围=所管分组店铺')
})
@@ -17,7 +17,9 @@ const EXCEPTED_KEY = 'admin_shop_data_duplicate_check'
test('align_guide_users_matches_reference_text', () => {
const g = operationGuideFor('admin_users')
assert.ok(g)
assert.equal(g.text, '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。')
// 批次 4 起这页参与公司 tab ⇒ 原文之后追加那句 §9.3,不再逐字相等(同 group-manage 那处故意偏离)。
assert.match(g.text, /^先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。/)
assert.match(g.text, /超级管理员可用页面上方的公司 tab 切换公司/)
assert.deepEqual(g.steps, ['筛选账号', '编辑权限', '确认保存'])
})
@@ -85,18 +87,25 @@ test('align_guide_fallback_shape', () => {
test('guide_copy_carries_company_tab_note_for_every_scoped_page', () => {
// spec §9.3:tab 会改行数观感,承载方式是既有引导文案(不新做控件)。
// 分母=COMPANY_SCOPED_PAGES,杜绝"加了一页忘了补文案"。
const need = COMPANY_SCOPED_PAGES.map((p) => p.menuKey)
assert.ok(need.length >= 8, '取样集非空自检:注册表应当至少有 8 页进了 tab 范围')
// 唯一豁免 = EXCEPTED_KEY(撞款监控不展示提示条,那句没有可挂的地方);豁免是**显式列出的**,
// 新页缺文案仍会红(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(scopedKeys.includes(EXCEPTED_KEY),
'取样集前提自检:撞款监控已不在 COMPANY_SCOPED_PAGES 里,上面那道豁免就成了空豁免——把它连同 EXCEPTED_KEY 一起删掉')
for (const key of need) {
const g = operationGuideFor(key)
assert.ok(g, `注册表页缺 guide: ${key}`)
assert.match(g.text, /超级管理员可用页面上方的公司 tab 切换公司/, `${key} 缺 §9.3 那句`)
}
// C 类两页(spec §5):它们要的是**另一句**——"这页不参与",不是"会随 tab 变"。
// C 类页(spec §5):它们要的是**另一句**——"这页不参与",不是"会随 tab 变"。
// 分母**取注册表里显式写 companyScoped:false 的页**,不抄名单:漏写一条 ⇒ 这支在自检那句红。
// 批次 2 之前这里是 2 页(店铺密钥 + 商品类目),商品类目已接上公司口径 ⇒ 今天只剩 admin_shop_keys
// 一条,所以自检降到 1;再往下掉就是有人把注册表里那条 false 改成不写(不写 = 不参与但没人说)。
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 >= 2, '取样集非空自检:注册表里显式 companyScoped:false 的至少 C 类那两页')
assert.ok(cClass.length >= 1, '取样集非空自检:注册表里显式 companyScoped:false 的一条都不剩了——那这句判据就是空跑')
for (const key of cClass) {
assert.equal(scoped.has(key), false, `${key} 既声明 false 又在清单里,两处口径打架`)
const g = operationGuideFor(key)
@@ -111,7 +120,7 @@ test('guide_copy_carries_company_tab_note_for_every_scoped_page', () => {
// 反向分母取 OPERATION_GUIDES 的全部 key(不是 adminPages):没带文案的页走 fallback,由下面那支单独钉。
const withTabNote = Object.keys(OPERATION_GUIDES).filter((k) => operationGuideFor(k)!.text.includes('公司 tab 切换公司'))
assert.deepEqual(withTabNote.sort(), [...need].sort(),
'tab 那句只能出现在 COMPANY_SCOPED_PAGES 那 8 页:多一页 = 把公司 tab 端给一页不参与 tab 的页')
'tab 那句只能出现在 COMPANY_SCOPED_PAGES 那 ' + need.length + ' 页:多一页 = 把公司 tab 端给一页不参与 tab 的页')
const withNotAppliedNote = Object.keys(OPERATION_GUIDES).filter((k) => operationGuideFor(k)!.text.includes('全平台共享,不按公司区分'))
assert.deepEqual(withNotAppliedNote.sort(), [...cClass].sort(),
'「本页不参与」那句只能出现在注册表显式 companyScoped:false 的页:多一页 = 给了它没有的口径')
@@ -4,7 +4,7 @@ import { readdirSync, statSync } from 'node:fs'
import { join } from 'node:path'
import { readSource } from './helpers.ts'
import { adminPages } from '../src/router/routes.ts'
import { SUPER_ADMIN_ONLY_MENU_KEYS } from '../src/config/company-scope.ts'
import { COMPANY_SCOPED_PAGES, SUPER_ADMIN_ONLY_MENU_KEYS } from '../src/config/company-scope.ts'
/** 递归扫 src 下指定后缀的文件(相对路径统一正斜杠)。
* 不走 execSync('grep'):node 在 Windows 上把 execSync 交给 cmd.exe,那里没有 grep,
@@ -70,3 +70,27 @@ test('公司列表的读路径不靠 canManage 把关(把关只有两处:Tas
assert.equal(loader.includes('canManage'), false,
'loadCompanies 里不许出现 canManage:列表可见性由入口剪枝和后端决定,前端再加一道就变成第三套口径')
})
/** 公司 tab 唯一取值口的调用签名。
* 必须带括号:光匹配标识符会把 `import { useCompanyTabStore } from '@/stores/company-tab'` 也算成消费者 ⇒
* 「import 留着、调用删了」这种变异会存活。 */
const STORE_USE_TOKEN = 'useCompanyTabStore()'
test('吃公司 tab 的页面集合恰好等于 COMPANY_SCOPED_PAGES 的 pageFiles(公司管理页永远不在其中)', () => {
// 控制方 2026-10-05:「公司管理菜单仅 admin 账号可见,不需要做公司 tab」。
// 这条是 SUPER_ADMIN_ONLY_MENU_KEYS ∩ COMPANY_SCOPED_PAGES = ∅(company-tab-wiring:687)的反向尺子:
// 那条比的是两张**清单**,这条比的是**代码真值**——有人往 CompaniesPage.vue 里塞 companyTab 时,
// 清单可以一字不改而界面已经变了。
// 范围只扫 src/pages:src/layout/CompanyTabs.vue 渲染 tab 条本身、src/stores/company-tab.ts 是定义处,
// 两者都不是「一页」,把它们算进分母会让断言变成常量自比。
const consumers = filesWithSuffix(['.vue'])
.filter((rel) => rel.startsWith('src/pages/'))
.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})或页面文件本身出了问题`)
assert.deepEqual(consumers, declared,
'公司 tab 的消费者与清单对不上:多出来的一页=悄悄给一页不参与隔离的页上了 tab(公司管理就属于这类),'
+ '少掉的一页=清单声明它隔离但页面根本没取值')
})
@@ -45,9 +45,12 @@ test('剪枝是纯函数且幂等(store 里会反复调用)', () => {
assert.deepEqual(pruneSuperAdminOnly(once, false), once)
})
test('C 类两页必须显式声明 companyScoped: false(spec §5:声明,不是遗漏)', () => {
test('不参与 tab 的页必须显式声明 companyScoped: false(spec §5:声明,不是遗漏)', () => {
// 留空和 false 运行时等价,但只有 false 是"读过普查、决定不参与"的证据。
for (const key of ['admin_shop_keys', 'admin_product_categories']) {
// 名单批次 1 是两页(店铺密钥 + 商品类目);商品类目在批次 2(2026-10-05)接上了公司口径,
// 今天只剩紫鸟令牌这一页真的是"全平台共享、与公司无关"。
// 想再往这页上加 false 的对向(把某页改回 false)不用改这里:上面那条双向对账会红。
for (const key of ['admin_shop_keys']) {
const page = adminPages.find((p) => p.menuKey === key)
assert.ok(page, `注册表里找不到 ${key}`) // 取样非空自检
assert.equal(page.companyScoped, false, `${key} 必须显式写 companyScoped: false,不能留空`)
@@ -41,42 +41,100 @@ const TASK_CENTER_SEND_LINE = 'if (companyId != null) query.company_id = company
* - 从 `function` 这个词的头起算(旧举证用的口径,比上组各多 33~36):154/147/196/238/244 与 471/726/(无)/877/(无)。
* ⇒ 320 够得着自己的行(最紧 217),够不到隔壁(最紧 438,余量 **118 字符**):删掉任一处,那条 shape 就匹配不出
* (不是"文件里还有别人在发"就算过)。
* ⚠ 下面那段「拆条取样自检·负样本」只证明「窗口有界」,它跟着 `TASK_CENTER_WINDOW` 自动缩放 ⇒ **证明不了余量还在**。
* ⚠ 下面那段「拆条取样自检·负样本」只证明「窗口有界」,它跟着窗口预算自动缩放 ⇒ **证明不了余量还在**。
* 把 320 调大之前必须按第一组口径重测这五个数;api 函数体写长会先假红(fail-closed,可接受)。
* 批次 2 起这一档改成 `SendPoint.window`(每处一个值),举证不再靠这段注释,
* 而由「窗口与真文件对平」那条用例逐处重测 own/next。
*/
const TASK_CENTER_WINDOW = 320
/** 一个登记项 = 一个字面发送口(一函数一处、逐处一条,一条都不许并)。 */
interface SendPoint {
readonly menuKey: string
readonly file: string
/** 这一处所在函数的名字:shape 锚在 `function <fn>(` 的括号后,红点直接报到函数。 */
readonly fn: string
/** 塞键那一整行(缩进不入锚串)。整行入锚而不只锚 `company_id = companyId`:
* 评审把 `params.companyId` 改成 `normalized.companyId` 时形状判据(复评 I-2)要能红,
* 锚右半边的字面量才是举证。 */
readonly line: string
/** 从 `function <fn>(` 括号后到自己那一行的字符预算,见上面 TASK_CENTER_WINDOW 的注释。 */
readonly window: number
readonly title: string
}
/** 正则字面量转义:`line` 里带 `( ) . = { } $ [ ]` 与反引号,不转义就匹配到别处(sendArgsShape 同一把尺子)。 */
function escapeRegExp(text: string): string {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
/**
* 这一页的 5 处 `company_id` 发送口(2026-10-05 修复轮 1,复评 I-1)。
* 全部 22 个字面发送口:批次 1 的任务看板 5 处 + 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页)12 处
* + 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」那两页)4 处
* + 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」里的用户管理)1 处。
*
* <p>为什么从 2 条文件级钉拆成 5 条:`shape` 的求值是整文件 `RegExp.test`(不数次数),
* 评审实测「删掉 5 处里的任何一处」在两条文件级钉下**双双仍为 true**——包括 brief
* `task-10-brief.md:14` 点名的那一处(`fetchTaskCenterTaskDetail` 少带参数 ⇒ 超管在别家 tab 下按
* taskNo 读别家详情照样 200,这一页的护栏恰好全落在前端)。`vue-tsc` 也救不了:tsconfig 没开
* `noUnusedParameters`,删了塞键那一行、留一个没人用的形参,编译器不响。</p>
* <p>`window` 的取法:本轮实扫的 own(到自己那行的距离)+ ≥150 余量,且当同文件还有下一个同名发送口时必须
* `window < next`。own/next 不写死在这里——下面「窗口与真文件对平」那条用例逐处从真文件重算,
* `own >= window`(函数体写长)或 `window >= next`(窗口够到隔壁)都当场红。</p>
*
* <p>选「拆条」而不是「计数」(`occurrences()` 数 api=3 / model=2):计数不回答「哪三处」,
* 把一处重复写三遍、另一处删掉,计数照样绿;函数名锚 + 有界窗口才把判据绑到发送口自己的身份上。
* 形状照 `admin_shop_manage` 的先例(同一个文件两条 pin,「两条各管一处取值口,不许合成一条 alternation」)。</p>
* <p>三个 `*-export.ts` 的 own 天生比 api 侧大(构造器是多行签名 + 一串前置筛选条件:625/528/827),
* 它们的 `line` 在同文件只出现 1 次(对平闸门数得出),所以"窗口会不会够到隔壁"在这一族是空命题,
* 真正的看守是「这一处脱管就没人钉」。</p>
*
* <p>`shape` 与取样样本同源于这张表(都由 fn/window 现算),不会出现「钉改了、自检还测旧串」的漂移。</p>
* <p>批次 3 的撞款控制台三个发送口把塞键行的左值各起一个名字(query / params / itemsQuery):
* 三处若逐字同行,(文件, 整行) 分组会把它们并成一组、要求钉 3 条,而「窗口够不到隔壁」这条判据
* 在同一行重复时才有意义——左值不同名既是真代码的样子,也让每条钉各自点到唯一一个发送口。</p>
*/
const TASK_CENTER_SEND_POINTS: ReadonlyArray<{ readonly file: string; readonly fn: string; readonly title: string }> = [
{ file: 'src/api/task-center.ts', fn: 'fetchTaskCenterOverview', title: 'GET /overview 汇总卡' },
{ file: 'src/api/task-center.ts', fn: 'fetchTaskCenterShopOptions', title: 'GET /shop-options 店铺候选' },
{ file: 'src/api/task-center.ts', fn: 'fetchTaskCenterTaskDetail', title: 'GET /tasks/detail 详情(brief 点名那一处)' },
{ file: 'src/pages/task-center/task-center-model.ts', fn: 'buildTaskQuery', title: '任务列表 query 构造器' },
{ file: 'src/pages/task-center/task-center-model.ts', fn: 'buildVariantQuery', title: '变体采集 query 构造器' },
const SEND_POINTS: ReadonlyArray<SendPoint> = [
{ menuKey: 'admin_task_center', file: 'src/api/task-center.ts', fn: 'fetchTaskCenterOverview', line: TASK_CENTER_SEND_LINE, window: TASK_CENTER_WINDOW, title: 'GET /overview 汇总卡' },
{ menuKey: 'admin_task_center', file: 'src/api/task-center.ts', fn: 'fetchTaskCenterShopOptions', line: TASK_CENTER_SEND_LINE, window: TASK_CENTER_WINDOW, title: 'GET /shop-options 店铺候选' },
{ menuKey: 'admin_task_center', file: 'src/api/task-center.ts', fn: 'fetchTaskCenterTaskDetail', line: TASK_CENTER_SEND_LINE, window: TASK_CENTER_WINDOW, title: 'GET /tasks/detail 详情(brief 点名那一处)' },
{ menuKey: 'admin_task_center', file: 'src/pages/task-center/task-center-model.ts', fn: 'buildTaskQuery', line: TASK_CENTER_SEND_LINE, window: TASK_CENTER_WINDOW, title: '任务列表 query 构造器' },
{ menuKey: 'admin_task_center', file: 'src/pages/task-center/task-center-model.ts', fn: 'buildVariantQuery', line: TASK_CENTER_SEND_LINE, window: TASK_CENTER_WINDOW, title: '变体采集 query 构造器' },
{ 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 指标/店铺/撞款全集/分组统计' },
{ menuKey: 'admin_shop_data_duplicate_check', file: 'src/pages/tasks/duplicate-console-api.ts', fn: 'fetchDuplicateLedger', line: 'if (companyId != null) params.company_id = companyId', window: 400, title: 'GET /duplicate-check-ledger 全部 ASIN 台账分页' },
{ menuKey: 'admin_shop_data_duplicate_check', file: 'src/pages/tasks/duplicate-console-api.ts', fn: 'requestDuplicateExportBlob', line: 'if (companyId != null) itemsQuery.company_id = companyId', window: 400, title: 'GET /duplicate-check-export 导出(不带就导全平台)' },
{ 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 用户列表(后端早就认这个参数,断的是前端没发)' },
]
/** 一个发送口一条钉:锚在自己的函数开行上,要求窗口内出现「塞键」那一行。 */
function sendPointShape(fn: string): RegExp {
return new RegExp(`function ${fn}\\([\\s\\S]{0,${TASK_CENTER_WINDOW}}company_id\\s*=\\s*companyId\\b`)
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径)。 */
const TASK_CENTER_SEND_POINTS: ReadonlyArray<SendPoint> =
SEND_POINTS.filter((p) => p.menuKey === 'admin_task_center')
/** 一条钉 = 一个发送口:锚在自己的函数开行上,要求窗口内出现「塞键」那一整行。 */
function pointShape(p: SendPoint): RegExp {
return new RegExp(`function ${p.fn}\\([\\s\\S]{0,${p.window}}${escapeRegExp(p.line)}`)
}
/** 正样本用的迷你源码:函数开行 + 它自己那行塞键(缩进、形状逐字照抄真实发送口)。 */
function sendPointCompliant(fn: string): string {
return `function ${fn}(companyId?: number | null) {\n const query: QueryParams = {}\n ${TASK_CENTER_SEND_LINE}\n`
function pointCompliant(p: SendPoint): string {
return `function ${p.fn}(companyId?: number | null) {\n const query: QueryParams = {}\n ${p.line}\n`
}
/** 同一页的取值口钉由 SEND_POINTS 现算,不许手写:手写会和表漂开(复评 I-1 拆条的初衷)。 */
function pinsFor(menuKey: string): readonly CompanyIdPin[] {
return SEND_POINTS.filter((p) => p.menuKey === menuKey).map((p) => ({
file: p.file,
shape: pointShape(p),
note: `发送口 ${p.fn}(${p.title}):company_id 的右半边必须是本函数自己的入参(表里登记的整行锚),`
+ '值由页面传 companyTab.requestCompanyId;红点归属见「窗口与真文件对平」那条用例',
}))
}
const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>> = {
@@ -97,16 +155,10 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
note: 'filter 走 toImageVideoQuery 白名单构造,公司值只能落在 companyId 形参上',
},
],
// 五个发送口五条钉(一函数一条),不是一条文件级钉数五处:判据形状见 TASK_CENTER_SEND_POINTS 的举证。
// 五个发送口五条钉(一函数一条),不是一条文件级钉数五处:判据形状见 SEND_POINTS 的举证。
// 这一页也不许套 Task 8 的 `params.companyId` 形——api 侧 `tasks`/`variant-tasks` 是 `params: QueryParams`
// 直传、没有 params.companyId 这个口,公司键由 model 那两个 builder 补进同一个对象。
admin_task_center: TASK_CENTER_SEND_POINTS.map((p, i) => ({
file: p.file,
shape: sendPointShape(p.fn),
note: `发送口 ${i + 1}/5 ${p.title}(${p.fn}):null 由发送口自己丢(不依赖 axios 丢 null),`
+ '右半边必须是本函数自己的形参 companyId;红点归属见下面「拆条的补集」那段——删掉塞键那一行报在对平闸门,'
+ '这条 shape 独家点名的是计数不掉的形变(函数名改了、或那一行离自己函数开行超过了窗口)',
})),
admin_task_center: pinsFor('admin_task_center'),
admin_user_secret_usage: [
{
file: 'src/api/user-secret-usage.ts',
@@ -154,6 +206,17 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
note: '列表窄了而下拉不窄 = 两页口径对不上,且下拉能选到别家的组',
},
],
// 批次 2 的五页:取值口钉全部由 SEND_POINTS 现算(一页几处发送口就几条钉),
// 手写一份就会和表漂开——那正是复评 I-1 拆条要避免的形状。
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'),
}
/** 严格判据的分母由本轮实扫得出(修完不许恒绿也不许恒红):求值了几条 shape、其中几条通过。 */
@@ -236,29 +299,28 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
&& COMPANY_ID_SOURCE_PINS.admin_image_video_tasks.some((p) => p.shape !== null),
'Task 8 已接线的两页在登记表里的 shape 被改回 null 了:严格判据对这两页不再起作用(正样本归零)')
// —— I-1 拆条那 5 条钉的取样自检(全局约束 15:反向钉必须自带同支正样本,
// —— 取值口拆条钉的取样自检(全局约束 15:反向钉必须自带同支正样本,
// 不许让另一支用例替我证明"这串本来就会被匹配到")。
// ⚠ 身份要说清:下面这几条是对**字面量字符串**求值的探针,只证明判据形状没写坏
// (正样本匹配得出 ⇒ 不恒红;窗口外的负样本不匹配 ⇒ 窗口真有界,删一处不会靠隔壁过关),
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那 5 条 shape 对真实文件的求值 + 变异自证。
// ⚠ 这条 length 比对**按构造恒真**(2026-10-05 复评 N-2):登记表条目就是 `TASK_CENTER_SEND_POINTS.map(...)`,
// 删表一行两边同时变成 4,它一声不响。它只剩一种防御对象——有人把那个 `.map()` 换成手写 N 条字面 pin;
// 「删表一行」的真红点在下面「拆条的补集」那条逐文件对平闸门(它的分母取自源码里的字面发送口,与表不同源)。
assert.equal(COMPANY_ID_SOURCE_PINS.admin_task_center.length, TASK_CENTER_SEND_POINTS.length,
`登记表条数与 TASK_CENTER_SEND_POINTS 条数不等 ⇒ 上面那条 .map() 被换成了手写 pin 且数量不符`
+ `(表 ${TASK_CENTER_SEND_POINTS.length} 条 / 登记表 ${COMPANY_ID_SOURCE_PINS.admin_task_center.length} 条)`)
for (const p of TASK_CENTER_SEND_POINTS) {
const shape = sendPointShape(p.fn)
const compliant = sendPointCompliant(p.fn)
// 任何代码注入都不会让它们红。真覆盖 = 上面 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 条)⇒ 有人把钉从表里摘了,取值口看守成空`)
for (const p of SEND_POINTS) {
const shape = pointShape(p)
const compliant = pointCompliant(p)
assert.ok(shape.test(compliant),
`(拆条取样自检·正样本)${p.fn} 的合规样本都匹配不出 ${shape} ⇒ 这条钉恒红,删没删发送口都会红,等于没看守`)
const deleted = compliant.replace(` ${TASK_CENTER_SEND_LINE}\n`, '')
+ ' '.repeat(TASK_CENTER_WINDOW + 1) + TASK_CENTER_SEND_LINE
const deleted = compliant.replace(` ${p.line}\n`, '')
+ ' '.repeat(p.window + 1) + p.line
assert.equal(shape.test(deleted), false,
`(拆条取样自检·负样本)${p.fn} 删掉自己那一行、只剩窗口外的隔壁发送口却仍然匹配 ⇒ 窗口够得到了隔壁,删一处不会红`)
}
// 拆条的补集(复评 I-1 的另一半):一条钉管一个发送口 ⇒ 每个文件登记的钉数必须等于该文件里发送口的实际条数。
// 拆条的补集(复评 I-1 的另一半):一条钉管一个发送口 ⇒ 每个 (文件, 塞键整行) 登记的钉数
// 必须等于它在该文件的实际条数。
// 红点归属要说实(2026-10-05 复评 N-1):shape 不匹配只往 gaps 里记,得等本用例末尾的
// `assert.deepEqual(problems, [])` 才喊,而这条闸门在同一 test 体内**先执行** ⇒
// 「删源码里的塞键那一行」(变异自证 M1–M5 就是这一形)实际报的是这里的「钉数 ≠ 实际条数」消息
@@ -268,21 +330,65 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
// 这一条杀的是「把 TASK_CENTER_SEND_POINTS 删剩 4 行」——少一条钉就等于少一处看守,而 5 条 shape 谁都不会红。
// 路线 ②(occurrences 计数)在这里只当"钉数与发送口条数对平"的闸门,不当"是哪一处"的判据:
// 计数回答不了"哪三处"(把一处重复写三遍、另一处删掉,计数照样对平),所以主判据仍是路线 ① 的函数名锚 + 有界窗口。
const pinnedPerFile = new Map<string, number>()
for (const p of TASK_CENTER_SEND_POINTS) {
pinnedPerFile.set(p.file, (pinnedPerFile.get(p.file) ?? 0) + 1)
// 分母按 (文件, 整行) 而不是按文件:批次 2 的 product-category-api.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) {
const key = p.file + '|' + p.line
const hit = grouped.get(key)
if (hit) hit.pinned += 1
else grouped.set(key, { file: p.file, line: p.line, pinned: 1 })
}
assert.equal(pinnedPerFile.size, 2,
`发送口表应当只覆盖 api + model 这 2 个文件,现在却有 ${pinnedPerFile.size} 个 —— 表被改形状了,对平判据失去分母`)
for (const [file, pinned] of pinnedPerFile) {
const actual = occurrences(stripComments(read(file)), TASK_CENTER_SEND_LINE)
assert.equal(pinned, actual,
`${file} 里实际有 ${actual} 处「${TASK_CENTER_SEND_LINE}」,登记表却只钉了 ${pinned} 条 —— `
+ '有一处发送口脱管(一函数一钉:钉数必须与该文件的发送口条数逐文件对平)')
assert.equal(grouped.size, 17,
`发送口表按 (文件, 整行) 应聚成 17 组(22 处发送口),现在却有 ${grouped.size} 组 —— 表被改形状了,对平判据失去分母`)
for (const g of grouped.values()) {
const actual = occurrences(stripComments(read(g.file)), g.line)
assert.equal(g.pinned, actual,
`${g.file} 里实际有 ${actual} 处「${g.line}」,登记表却只钉了 ${g.pinned} 条 —— `
+ '有一处发送口脱管(一函数一钉:钉数必须与该文件该行的实际条数对平)')
}
// 同支正样本(全局约束 15:计数判据不许"0 == 0 也算对平"就当自己成立):字面样本里有两条,occurrences 必须数得出 2。
assert.equal(occurrences(sendPointCompliant('f') + sendPointCompliant('g'), TASK_CENTER_SEND_LINE), 2,
'(计数取样自检·正样本)occurrences 连两条字面发送口都数不出来 ⇒ 上面那条逐文件对平恒真,等于没看守')
const twoSendLines = `function f() {\n ${TASK_CENTER_SEND_LINE}\n}\nfunction g() {\n ${TASK_CENTER_SEND_LINE}\n}\n`
assert.equal(occurrences(twoSendLines, TASK_CENTER_SEND_LINE), 2,
'(计数取样自检·正样本)occurrences 连两条字面发送口都数不出来 ⇒ 上面那条逐行对平恒真,等于没看守')
// 窗口预算与真文件对平:批次 2 把上面 TASK_CENTER_WINDOW 那段"320 够得着自己、够不到隔壁"的举证从注释挪进代码,
// 逐处从**当前源码**重算两个距离,注释过期也不会骗人:
// own = 从 `function <fn>(` 的括号后到自己那一行的距离 ⇒ 必须 < window(函数体写长 = 假红,fail-closed 可接受);
// next = 到同文件**下一条同名发送行**开头的距离 ⇒ 存在时必须 > window(否则删一处还有隔壁顶着,这条钉就是摆设)。
// 隔壁的"名字"用的是自己的整行,所以 next 只在同文件有逐字同行的另一处时才有意义:
// product-category-api.ts 三处同行(next 实测 705/929/无)是这一族唯一的真冲突面,其余 14 处 own 唯一。
for (const p of SEND_POINTS) {
const src = stripComments(read(p.file))
const anchor = 'function ' + p.fn + '('
const anchorCount = occurrences(src, anchor)
assert.equal(anchorCount, 1,
`${p.file} 里「${anchor}」出现 ${anchorCount} 次(要求 1):函数改名或被复制,这条按函数名钉的看守就对不上是谁发的`)
const open = src.indexOf(anchor) + anchor.length
const own = src.indexOf(p.line, open) - open
assert.ok(own >= 0 && own < p.window,
`${p.fn} 的塞键行离自己函数开行 ${own} 字符,窗口预算却是 ${p.window}:own<0 = 那一行整段没了或换了写法;`
+ 'own>=window = 函数体写长把这一处挤出了窗口(这条判据宁可假红也不放宽,放宽就等于够得着隔壁)')
const second = src.indexOf(p.line, src.indexOf(p.line, open) + p.line.length)
assert.ok(second < 0 || p.window < second - open,
`${p.fn} 的窗口(${p.window})够得着同文件下一条同名发送口(距离 ${second - open}):`
+ '删掉这一处,隔壁那行会替它过关,这条钉就只守得住"两处一起删"')
}
// 覆盖性自检的另一半:清单里每个 api 文件,只要它已经把 company_id 当参数下传,就必须被**点名到文件**的钉盖住。
// 上面 loop 的 shape 只求值"登记了的那条钉指向的文件",而正向的 `/company_id\s*[:=]/` 问的是整个文件——
// 于是"给某页的 apiFiles 新增一个会发 company_id 的模块、却不给它登记取值口钉"这一手能双双过关
// (新模块的宽松判据绿、旧模块的严格判据也绿)。批次 2 的 dedupe/query/skip-price 三页各有 2 个发送文件,正是这一形。
for (const page of COMPANY_SCOPED_PAGES) {
const pinnedFiles = new Set((COMPANY_ID_SOURCE_PINS[page.menuKey] ?? []).map((p) => p.file))
for (const file of page.apiFiles) {
const wired = /company_id\s*[:=]/.test(stripComments(read(file)))
if (wired && !pinnedFiles.has(file)) {
problems.push(`${page.menuKey}:${file} 已经在下传 company_id,登记表里却没有一条钉指向它`
+ '——正向只问"文件里有没有",那是恒绿的宽松档')
}
}
}
assert.deepEqual(problems, [],
`公司 tab 接线缺口(逐页列全;批次 1 的 8 页到 Task 10 已全部接线,谁再退回未接线就红在这里):\n`
@@ -400,7 +506,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
* 症状回到裁决 1 想避免的那一型。</p>
*
* <p>判据形状:从 `watch(() => companyTab.activeId, …)` 那**一条语句**取文本(正则在第一个
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;两页今天都没有那种写法,由下面的取样自检兜着)。
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;表里这九页今天都没有那种写法,由下面的取样自检兜着)。
* 反向钉与正样本同支(全局约束 15,三条前提不成立就是探针失效、当场红,不许静默空跑),**每一对**都各跑一遍:
* ① 合规样本必须匹配得出且含两把 token ⇒ 判据不恒红;
* ② 删掉那一句的样本必须不含 ⇒ 判据能红(变异自证走的就是这一条);
@@ -415,7 +521,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
const WATCH_ACTIVE_ID = /watch\(\(\)\s*=>\s*companyTab\.activeId\s*,\s*\(\)\s*=>\s*\{([\s\S]*?)\}\s*\)/
/**
* (文件, 必须出现在 watch 体内的赋值) 两对,同一条 test 里逐对钉。
* (文件, 必须出现在 watch 体内的赋值) 九对,同一条 test 里逐对钉(批次 1 两对 + 批次 2 五对 + 批次 3 两对)。
* `premise` 是这一对的反向钉前提:这一页的发送口今天还在发 `company_id`,清筛选项才有意义;
* 哪天发送口退回不带参,watch 看守就变成"清了一个没人用的筛选项",必须一起红。
*/
@@ -445,6 +551,88 @@ 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 数据还一样」那一批)。
// token 在两页上同形(`filter.groupId = null` 出现三次),这**不是**漏洞:判据按 (file, token) 成对求值,
// 每一对都各自去读它自己那一页的源码,别家页缺了这行不会红在这一页,反之这一页删掉了也不会被隔壁顶住
// (负样本 ③「挪到 watch 之外」钉的就是位置)。
{
file: 'src/pages/asin/DedupeRegistryPage.vue',
token: 'filter.groupId = null',
why: '分组候选 /shop-manages/groups 现在按公司下传,上一家选中的 groupId 在新一家的字典里不存在 ⇒ 去重库被它筛成空页',
premise: [
{ 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 = ''",
why: '这一页的店铺名候选是按分组现拉的(fetchShopNamesByGroup 也透传了公司):只清 groupId 而留着 shopName,'
+ '新一家会被一个不属于它的店铺名筛空,而筛选项 UI 上还显示着上一家填的值',
premise: [
{ file: 'src/pages/asin/query-asin-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
],
},
{
file: 'src/pages/asin/SkipPricePage.vue',
token: "filter.groupId = null; filter.shopName = ''",
why: '同查询 ASIN 页:分组与店铺名是一对(店铺名候选跟着分组走),切公司必须一起清',
premise: [
{ 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()」当时全绿——清筛选项那半守住了,重新取数那半没人守。
{
file: 'src/pages/tasks/DuplicateCheckPage.vue',
token: "filter.shop = ''; filter.group = ''; selectedGroup.value = ''; scope.value = 'global'; void loadConsole(); void loadLedger(1)",
why: '这一页的店铺下拉与分组下拉的候选字典都由 /duplicate-check-console 按公司下发(shops/groups 都来自裁剪后的可见集),'
+ '留着上一家选中的店铺名/分组名,新一家首屏就被一个不属于它的值筛成空页;selectedGroup 单独清是因为'
+ ' loadConsole 的重挑分支只在 groupStats 非空时触发,切到没有分组的公司时它会原样留着。'
+ '末尾两句是 reload:清完了却不重取,页面还是上一家的快照',
premise: [
{ file: 'src/pages/tasks/duplicate-console-api.ts', shapes: [/company_id\s*=\s*companyId\b/] },
],
},
{
file: 'src/pages/tasks/ShopDataTasksPage.vue',
token: "filter.shopName = ''; filter.groupName = ''; selection.value = createShopDataSelection(); page.value = 1; cardPage.value = 1; void load()",
why: '两处自由文本筛选项留着上一家填的值 = 拿新一家看不见的店铺名去筛列表;勾选集更硬——它存的是 resultId,'
+ '跨公司不清的话点「批量下载」会把别家店铺的结果文件打进同一个 zip(不发筛选请求,直接按 id 取件);'
+ '页码回 1 是因为新一家的条数更少,末尾的 void load() 才让切 tab 真的换数据',
premise: [
{ file: 'src/pages/tasks/shop-data-api.ts', shapes: [/company_id\s*=\s*companyId\b/] },
],
},
// ↓ 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
{
file: 'src/pages/account/UsersPage.vue',
token: "filters.createdByAdminId = null; filters.keyword = ''; filters.page = 1; void loadUsers()",
why: '「所属管理员」的候选 admins 随本公司的列表响应给出,上一家的 adminId 在新一家的下拉里不存在;'
+ '用户名又全平台唯一(V143 的唯一索引),留着上一家填的关键字去筛新一家必然空页,'
+ '而输入框还显示着那个值——两处都不是后端筛坏了。末尾的 void loadUsers() 是本页唯一的数据出口,'
+ '少了它前面三条赋值都只是清了一遍没人看的表单',
premise: [
{ file: 'src/api/users.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
],
},
]
/** 取「`watch(() => companyTab.activeId, () => { … })`」这一条语句的原文;匹配不出返回 null(由调用方判探针失效)。 */
@@ -453,9 +641,10 @@ function watchStatement(source: string): string | null {
return m ? m[0] : null
}
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(店铺管理清 groupId、任务看板清 shop)', () => {
assert.ok(WATCH_BODY_PINS.length >= 2,
'watch 体看守被删到只剩一对 ⇒ 这一族又退回"只钉 ShopManagePage",任务看板那行 filter.shop 再次没人看守')
test('切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 五页 + 批次 3 两页 + 批次 4 一页)', () => {
assert.ok(WATCH_BODY_PINS.length >= 10,
`watch 体看守只剩 ${WATCH_BODY_PINS.length} 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/品牌库/查询ASIN/最低价ASIN/商品类目 + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理共 10 对)`
+ '⇒ 这一族又退回"只钉少数几页",被摘掉那一页的"切公司不清筛选项"再次没人看守')
const pinnedFiles = new Set(WATCH_BODY_PINS.map((pin) => pin.file))
for (const pin of WATCH_BODY_PINS) {
// ① 正样本(判据不恒红)——逐字就是这一页今天 watch 体里的那一行。
@@ -17,6 +17,12 @@ import { topbarUserOf } from '../src/layout/topbar-model.ts'
* `AdminUserService#resolveTargetCompanyId` 落操作者自己的公司;跨公司隔离发生在消费侧与读取侧
* (二期批次 2/3),不依赖页面把公司名渲染出来。所以这里的断言全部打在"不得回流"上:
* 任何一处重新渲染公司,本文件就红。</p>
*
* <p><b>2026-10-05 批次 4 修订(控制方点名「用户管理也要区分公司 tab 的数据」)</b>:
* 摘掉的是<b>渲染层</b>的公司维度——行级公司列、「所属公司」标签、筛选状态里的公司、顶栏公司名,这些仍不得回流
* (界面暴露要单独批准,而且 tab 已经是公司选择器,页面里再加一个公司筛选就是第二套口径)。
* <b>请求层</b>的 company_id 是这次明确要加回来的,且取值口唯一:`companyTab.requestCompanyId`。
* 下面 `companyId 的取值口唯一` 那条就是这条新边界的尺子。</p>
*/
test('公司列不再写进列表项,但其余字段必须照常解析', () => {
@@ -39,7 +45,7 @@ test('公司列不再写进列表项,但其余字段必须照常解析', () =>
assert.equal(item.creatorUsername, 'admin')
})
test('筛选状态与查询参数里都没有公司这一维', () => {
test('筛选状态与查询参数里都没有公司这一维(公司值只从 fetchUserList 的原始入参走)', () => {
const state = createUserFilterState()
assert.equal('companyId' in state, false)
assert.deepEqual(state, { keyword: '', createdByAdminId: null, role: '', page: 1, pageSize: 10 })
@@ -49,7 +55,16 @@ test('筛选状态与查询参数里都没有公司这一维', () => {
assert.equal(isFilterActive({ ...state, keyword: ' ' }), false)
const query = toUserListQuery(normalizeUserPageParams({ page: 2, pageSize: 20, keyword: 'x' }))
assert.equal('company_id' in query, false, '绝不下发 company_id:一旦下发就是"只看这家"的过滤')
assert.equal('company_id' in query, false, '两只白名单构造器都不造公司值')
// 批次 4 的落点证据:normalizeUserPageParams 是白名单构造(返回对象只点名 page/pageSize/keyword/…),
// 传进 companyId 也会被丢 ⇒ users.ts 必须读**原始入参** params.companyId。
// 写成 normalized.companyId 时 TS 照样绿(字段在 UserListParams 上声明着),运行时恒 undefined——
// 这正是这条要拦的形状,所以它比的是行为不是字符串。
const dropped = normalizeUserPageParams({ page: 1, pageSize: 10, companyId: 3 })
assert.equal('companyId' in dropped, false,
'归一化结果里出现了 companyId ⇒ 白名单构造改了,users.ts 那句读原始入参的注释与实现得一起对账')
assert.equal(dropped.page, 1, '反向自检:归一化本身没坏(不许靠整只函数报废变绿)')
})
test('顶栏不再渲染公司名', () => {
@@ -59,15 +74,15 @@ test('顶栏不再渲染公司名', () => {
assert.equal(topbarUserOf(null).hasUser, false)
})
// 反向钉:公司维度不得回流到「列表/筛选/顶栏」(2026-10-04 定口径;2026-10-05 修订——
// 唯一例外是建号弹窗里的「公司超级管理员」所属公司下拉,由 company-user-create.test.ts 单独钉住)
// 反向钉:公司维度不得回流到「行渲染/筛选状态/顶栏」(2026-10-04 定口径;2026-10-05 修订——
// ①建号弹窗里的「公司超级管理员」所属公司下拉,由 company-user-create.test.ts 单独钉住;
// ②列表请求带 company_id 是批次 4 明确加回来的,尺子换成下面的「取值口唯一」)
test('账号页与顶栏的源码里公司维度已摘干净', () => {
const page = readSource('src/pages/account/UsersPage.vue')
assert.equal(/所属公司/.test(page), false, '账号页不该再出现「所属公司」标签')
// 列表契约层面不许出现公司维度:查询参数 company_id、筛选状态、行级公司列。
// (companyOptions/c.companyName 是 2026-10-05 建公司超管选公司的唯一豁免,不在此列。)
assert.equal(/company_id|filters\.company|row\.company|companyId/.test(page), false,
'列表查询/筛选/行渲染不允许出现公司维度')
// 渲染层与筛选状态不许有公司维度;snake_case 的 company_id 更不许在页面里手拼(那是 api 层的事)。
assert.equal(/filters\.company|row\.company|company_id/.test(page), false,
'行渲染/筛选状态里回流了公司维度,或页面自己拼了 snake_case 查询键')
assert.match(page, /fetchCompanies/, '公司目录仅供建号弹窗的「公司超管」下拉使用(唯一豁免)')
assert.match(page, /isSuperAdmin[\s\S]{0,200}fetchCompanies/,
'拉公司目录必须按站点超管门控,非超管不发这个请求(后端 403 兜底)')
@@ -95,7 +110,40 @@ test('账号页与顶栏的源码里公司维度已摘干净', () => {
const filter = readSource('src/pages/account/users-filter.ts')
assert.equal(/companyId/.test(filter), false)
const dto = readSource('src/api/users-dto.ts')
assert.equal(/company_id|companyId/.test(dto), false)
// 批次 4 之后 DTO 里**有**公司字段(UserListParams.companyId / UserListQuery.company_id),
// 但只许当类型声明用:两只构造函数一旦开始造这个值,页面的 requestCompanyId 就成了第二套口径的摆设。
for (const fn of ['normalizeUserPageParams', 'toUserListQuery']) {
assert.doesNotMatch(bodyOf(dto, fn), /compan/i,
`users-dto 的 ${fn} 里出现了公司值 ⇒ 取值口从页面挪进了构造器`)
}
const model = readSource('src/api/users-model.ts')
assert.equal(/company_id|company_name/.test(model), false)
assert.equal(/company_id|company_name/.test(model), false, '列表项解析不认后端回传的公司列')
})
/** 花括号配对取函数体(整文件比字符串会被类型声明和注释骗)。 */
function bodyOf(source: string, name: string): string {
const at = source.indexOf(`function ${name}(`)
assert.notEqual(at, -1, `${name} 不在了——先确认它不是被改名/删掉了`)
const open = source.indexOf('{', at)
let depth = 0
for (let i = open; i < source.length; i++) {
if (source[i] === '{') depth++
else if (source[i] === '}') { depth--; if (depth === 0) return source.slice(open, i + 1) }
}
assert.fail(`${name} 花括号不配对,解析失败`)
}
test('列表请求的公司值取值口唯一:每处 companyId 都指向 tab 的 requestCompanyId', () => {
const page = readSource('src/pages/account/UsersPage.vue')
// 分母从真源码现算,不是常量和自己比:0 处=批次 4 的接线被摘掉 ⇒ 三家公司又看到同一份全量列表。
const assigned = [...page.matchAll(/companyId:\s*([^,\n}]+)/g)].map((m) => m[1].trim())
assert.ok(assigned.length >= 1, 'UsersPage 已不再把公司值放进列表请求 ⇒ 用户页的公司隔离断了')
for (const value of assigned) {
assert.equal(value, 'companyTab.requestCompanyId',
`companyId 的取值口不唯一(${value}):请求体里的公司值只许来自公司 tab 的唯一取值口`)
}
// 建号请求仍然不带 company_id(归属由后端从操作者推导):弹窗那侧不许出现这个键。
const dialog = readSource('src/pages/account/CreateUserDialog.vue')
assert.equal(/companyId:|company_id:/.test(dialog), false,
'建号请求体不许带 company_id——那是 2026-10-04 定死的口径,跟列表读侧无关')
})