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 {