Compare commits

..

1 Commits

35 changed files with 480 additions and 1006 deletions
@@ -2,11 +2,6 @@
/** 旧版风格分页(像素复刻 admin.html .pagination)+ 每页条数下拉(10/20/50/100)。
* props: total / page / pageSize / sizes(默认 10/20/50/100) / showTotal(默认 true) / jump(默认 true)。 */
import { computed, ref } from 'vue'
// 每页条数下拉 2026-11-17 用户口径「和亚马逊不统一」:原生 <select> 的弹层是浏览器直角
// 原生物,全站分页条都有这一处 ⇒ 换 el-select(EP 圆角面板)。组件内局部导入,不与全局
// 注册表耦合:任何挂载测试单独 mount 本组件都能正确渲染(不依赖外部 app.use)。
// 样式已在 plugins/element.ts 里按组件全局引过,这里不重复引。
import { ElOption, ElSelect } from 'element-plus'
const props = withDefaults(
defineProps<{
@@ -39,7 +34,8 @@ function goJump() {
go(Math.min(Math.max(n, 1), totalPages.value))
}
function onSizeChange(value: number) {
function onSizeChange(event: Event) {
const value = Number((event.target as HTMLSelectElement).value)
if (Number.isFinite(value) && value > 0) emit('size-change', value)
}
</script>
@@ -47,16 +43,9 @@ function onSizeChange(value: number) {
<template>
<div class="old-pagination">
<span v-if="showTotal" class="page-total">共 {{ total }} 条</span>
<!-- el-select 出厂宽度 100%(--el-select-width),进 flex 行会横涨 ⇒ 类里钉位宽。 -->
<el-select
class="page-size-select"
:model-value="pageSize"
size="small"
aria-label="每页条数"
@change="onSizeChange"
>
<el-option v-for="size in sizes" :key="size" :value="size" :label="`${size}条/页`" />
</el-select>
<select class="page-size-select" :value="pageSize" @change="onSizeChange">
<option v-for="size in sizes" :key="size" :value="size">{{ size }}条/页</option>
</select>
<button type="button" :disabled="page <= 1" @click="go(page - 1)">上一页</button>
<span class="page-cur">第 {{ page }} / {{ totalPages }} 页</span>
<button type="button" :disabled="page >= totalPages" @click="go(page + 1)">下一页</button>
@@ -103,22 +92,15 @@ function onSizeChange(value: number) {
.page-total {
margin-right: 4px;
}
/* 每页条数下拉:与原分页条同尺寸(30px 高、8px 圆角、#cbd9e6 描边、#f8fbfd 浅底)。
外形走 .el-select__wrapper(EP 的结构类,scoped 需 :deep 穿透)。 */
.page-size-select {
width: 104px;
}
.page-size-select :deep(.el-select__wrapper) {
min-height: 30px;
padding: 3px 8px;
border: 1px solid #cbd9e6;
border-radius: 8px;
background: #f8fbfd;
box-shadow: 0 0 0 1px #cbd9e6 inset;
color: #24384d;
font-size: 13px;
line-height: 22px;
}
.page-size-select :deep(.el-select__wrapper:hover) {
box-shadow: 0 0 0 1px #9fb7cd inset;
font-family: inherit;
}
.page-jump {
display: inline-flex;
@@ -8,7 +8,7 @@ import { formatDateTime } from '@/utils/datetime'
import { fetchCompanies } from '@/api/companies'
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '@/api/companies-dto'
import { useAdminSessionStore } from '@/stores/admin-session'
import { refreshCompanyDirectory } from '@/stores/company-tab'
import { useCompanyTabStore } from '@/stores/company-tab'
import { usePlatformTabStore } from '@/stores/platform-tab'
import OldPagination from '@/components/OldPagination.vue'
import CompanyEditorDialog from './CompanyEditorDialog.vue'
@@ -18,6 +18,9 @@ import LoadFailureBar from '@/components/LoadFailureBar.vue'
const session = useAdminSessionStore()
// 平台 tab(V206):公司列表按当前平台过滤,新建默认落当前平台。
const platformTab = usePlatformTabStore()
// 公司 tab 条(2026-11-17 起按平台过滤)共用这一份目录:公司翻档/启停后必须强制重拉,
// 否则 18 个页面的 tab 条端着旧名单,刚翻去京东的公司还挂在亚马逊侧。
const companyTab = useCompanyTabStore()
const loading = ref(false)
const loadFailure = ref('')
const rows = ref<CompanyItem[]>([])
@@ -62,13 +65,10 @@ function openEdit(company: CompanyItem) {
}
// 保存成功后:本页列表照常重拉,共享公司目录(tab 条)强制重拉一份。
// 本页不参与公司隔离(控制方 2026-10-06「公司管理不要有 tab」)⇒ 走 store 的具名出口
// refreshCompanyDirectory,而不是自己持一份 company-tab store(后者形状与「给这页上了 tab」
// 分不开,company-config-entry-super-only 的 pageFiles 分母会当场红)。
// 重拉失败不弹新提示(§12 第 5 条未批的界面暴露):tab 条保留旧名单,下一次切平台 tab / 重进页面会再试。
async function onCompaniesSaved() {
await loadCompanies()
refreshCompanyDirectory().catch((error: unknown) => {
companyTab.refresh().catch((error: unknown) => {
console.warn('[company-tab] 公司保存后目录重拉失败', error)
})
}
@@ -228,7 +228,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -242,10 +243,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -236,15 +236,11 @@ onMounted(loadMenus)
</div>
<div class="form-group" style="min-width: 160px">
<label>菜单类型</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
⇒ 换 el-select(admin-filter 同壳 42px/9px 圆角,弹层是 EP 圆角面板)。
「全部」保留为空值首行=空串不按类型筛(与旧原生下拉同语义);model 是空串时
EP 不显示 label 而走 placeholder,所以 placeholder 同文案,观感与改前一致。 -->
<el-select v-model="filterType" class="admin-filter" placeholder="全部" aria-label="筛选菜单类型">
<el-option label="全部" value="" />
<el-option label="后台" value="admin" />
<el-option label="软件" value="app" />
</el-select>
<select v-model="filterType">
<option value="">全部</option>
<option value="admin">后台</option>
<option value="app">软件</option>
</select>
</div>
</div>
@@ -402,7 +398,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -416,10 +413,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -151,14 +151,10 @@ onMounted(load)
</div>
<div class="form-group" v-if="isSuperAdmin && groupOptions.length" style="min-width: 170px">
<label>分组</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
⇒ 换 el-select(admin-filter 同壳 42px/9px 圆角,弹层是 EP 圆角面板),组多时可搜。
「全部分组」的值仍是 null(下游 groupId 照旧 `|| undefined`),空档时由
placeholder 显示同一句文案。 -->
<el-select v-model="groupFilter" class="admin-filter" filterable placeholder="全部分组" aria-label="筛选分组">
<el-option label="全部分组" :value="null" />
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
</el-select>
<select v-model="groupFilter">
<option :value="null">全部分组</option>
<option v-for="group in groupOptions" :key="group.id" :value="group.id">{{ group.groupName }}</option>
</select>
</div>
<div class="form-group">
<label>&nbsp;</label>
@@ -294,7 +290,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -308,10 +305,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -324,23 +324,16 @@ onMounted(load)
</div>
<div class="form-group" style="min-width: 170px">
<label>状态(三项都通过才算通过)</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
⇒ 换 el-select(admin-filter 同壳 42px/9px 圆角,弹层是 EP 圆角面板)。
「全部状态」仍是 STATUS_OPTIONS 里的空串档(下游 checkStatus 照旧传 ''→undefined);
model 为空串时 EP 走 placeholder 显示,故 placeholder 与首档同文案。 -->
<el-select v-model="statusFilter" class="admin-filter" placeholder="全部状态" aria-label="筛选密钥状态">
<el-option v-for="option in STATUS_OPTIONS" :key="option.value" :label="option.label" :value="option.value" />
</el-select>
<select v-model="statusFilter">
<option v-for="option in STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
</select>
</div>
<div class="form-group" v-if="isSuperAdmin && groupOptions.length" style="min-width: 170px">
<label>分组</label>
<!-- 同上(2026-11-17 换 el-select):分组可能很多 ⇒ 保留 filterable 可搜。
「全部分组」的值仍是 null(下游 groupId 照旧 `|| undefined`),空档时由
placeholder 显示同一句文案。 -->
<el-select v-model="groupFilter" class="admin-filter" filterable placeholder="全部分组" aria-label="筛选分组">
<el-option label="全部分组" :value="null" />
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
</el-select>
<select v-model="groupFilter">
<option :value="null">全部分组</option>
<option v-for="group in groupOptions" :key="group.id" :value="group.id">{{ group.groupName }}</option>
</select>
</div>
<div class="form-group">
<label>&nbsp;</label>
@@ -560,7 +553,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -574,10 +568,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -390,7 +390,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -404,10 +405,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -290,7 +290,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -304,10 +305,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -70,10 +70,6 @@ const editSaving = ref(false)
const editTarget = ref<DedupeTotalItem | null>(null)
const editValue = ref('')
const editGroupId = ref<number | null>(null)
/** 弹窗分组下拉的清空回填值:EP 的 el-select 默认清空写 undefined,会破 editGroupId/importGroupId
* 的 `number | null` 契约(下游 saveEdit/importValid 按假值判「未选」、updateDedupeTotal 的入参是 number)
* ⇒ 清空一律钉回 null,与旧原生 select 空行(value=null)同语义。 */
const nullOnClear = (): null => null
type ImportMode = 'add' | 'delete'
const importVisible = ref(false)
@@ -377,14 +373,10 @@ onUnmounted(() => {
</div>
<div class="form-group">
<label>国家</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
⇒ 换 el-select(admin-filter 与亚马逊面同壳 42px/9px,弹层是 EP 圆角面板)。
「全部国家」保留为空值首行(value="" 与改前同语义,下发参数仍是空串=不限);
EP 把 '' 当空值 ⇒ 闭壳显示 placeholder,因此同时钉 placeholder="全部国家",视觉不变。 -->
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
<el-option label="全部国家" value="" />
<el-option v-for="code in ASIN_COUNTRY_CODES" :key="code" :label="asinCountryLabel(code)" :value="code" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="code in ASIN_COUNTRY_CODES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
</select>
</div>
<div class="dedupe-filter-actions">
<button class="btn" type="button" @click="apply">查询</button>
@@ -460,23 +452,10 @@ onUnmounted(() => {
</div>
<div class="form-group">
<label>分组</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物 ⇒ el-select。
「未选」语义:原写法是 disabled 的空行(:value="null",选中后不可回退),这里改成
placeholder="请选择分组" + clearable,并用 :value-on-clear 把清空值钉回 null
(理由见上方 nullOnClear 注释:EP 默认回 undefined 会破 number | null 契约)。
值域仍是 null 或分组 id(number),下游 editGroupId 的假值判断与入参形状不变;
非超管单分组时照旧锁定展示(:disabled 与护栏测试钉住的写法一致)。 -->
<el-select
v-model="editGroupId"
class="admin-filter"
placeholder="请选择分组"
clearable
:value-on-clear="nullOnClear"
:disabled="lockedGroupId != null"
aria-label="编辑分组"
>
<el-option v-for="group in groups" :key="group.id" :label="group.name" :value="group.id" />
</el-select>
<select v-model="editGroupId" :disabled="lockedGroupId != null">
<option disabled :value="null">请选择分组</option>
<option v-for="group in groups" :key="group.id" :value="group.id">{{ group.name }}</option>
</select>
</div>
<div class="modal-actions">
<button class="btn" type="button" :disabled="editSaving" @click="saveEdit">保存</button>
@@ -494,20 +473,10 @@ onUnmounted(() => {
</div>
<div class="form-group">
<label>分组</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物 ⇒ el-select。
与编辑弹窗同款「未选」处理(placeholder + clearable + 清空钉回 null),
导入锁定条件(importRunning 或单分组)照旧挂在 :disabled 上。 -->
<el-select
v-model="importGroupId"
class="admin-filter"
placeholder="请选择分组"
clearable
:value-on-clear="nullOnClear"
:disabled="importRunning || lockedGroupId != null"
aria-label="导入分组"
>
<el-option v-for="group in groups" :key="group.id" :label="group.name" :value="group.id" />
</el-select>
<select v-model="importGroupId" :disabled="importRunning || lockedGroupId != null">
<option disabled :value="null">请选择分组</option>
<option v-for="group in groups" :key="group.id" :value="group.id">{{ group.name }}</option>
</select>
</div>
<div v-if="importProgress" class="progress-wrap">
<div class="progress-text">{{ importProgress }}</div>
@@ -622,9 +591,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -638,10 +606,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -387,14 +387,10 @@ onMounted(() => {
</div>
<div class="form-group">
<label>国家</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
⇒ 换 el-select(与上面分组同一套 admin-filter 壳 42px/9px,弹层是 EP 圆角面板)。
「全部国家」保留为空值首行(value="" 与改前同语义,下发仍是空串=不限);
EP 把 '' 视作空值 ⇒ 闭壳走 placeholder,因此同步钉 placeholder="全部国家" 保持文案。 -->
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
<el-option label="全部国家" value="" />
<el-option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :label="asinCountryLabel(code)" :value="code" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
</select>
</div>
<div class="form-group">
<label>ASIN</label>
@@ -586,9 +582,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -602,10 +597,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -432,14 +432,10 @@ onMounted(() => {
</div>
<div class="form-group">
<label>国家</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
⇒ 换 el-select(与上面分组同一套 admin-filter 壳 42px/9px,弹层是 EP 圆角面板)。
「全部国家」保留为空值首行(value="" 与改前同语义,下发仍是空串=不限);
EP 把 '' 视作空值 ⇒ 闭壳走 placeholder,因此同步钉 placeholder="全部国家" 保持文案。 -->
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
<el-option label="全部国家" value="" />
<el-option v-for="code in COUNTRIES" :key="code" :label="asinCountryLabel(code)" :value="code" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="code in COUNTRIES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
</select>
</div>
<div class="form-group">
<label>ASIN</label>
@@ -650,9 +646,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -666,10 +661,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -354,11 +354,8 @@ watch(
.option-row:hover {
background: #f1f7fb;
}
/* 名称不占剩余空间:它只包住自己的文字,数量徽标紧贴其后。
剩余空间全部让给 row-actions 的 margin-left:auto(有操作时按钮仍靠右)。
写回 flex:1 会让名称把空白吃满、把号码顶到行尾(2026-11-17 用户反馈「0 和名称离的有点远」)。 */
.option-name {
flex: 0 1 auto;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
@@ -378,7 +375,6 @@ watch(
}
.row-actions {
flex: none;
margin-left: auto;
white-space: nowrap;
}
.manage-empty {
@@ -358,20 +358,16 @@ onMounted(async () => {
<label>分组</label>
<!-- 当前分组(V203):能看多组的人(平台超管/公司超管)下拉切换;只有一组时锁定显示组名。
2026-11-16 用户口径「做成分组」:从工具栏裸下拉上移进筛选行,做成带标签的表单控件
(与其他筛选同壳同圆角)。2026-11-17 用户口径「和亚马逊不统一」:原生 <select> 的
弹层是浏览器直角原生物,换 el-select(同亚马逊面 admin-filter 同壳),组多时可搜索。
分组是分类列/分类筛选/分类管理的作用域,不是筛选条件 ⇒ 放在筛选行也只是占位,
「重置」不清它(挂载测试钉住)。 -->
<el-select
(与其他筛选同壳同圆角)。分组是分类列/分类筛选/分类管理的作用域,不是筛选条件
⇒ 放在筛选行也只是占位,「重置」不清它(挂载测试钉住)。 -->
<select
v-if="canSwitchGroup"
:model-value="ownerGroupId"
class="admin-filter"
filterable
:value="ownerGroupId"
aria-label="当前分组"
@change="changeOwnerGroup"
@change="changeOwnerGroup(Number(($event.target as HTMLSelectElement).value))"
>
<el-option v-for="group in categoryScope" :key="group.id" :value="group.id" :label="group.label" />
</el-select>
<option v-for="group in categoryScope" :key="group.id" :value="group.id">{{ group.label }}</option>
</select>
<span v-else class="jd-group-locked" title="你的数据权限内只有这一个分组">{{ currentGroupName }}</span>
</div>
<div class="form-group">
@@ -404,19 +400,10 @@ onMounted(async () => {
<!-- 商品行写只对平台超管;分类写由当前分组 editable 决定(本组管理员/公司超管/平台超管)。
非超管看到只读提示,分类维护入口=工具栏「分类管理」(只读可看,写控件按 editable 分档)。 -->
<span v-if="!isSuperAdmin" class="jd-readonly-tip">只读:编辑/删除仅超级管理员可用;分类在本页「分类管理」查看与维护</span>
<!-- 分类筛选(2026-11-17 与分组同刀换 el-select,弹层圆角与亚马逊统一):保留显式
「全部分类」行(value='',与旧原生下拉同语义——列表里永远有回全量的出口),
选中它/重置回 '' 时闭壳显示同文案占位。 -->
<el-select
v-model="filter.groupId"
class="admin-filter"
placeholder="全部分类"
aria-label="筛选店铺分类"
@change="apply"
>
<el-option label="全部分类" value="" />
<el-option v-for="group in groupOptions" :key="group.id" :label="group.name" :value="String(group.id)" />
</el-select>
<select v-model="filter.groupId" aria-label="筛选店铺分类" @change="apply">
<option value="">全部分类</option>
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
</select>
<!-- 分类管理(2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里」):V204 独立
子菜单页整体并入本对话框(搜索+新建+改名+删除)。入口对所有人渲染(同组普通号
只读可看,V203),写控件由对话框按当前分组 editable 分档。 -->
@@ -62,7 +62,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -76,10 +77,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -128,12 +131,38 @@ h3 {
gap: 10px;
margin-bottom: 10px;
}
/* 工具栏分类筛选(2026-11-17 用户口径「和亚马逊不统一」起换 el-select):42px 外壳、
9px 圆角、#cbd9e6 描边、#f8fbfd 浅底与 focus ring 都由全局 .el-select.admin-filter
皮肤(main.css)出——与亚马逊面同一套,弹层不再是浏览器原生直角列表。
这里只钉工具栏位宽(admin-filter 出厂 width:100%,进 flex 工具栏会横涨)。 */
.jd-toolbar .el-select.admin-filter {
width: 200px;
/* 工具栏里的下拉与按钮统一 42px 外壳(2026-11-16 用户口径「样式要统一」):
这一行此前只有 .btn 有壳,原生 <select> 落成 28px 灰框、字号也不跟,
与旁边按钮同排时高矮不齐(分组下拉同日上移进筛选行,本行只剩分类筛选一颗)。
数值与 .form-group select / .btn 同一套(42px 高、
9px 圆角、#cbd9e6 描边、#f8fbfd 底),箭头用内联 SVG 自绘,避免各浏览器原生
箭头粗细不一(appearance:none 后必须补 padding-right 给箭头留位)。 */
.jd-toolbar select {
min-height: 42px;
max-width: 220px;
padding: 0 34px 0 12px;
border: 1px solid #cbd9e6;
border-radius: 9px;
background-color: #f8fbfd;
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235b6f83' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
appearance: none;
-webkit-appearance: none;
color: #24384d;
font-family: inherit;
font-size: 13.5px;
cursor: pointer;
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.jd-toolbar select:hover {
border-color: #9fb7cd;
}
.jd-toolbar select:focus {
background-color: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
}
/* 危险动作(删除勾选)推到行尾:留在「批量编辑分类/分类筛选」旁边会被读成同一组动作。 */
.jd-delete-btn {
@@ -165,7 +194,7 @@ h3 {
white-space: nowrap;
}
/* 只有一个可见分组时锁定的组名(不可切):筛选行「分组」标签下的静态芯片(2026-11-16 用户口径
「做成分组」把下拉从工具栏上移进筛选行后跟着搬),与同排 el-select 同高同壳(42px/9px 圆角),
「做成分组」把下拉从工具栏上移进筛选行后跟着搬),与同排 select 同高同壳(42px/9px 圆角),
"一组锁定"和"多组下拉"两种形态占位一致;组名超宽省略号收口,不把筛选行撑破。 */
.jd-group-locked {
display: flex;
@@ -170,22 +170,18 @@ onMounted(() => {
</div>
<div class="form-group">
<label>国家</label>
<!-- 下拉 2026-11-17 用户口径「和亚马逊不统一」:原生 <select> 的弹层是浏览器直角
原生物 ⇒ 换 el-select(admin-filter 同壳 42px/9px,弹层 EP 圆角面板)。
「全部国家」保留为空值首行(与旧原生下拉同语义,查询参数仍是空串)。 -->
<el-select v-model="filter.country" class="admin-filter" aria-label="筛选国家">
<el-option label="全部国家" value="" />
<el-option v-for="code in ASIN_COUNTRY_CODES" :key="code" :label="asinCountryLabel(code)" :value="code" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="code in ASIN_COUNTRY_CODES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
</select>
</div>
<div class="form-group">
<label>分组</label>
<!-- 分组(主管)选中即查:选完立刻按该主管过滤刷新(回第一页),不必再点查询。
value 保持字符串形状(下游按字符串比对/透传)。 -->
<el-select v-model="filter.groupId" class="admin-filter" aria-label="筛选分组" @change="apply">
<el-option label="全部分组" value="" />
<el-option v-for="group in groupOptions" :key="group.id" :label="group.name" :value="String(group.id)" />
</el-select>
<!-- 分组(主管)选中即查:选完立刻按该主管过滤刷新(回第一页),不必再点查询。 -->
<select v-model="filter.groupId" @change="apply">
<option value="">全部分组</option>
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
</select>
</div>
<div class="form-group">
<label>同步开始日期</label>
@@ -310,7 +306,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -324,10 +321,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -221,11 +221,6 @@ function modeLabel(mode: string): string {
return mode === 'selected' ? '精选' : '全量'
}
/** 终端覆盖下拉的显示文案(el-option 需要显式 label,文案与旧原生 <option> 逐字一致)。 */
function deviceOptionLabel(device: DeviceLogDevice): string {
return `${sourceLabel(device.source)} · ${device.deviceName || device.deviceId}(${device.deviceId})`
}
async function openConfig() {
configVisible.value = true
await loadConfig()
@@ -306,20 +301,16 @@ onMounted(() => {
<div class="form-row logs-filter-row">
<div class="form-group" style="min-width: 150px">
<label>来源</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
「全部来源」保留为空值首行(value 语义不变,查询参数仍是空串)。 -->
<el-select v-model="sourceFilter" class="admin-filter" aria-label="来源">
<el-option v-for="option in SOURCE_OPTIONS" :key="option.value" :label="option.label" :value="option.value" />
</el-select>
<select v-model="sourceFilter">
<option v-for="option in SOURCE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
</select>
</div>
<div class="form-group" style="min-width: 180px">
<label>指定用户</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
「全部用户」保留为空值首行;用户值仍是 String(id)(下游按字符串判空、落库前再转数字)。 -->
<el-select v-model="uidFilter" class="admin-filter" filterable aria-label="指定用户" :disabled="usersLoading">
<el-option label="全部用户" value="" />
<el-option v-for="u in userOptions" :key="u.id" :label="u.username" :value="String(u.id)" />
</el-select>
<select v-model="uidFilter" :disabled="usersLoading">
<option value="">全部用户</option>
<option v-for="u in userOptions" :key="u.id" :value="String(u.id)">{{ u.username }}</option>
</select>
</div>
<div class="form-group" style="min-width: 150px">
<label>日志日期(起)</label>
@@ -434,21 +425,15 @@ onMounted(() => {
<div class="config-block">
<h4>终端覆盖</h4>
<div class="override-add">
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
value 仍是 `${source}|${deviceId}` 与 'full'/'selected' 常量,逐字保留(addOverride
按 '|' 切分、后端按 mode 常量解析,值形状一动就错单)。 -->
<el-select v-model="newOverrideKey" class="admin-filter override-select" filterable aria-label="选择终端">
<el-option label="选择终端(最近上报的设备)" value="" />
<el-option
v-for="device in devices"
:key="`${device.source}|${device.deviceId}`"
:label="deviceOptionLabel(device)"
:value="`${device.source}|${device.deviceId}`"
/>
</el-select>
<el-select v-model="newOverrideMode" class="admin-filter override-mode" aria-label="覆盖模式">
<el-option v-for="option in MODE_OPTIONS" :key="option.value" :label="option.label" :value="option.value" />
</el-select>
<select v-model="newOverrideKey" class="override-select">
<option value="">选择终端(最近上报的设备)</option>
<option v-for="device in devices" :key="`${device.source}|${device.deviceId}`" :value="`${device.source}|${device.deviceId}`">
{{ sourceLabel(device.source) }} · {{ device.deviceName || device.deviceId }}({{ device.deviceId }})
</option>
</select>
<select v-model="newOverrideMode">
<option v-for="option in MODE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
</select>
<button class="btn btn-sm" type="button" @click="addOverride">添加/更新覆盖</button>
</div>
<table class="override-table">
@@ -544,7 +529,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -557,7 +543,8 @@ h3 {
color-scheme: light;
outline: none;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -756,15 +743,21 @@ td {
gap: 10px;
margin-bottom: 12px;
}
/* 只管布局:外壳皮肤(42px/9 圆角/#f8fbfd/focus ring)由全局 .admin-filter 提供,
这里不再重复描边(旧 `.override-add select` 那段原生下拉皮肤已随 el-select 删除)。 */
.override-add select {
min-height: 38px;
padding: 6px 10px;
border: 1px solid #cbd9e6;
border-radius: 9px;
background: #f8fbfd;
color: #24384d;
font-size: 13px;
font-family: inherit;
color-scheme: light;
}
.override-select {
flex: 1;
min-width: 0;
}
.override-mode {
flex: 0 0 140px;
}
.override-table td {
vertical-align: middle;
}
@@ -146,12 +146,10 @@ onMounted(() => {
<div class="form-row">
<div class="form-group" style="min-width: 150px">
<label>指定用户</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
「全部用户」保留为空值首行;用户值仍是 String(id)(查询前再 Number() 转数字)。 -->
<el-select v-model="filter.userId" class="admin-filter" filterable aria-label="指定用户" :disabled="userLoading">
<el-option label="全部用户" value="" />
<el-option v-for="u in userOptions" :key="u.id" :label="u.username" :value="String(u.id)" />
</el-select>
<select v-model="filter.userId" :disabled="userLoading">
<option value="">全部用户</option>
<option v-for="u in userOptions" :key="u.id" :value="String(u.id)">{{ u.username }}</option>
</select>
</div>
<div class="form-group" style="min-width: 176px">
<label>开始时间</label>
@@ -296,7 +294,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -310,10 +309,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -379,19 +379,17 @@ onUnmounted(() => {
<label>账号</label>
<input v-model="filter.username" type="text" placeholder="模糊搜索账号名" @keyup.enter="search" />
</div>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select
(与下方店铺筛选同形,挂全局 admin-filter 皮肤)。 -->
<div class="form-group" style="min-width: 150px">
<label>业务</label>
<el-select v-model="filter.moduleType" class="admin-filter" aria-label="筛选业务">
<el-option v-for="option in MODULE_OPTIONS" :key="option.value" :value="option.value" :label="option.label" />
</el-select>
<select v-model="filter.moduleType">
<option v-for="option in MODULE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
</select>
</div>
<div class="form-group" style="min-width: 130px">
<label>状态</label>
<el-select v-model="filter.status" class="admin-filter" aria-label="筛选任务状态">
<el-option v-for="option in TASK_STATUS_OPTIONS" :key="option.value" :value="option.value" :label="option.label" />
</el-select>
<select v-model="filter.status">
<option v-for="option in TASK_STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
</select>
</div>
<div class="form-group shop-filter">
<label>店铺</label>
@@ -449,11 +447,9 @@ onUnmounted(() => {
<div class="form-row">
<div class="form-group" style="min-width: 150px">
<label>状态</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
value 原样透传('0'~'3' 是字符串,后端按值比对)。 -->
<el-select v-model="variantFilter.status" class="admin-filter" aria-label="筛选变体状态">
<el-option v-for="option in VARIANT_STATUS_OPTIONS" :key="option.value" :value="option.value" :label="option.label" />
</el-select>
<select v-model="variantFilter.status">
<option v-for="option in VARIANT_STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
</select>
</div>
<div class="form-group">
<label>&nbsp;</label>
@@ -693,7 +689,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -706,7 +703,8 @@ h3 {
color-scheme: light;
outline: none;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -253,16 +253,15 @@ onMounted(() => {
</label>
<label class="g-field">
<span>国家</span>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。 -->
<el-select v-model="form.country" class="admin-filter" aria-label="表单国家">
<el-option v-for="country in GATING_COUNTRIES" :key="country" :value="country" :label="country" />
</el-select>
<select v-model="form.country">
<option v-for="country in GATING_COUNTRIES" :key="country" :value="country">{{ country }}</option>
</select>
</label>
<label class="g-field">
<span>类型</span>
<el-select v-model="form.gatingType" class="admin-filter" aria-label="表单类型">
<el-option v-for="type in typeOptions" :key="type" :value="type" :label="type" />
</el-select>
<select v-model="form.gatingType">
<option v-for="type in typeOptions" :key="type" :value="type">{{ type }}</option>
</select>
</label>
<label class="g-field">
<span>ASIN</span>
@@ -303,25 +302,23 @@ onMounted(() => {
<div class="g-panel-body">
<div class="g-filters">
<input v-model="filter.keyword" placeholder="搜索品牌 / ASIN" @keyup.enter="query" />
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
「全部 XX」空值行保留、status 的 '1'/'0' 仍是字符串(后端按值比对)。 -->
<el-select v-model="filter.country" class="admin-filter" style="width: 132px" aria-label="筛选国家">
<el-option value="" label="全部国家" />
<el-option v-for="country in countryOptions" :key="country" :value="country" :label="country" />
</el-select>
<el-select v-model="filter.gatingType" class="admin-filter" style="width: 132px" aria-label="筛选类型">
<el-option value="" label="全部类型" />
<el-option v-for="type in typeOptions" :key="type" :value="type" :label="type" />
</el-select>
<el-select v-model="filter.status" class="admin-filter" style="width: 132px" aria-label="筛选状态">
<el-option value="" label="全部状态" />
<el-option value="1" label="生效" />
<el-option value="0" label="已解除" />
</el-select>
<el-select v-model="filter.source" class="admin-filter" style="width: 132px" aria-label="筛选来源">
<el-option value="" label="全部来源" />
<el-option v-for="source in GATING_SOURCES" :key="source" :value="source" :label="sourceText(source)" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="country in countryOptions" :key="country" :value="country">{{ country }}</option>
</select>
<select v-model="filter.gatingType">
<option value="">全部类型</option>
<option v-for="type in typeOptions" :key="type" :value="type">{{ type }}</option>
</select>
<select v-model="filter.status">
<option value="">全部状态</option>
<option value="1">生效</option>
<option value="0">已解除</option>
</select>
<select v-model="filter.source">
<option value="">全部来源</option>
<option v-for="source in GATING_SOURCES" :key="source" :value="source">{{ sourceText(source) }}</option>
</select>
<button class="g-btn g-btn-primary" type="button" @click="query">查询</button>
<button class="g-btn g-btn-ghost" type="button" @click="resetFilter">重置</button>
</div>
@@ -525,9 +522,10 @@ onMounted(() => {
.g-field-wide {
grid-column: span 2;
}
/* 下拉已换 el-select(2026-11-17)⇒ 皮肤走全局 .admin-filter,这里只留原生输入框。 */
.g-field input,
.g-filters input {
.g-field select,
.g-filters input,
.g-filters select {
width: 100%;
height: 34px;
padding: 0 10px;
@@ -540,28 +538,13 @@ onMounted(() => {
outline: none;
}
.g-field input:focus,
.g-filters input:focus {
.g-field select:focus,
.g-filters input:focus,
.g-filters select:focus {
border-color: var(--g-primary);
box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12);
background: #fff;
}
/* 本页表单/筛选行是 34px 紧凑档(输入框与 `.g-btn` 同为 34px、7px 圆角、蓝色 focus)。
新换的 el-select 若照全局 admin-filter(42px/9px/蓝灰 ring)会在同一行里高出一截,
与旁边的输入框错位 ⇒ 在本页把壳压回本地档位(scoped 下 :deep 穿透 EP 内部结构)。 */
.g-field :deep(.el-select__wrapper),
.g-filters :deep(.el-select__wrapper) {
min-height: 34px;
padding: 0 10px;
border-radius: 7px;
background: #fbfcfe;
box-shadow: 0 0 0 1px #d7dce5 inset;
font-size: 13px;
}
.g-field :deep(.el-select__wrapper.is-focused),
.g-filters :deep(.el-select__wrapper.is-focused) {
background: #fff;
box-shadow: 0 0 0 1px var(--g-primary) inset, 0 0 0 3px rgba(46, 91, 230, 0.12);
}
.g-form-actions {
display: flex;
justify-content: flex-end;
@@ -597,6 +580,9 @@ onMounted(() => {
.g-filters input {
width: 190px;
}
.g-filters select {
width: 132px;
}
.g-btn {
height: 34px;
@@ -447,26 +447,24 @@ onMounted(() => {
</div>
<div class="f-group">
<label>店铺</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
「全部 XX」空值行保留,候选值原样透传。 -->
<el-select v-model="filter.shop" class="admin-filter" filterable style="width: 150px" aria-label="筛选店铺">
<el-option value="" label="全部店铺" />
<el-option v-for="shop in orderedShops" :key="shop.shopName" :value="shop.shopName" :label="shop.shopName" />
</el-select>
<select v-model="filter.shop">
<option value="">全部店铺</option>
<option v-for="shop in orderedShops" :key="shop.shopName" :value="shop.shopName">{{ shop.shopName }}</option>
</select>
</div>
<div v-if="isSuper" class="f-group">
<label>分组</label>
<el-select v-model="filter.group" class="admin-filter" filterable style="width: 150px" aria-label="筛选分组">
<el-option value="" label="全部分组" />
<el-option v-for="group in groupStats" :key="group.name" :value="group.name" :label="group.name" />
</el-select>
<select v-model="filter.group">
<option value="">全部分组</option>
<option v-for="group in groupStats" :key="group.name" :value="group.name">{{ group.name }}</option>
</select>
</div>
<div class="f-group">
<label>国家 / 站点</label>
<el-select v-model="filter.country" class="admin-filter" style="width: 150px" aria-label="筛选国家">
<el-option value="" label="全部国家" />
<el-option v-for="code in countryOptions" :key="code" :value="code" :label="asinCountryLabel(code)" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="code in countryOptions" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
</select>
</div>
<div class="f-group">
<label>上架时间开始</label>
@@ -776,8 +774,7 @@ onMounted(() => {
.dup-ref .mono { font-family: var(--mono); }
.dup-ref button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.dup-ref button:disabled { opacity: 0.55; cursor: not-allowed; }
/* 原生 select 已换 el-select(2026-11-17)⇒ 选择器里不再列 select。 */
.dup-ref input { font-family: inherit; font-size: 13px; color: var(--text); }
.dup-ref input, .dup-ref select { font-family: inherit; font-size: 13px; color: var(--text); }
.dup-ref a { color: var(--primary); text-decoration: none; }
.dup-ref .dim-cell { color: var(--text3); }
.dup-ref .num-cell { font-variant-numeric: tabular-nums; }
@@ -804,27 +801,14 @@ onMounted(() => {
.dup-ref .filter-row { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.dup-ref .f-group { display: flex; flex-direction: column; gap: 6px; }
.dup-ref .f-group label { font-size: 12px; color: var(--text2); }
/* 下拉已换 el-select(2026-11-17)⇒ 皮肤走全局 .admin-filter。
本页 style 块不是 scoped,`.f-group input` 会连带命中 el-select 内层的
`input.el-select__input`(EP 自己的边框/背景会被这套规则压掉,控件变成框里套框)
⇒ 必须显式排除。 */
.dup-ref .f-group input:not(.el-select__input) {
width: 170px;
.dup-ref .f-group input, .dup-ref .f-group select {
height: 34px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 0 10px; background: #FBFCFE; outline: none;
transition: border-color 0.15s, box-shadow 0.15s;
}
.dup-ref .f-group input:not(.el-select__input):focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12); background: #fff; }
.dup-ref .f-group input:focus, .dup-ref .f-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12); background: #fff; }
.dup-ref .f-group input { width: 170px; }
.dup-ref .f-group select { width: 150px; cursor: pointer; }
.dup-ref .f-group input[type="date"] { width: 150px; }
/* 本页筛选行是 34px 紧凑档(输入框与 `.btn` 同为 34px、7px 圆角、蓝色 focus)。
新换的 el-select 若照全局 admin-filter(42px/9px/蓝灰 ring)会与同行输入框错位
⇒ 在本页把壳压回本地档位;本页 style 不 scoped,EP 内部结构可直接选中。 */
.dup-ref .f-group .el-select__wrapper {
min-height: 34px; padding: 0 10px; border-radius: 7px;
background: #FBFCFE; box-shadow: 0 0 0 1px var(--border-strong) inset; font-size: 13px;
}
.dup-ref .f-group .el-select__wrapper.is-focused {
background: #fff; box-shadow: 0 0 0 1px var(--primary) inset, 0 0 0 3px rgba(46, 91, 230, 0.12);
}
.dup-ref .btn {
height: 34px; border-radius: 7px; padding: 0 16px; font-size: 13px; font-weight: 600;
display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s, color 0.15s, border-color 0.15s;
@@ -185,21 +185,19 @@ onMounted(() => {
<div class="kw-panel-head">筛选条件</div>
<div class="kw-panel-body">
<div class="kw-filters">
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。
「全部 XX」空值行保留。 -->
<label class="kw-field">
<span>使用者</span>
<el-select v-model="filter.user" class="admin-filter" filterable aria-label="筛选使用者">
<el-option value="" label="全部使用者" />
<el-option v-for="user in userOptions" :key="user" :value="user" :label="user" />
</el-select>
<select v-model="filter.user">
<option value="">全部使用者</option>
<option v-for="user in userOptions" :key="user" :value="user">{{ user }}</option>
</select>
</label>
<label class="kw-field">
<span>国家</span>
<el-select v-model="filter.country" class="admin-filter" aria-label="筛选国家">
<el-option value="" label="全部国家" />
<el-option v-for="country in countryOptions" :key="country" :value="country" :label="country" />
</el-select>
<select v-model="filter.country">
<option value="">全部国家</option>
<option v-for="country in countryOptions" :key="country" :value="country">{{ country }}</option>
</select>
</label>
<label class="kw-field kw-field-wide">
<span>关键词</span>
@@ -207,10 +205,10 @@ onMounted(() => {
</label>
<label class="kw-field">
<span>场景</span>
<el-select v-model="filter.scene" class="admin-filter" aria-label="筛选场景">
<el-option value="" label="全部场景" />
<el-option v-for="scene in KEYWORD_USAGE_SCENES" :key="scene" :value="scene" :label="scene" />
</el-select>
<select v-model="filter.scene">
<option value="">全部场景</option>
<option v-for="scene in KEYWORD_USAGE_SCENES" :key="scene" :value="scene">{{ scene }}</option>
</select>
</label>
<div class="kw-actions">
<button class="kw-btn kw-btn-primary" type="button" @click="query">查询</button>
@@ -407,8 +405,8 @@ onMounted(() => {
font-size: 12px;
color: #5a6474;
}
/* 下拉已换 el-select(2026-11-17)⇒ 皮肤走全局 .admin-filter,这里只留原生输入框。 */
.kw-field input {
.kw-field input,
.kw-field select {
height: 34px;
padding: 0 10px;
border: 1px solid #d7dce5;
@@ -419,26 +417,12 @@ onMounted(() => {
font-size: 13px;
outline: none;
}
.kw-field input:focus {
.kw-field input:focus,
.kw-field select:focus {
border-color: #2e5be6;
box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12);
background: #fff;
}
/* 本页筛选行是 34px 紧凑档(关键词输入框 34px、7px 圆角、蓝色 focus)。
新换的 el-select 若照全局 admin-filter(42px/9px/蓝灰 ring)会与同行输入框错位
⇒ 在本页把壳压回本地档位(scoped 下 :deep 穿透 EP 内部结构)。 */
.kw-field :deep(.el-select__wrapper) {
min-height: 34px;
padding: 0 10px;
border-radius: 7px;
background: #fbfcfe;
box-shadow: 0 0 0 1px #d7dce5 inset;
font-size: 13px;
}
.kw-field :deep(.el-select__wrapper.is-focused) {
background: #fff;
box-shadow: 0 0 0 1px #2e5be6 inset, 0 0 0 3px rgba(46, 91, 230, 0.12);
}
.kw-actions {
display: flex;
gap: 8px;
@@ -334,11 +334,10 @@ onMounted(load)
</div>
<div class="form-group" style="min-width: 130px">
<label>国家</label>
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物,换 el-select。 -->
<el-select v-model="filter.country" class="admin-filter" aria-label="筛选国家">
<el-option value="" label="全部" />
<el-option v-for="code in ['UK', 'DE', 'FR', 'ES', 'IT']" :key="code" :value="code" :label="asinCountryLabel(code)" />
</el-select>
<select v-model="filter.country">
<option value="">全部</option>
<option v-for="code in ['UK', 'DE', 'FR', 'ES', 'IT']" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
</select>
</div>
<div class="form-group" style="min-width: 176px">
<label>创建开始</label>
@@ -511,7 +510,8 @@ h3 {
font-size: 12.5px;
font-weight: 600;
}
.form-group input {
.form-group input,
.form-group select {
min-width: 0;
min-height: 42px;
padding: 8px 12px;
@@ -525,10 +525,12 @@ h3 {
outline: none;
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.form-group input:hover {
.form-group input:hover,
.form-group select:hover {
border-color: #9fb7cd;
}
.form-group input:focus {
.form-group input:focus,
.form-group select:focus {
background: #ffffff;
border-color: #5f85ad;
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
@@ -86,15 +86,3 @@ export const useCompanyTabStore = defineStore('company-tab', {
},
},
})
/** 公司目录失效通知:公司管理页保存(新建/改名/启停/翻档)之后调这里,让全站 tab 条重拉一份。
*
* 为什么是 store 里的具名出口而不是让页面自己持一份 store:公司管理页**不参与公司隔离**
* (控制方 2026-10-06「公司管理不要有 tab」),它要的不是 tab 状态,只是「别让 18 个页面的
* tab 条端着旧名单」这一个动作。页面里一旦出现 `useCompanyTabStore()`,形状就和「给这页上了
* tab」分不开——company-config-entry-super-only 的 pageFiles 分母会当场红(2026-11-17 实测:
* ee613db0 给这页加了保存后重拉,正是踩在这条上)。
* 失败语义同 refresh:error 落 store 再 rethrow,调用方决定要不要提示。 */
export function refreshCompanyDirectory(): Promise<void> {
return useCompanyTabStore().refresh()
}
@@ -1,217 +0,0 @@
/**
* 账户域三页的原生 <select> → el-select(2026-11-17 用户口径「和亚马逊不统一」:
* 原生 select 的弹层是浏览器直角原生物 ⇒ 换 EP 圆角弹层,外壳走全局 .admin-filter)。
*
* 钉住换壳最容易错的两件事:
* 1. **值形状逐字不变**——菜单类型/密钥状态仍是 '' / 'admin' / 'app' / 'passed'…(空串=不筛),
* 分组仍是 null 或数字 id(下游 `groupId: groupFilter.value || undefined` 一字不动);
* 2. **「全部 XX」空值行还在**,且选中它就是"不改筛选条件",不是筛一个叫空的类型。
*
* aria-label 由 EP 落在内层 combobox input 上;选项清单走组件树读,点选走「点开→点选项」真实路径
* (弹层 teleport 到 body)。页面模板靠 main.ts 全局注册 EP 组件,挂载测试不跑 main.ts ⇒
* 这里必须显式把 ElSelect/ElOption 传进 plugins。
*
* 跑法:`npx vitest run tests/mount/account-select-el.mount.test.ts`
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { ElOption, ElSelect } from 'element-plus'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import MenusPage from '@/pages/account/MenusPage.vue'
import UserSecretsPage from '@/pages/account/UserSecretsPage.vue'
import UserSecretUsagePage from '@/pages/account/UserSecretUsagePage.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
const menuApi = vi.hoisted(() => ({
loadMenuManageTree: vi.fn(),
createMenu: vi.fn(),
updateMenu: vi.fn(),
deleteMenu: vi.fn(),
reorderMenus: vi.fn(),
}))
const secretsApi = vi.hoisted(() => ({
fetchUserSecretList: vi.fn(),
fetchAdminSecretBalances: vi.fn(),
checkUserSecret: vi.fn(),
deleteUserSecret: vi.fn(),
saveUserSecretModule: vi.fn(),
clearUserSecretModule: vi.fn(),
}))
const usageApi = vi.hoisted(() => ({ fetchUserSecretUsage: vi.fn() }))
vi.mock('@/pages/account/menu-manage-api', () => menuApi)
vi.mock('@/api/user-secrets', () => secretsApi)
vi.mock('@/api/user-secret-usage', () => usageApi)
const GROUPS = [
{ id: 7, groupName: '甲组' },
{ id: 9, groupName: '乙组' },
]
const MENU_ROWS = [
{ id: 1, name: '后台菜单', columnKey: 'admin-col', parentId: null, menuType: 'admin', routePath: '/a', sortOrder: 0, children: [] },
{ id: 2, name: '软件菜单', columnKey: 'app-col', parentId: null, menuType: 'app', routePath: '/b', sortOrder: 1, children: [] },
]
// ---------------- el-select 交互助手(与京东数据库页/亚马逊面同一套口径) ----------------
/** 按 aria-label 找对应的 ElSelect 实例(EP 把该属性落在内层 combobox input 上)。 */
function selectByLabel(wrapper: VueWrapper<Element>, label: string) {
const found = wrapper.findAllComponents(ElSelect).find((s) => s.find(`[aria-label="${label}"]`).exists())
expect(found, `应存在 aria-label="${label}" 的下拉`).toBeTruthy()
return found!
}
/** 某颗下拉的全部选项文案(读 el-option 的 label prop,不依赖插槽文本)。 */
function optionLabels(wrapper: VueWrapper<Element>, label: string): string[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('label') as string)
}
/** 某颗下拉的全部选项 value(形状判据:空串/数字 id/null 逐字对撞)。 */
function optionValues(wrapper: VueWrapper<Element>, label: string): unknown[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('value'))
}
/** 点开指定下拉并点选目标文案的选项(触发 update:modelValue + change,与真实用户一致)。
* 面板按内层 input 的 aria-controls 圈定,避免另一颗(可能仍挂着的)弹层串台。 */
async function pickSelectOption(wrapper: VueWrapper<Element>, label: string, optionText: string): Promise<void> {
const input = wrapper.get(`[aria-label="${label}"]`)
await input.trigger('click')
await flushPromises()
const contentId = input.attributes('aria-controls')
const scope = (contentId && document.getElementById(contentId)) ?? document.body
const items = [...scope.querySelectorAll('.el-select-dropdown__item')].filter((el) => !el.classList.contains('is-hidden'))
const target = items.find((el) => (el.textContent ?? '').trim() === optionText)
expect(target, `下拉应弹出「${optionText}」选项`).toBeTruthy()
await new DOMWrapper(target as Element).trigger('click')
await flushPromises()
}
/** 按文案点按钮(筛选条上的查询/重置)。 */
async function clickButton(wrapper: VueWrapper<Element>, text: string): Promise<void> {
const button = wrapper.findAll('button').find((b) => b.text().trim() === text)
expect(button, `应存在「${text}」按钮`).toBeTruthy()
await button!.trigger('click')
await flushPromises()
await flushPromises()
}
/** 最近一次调用的入参(首屏 + 公司 tab watch 可能各发一次,判"选完落什么参"只认最后一次)。 */
function lastArgs(fn: { mock: { calls: unknown[][] } }): Record<string, unknown> {
const calls = fn.mock.calls
expect(calls.length, '接口应至少被调用一次').toBeGreaterThan(0)
return calls[calls.length - 1][0] as Record<string, unknown>
}
let pinia: Pinia
beforeEach(() => {
vi.clearAllMocks()
pinia = createPinia()
setActivePinia(pinia)
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
useCompanyTabStore().setActiveId(1)
})
async function mountMenus(): Promise<VueWrapper<Element>> {
menuApi.loadMenuManageTree.mockResolvedValue(MENU_ROWS)
const wrapper = mount(MenusPage, { global: { plugins: [pinia, ElSelect, ElOption] } })
await flushPromises()
return wrapper
}
async function mountSecrets(): Promise<VueWrapper<Element>> {
secretsApi.fetchUserSecretList.mockResolvedValue({ items: [], total: 0, page: 1, pageSize: 15, groupOptions: GROUPS })
secretsApi.fetchAdminSecretBalances.mockResolvedValue({ items: [] })
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia, ElSelect, ElOption] } })
await flushPromises()
return wrapper
}
async function mountUsage(): Promise<VueWrapper<Element>> {
usageApi.fetchUserSecretUsage.mockResolvedValue({ items: [], total: 0, groupOptions: GROUPS })
const wrapper = mount(UserSecretUsagePage, { global: { plugins: [pinia, ElSelect, ElOption] } })
await flushPromises()
return wrapper
}
/** 菜单表格里正在显示的行名(顺序=树展平顺序)。 */
function visibleMenuNames(wrapper: VueWrapper<Element>): string[] {
return wrapper.findAll('.menu-name-text').map((el) => el.text().trim())
}
describe('菜单管理页 × el-select', () => {
it('菜单类型下拉:空值行仍是空串,另两档仍是 admin/app', async () => {
const wrapper = await mountMenus()
expect(optionLabels(wrapper, '筛选菜单类型')).toEqual(['全部', '后台', '软件'])
expect(optionValues(wrapper, '筛选菜单类型')).toEqual(['', 'admin', 'app'])
})
it('选「软件」按 menuType 筛表,选回「全部」恢复全量(空串不参与筛选)', async () => {
const wrapper = await mountMenus()
expect(visibleMenuNames(wrapper)).toEqual(['后台菜单', '软件菜单'])
await pickSelectOption(wrapper, '筛选菜单类型', '软件')
expect(visibleMenuNames(wrapper)).toEqual(['软件菜单'])
await pickSelectOption(wrapper, '筛选菜单类型', '全部')
expect(visibleMenuNames(wrapper)).toEqual(['后台菜单', '软件菜单'])
})
})
describe('密钥管理页 × el-select', () => {
it('状态下拉:「全部状态」是空串档,其余各档码逐一在案', async () => {
const wrapper = await mountSecrets()
expect(optionLabels(wrapper, '筛选密钥状态')).toEqual([
'全部状态',
'检测通过',
'检测失败',
'未配齐',
'无法判定/可重试',
'未检测',
])
expect(optionValues(wrapper, '筛选密钥状态')).toEqual(['', 'passed', 'failed', 'incomplete', 'error', 'unknown'])
})
it('分组下拉:「全部分组」仍是 null,组选项是数字 id', async () => {
const wrapper = await mountSecrets()
expect(optionLabels(wrapper, '筛选分组')).toEqual(['全部分组', '甲组', '乙组'])
expect(optionValues(wrapper, '筛选分组')).toEqual([null, 7, 9])
})
it('落参:checkStatus 是状态码、groupId 是数字;选回空值行后两者都不出现', async () => {
const wrapper = await mountSecrets()
await pickSelectOption(wrapper, '筛选密钥状态', '检测失败')
await pickSelectOption(wrapper, '筛选分组', '甲组')
await clickButton(wrapper, '查询')
const selected = lastArgs(secretsApi.fetchUserSecretList)
expect(selected.checkStatus).toBe('failed')
expect(selected.groupId).toBe(7)
// 空值行=不筛:'' / null 都落回 undefined,查询参数与换壳前逐字一致
await pickSelectOption(wrapper, '筛选密钥状态', '全部状态')
await pickSelectOption(wrapper, '筛选分组', '全部分组')
await clickButton(wrapper, '查询')
const cleared = lastArgs(secretsApi.fetchUserSecretList)
expect(cleared.checkStatus).toBeUndefined()
expect(cleared.groupId).toBeUndefined()
})
})
describe('密钥用量页 × el-select', () => {
it('分组下拉与密钥页同口径(全部分组=null),落参仍是数字 id / 缺省', async () => {
const wrapper = await mountUsage()
expect(optionLabels(wrapper, '筛选分组')).toEqual(['全部分组', '甲组', '乙组'])
expect(optionValues(wrapper, '筛选分组')).toEqual([null, 7, 9])
await pickSelectOption(wrapper, '筛选分组', '乙组')
await clickButton(wrapper, '查询')
expect(lastArgs(usageApi.fetchUserSecretUsage).groupId).toBe(9)
await pickSelectOption(wrapper, '筛选分组', '全部分组')
await clickButton(wrapper, '查询')
expect(lastArgs(usageApi.fetchUserSecretUsage).groupId).toBeUndefined()
})
})
@@ -14,9 +14,8 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import { ElOption, ElSelect } from 'element-plus'
import AppearancePatentCleanItemsPage from '@/pages/patent/AppearancePatentCleanItemsPage.vue'
import { adminPages } from '@/router/routes'
@@ -75,40 +74,12 @@ beforeEach(() => {
async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
cleanApi.fetchAppearancePatentCleanList.mockImplementation(() => Promise.resolve(payload))
const wrapper = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia, ElSelect, ElOption] } })
const wrapper = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia] } })
await flushPromises()
await flushPromises()
return wrapper
}
// ---------------- el-select 交互助手(2026-11-17 筛选行/分页条下拉换 el-select,与亚马逊面统一) ----------------
// aria-label 经 EP 的 ariaLabel prop 落在内层 combobox input 上;弹层 teleport 到 body,
// ElOption 仍在挂载树里 ⇒ 选项清单走组件树读,点选走「点开→点选项」真实路径。
function selectByLabel(wrapper: VueWrapper<Element>, label: string) {
const found = wrapper.findAllComponents(ElSelect).find((s) => s.find(`[aria-label="${label}"]`).exists())
expect(found, `应存在 aria-label="${label}" 的下拉`).toBeTruthy()
return found!
}
function optionLabels(wrapper: VueWrapper<Element>, label: string): string[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('label') as string)
}
async function pickSelectOption(wrapper: VueWrapper<Element>, label: string, optionText: string): Promise<void> {
const input = wrapper.get(`[aria-label="${label}"]`)
await input.trigger('click')
await flushPromises()
const contentId = input.attributes('aria-controls')
const scope = (contentId && document.getElementById(contentId)) ?? document.body
const items = [...scope.querySelectorAll('.el-select-dropdown__item')]
.filter((el) => !el.classList.contains('is-hidden'))
const target = items.find((el) => (el.textContent ?? '').trim() === optionText)
expect(target, `下拉应弹出「${optionText}」选项`).toBeTruthy()
await new DOMWrapper(target as Element).trigger('click')
await flushPromises()
}
describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那个格式」)', () => {
it('页面组件落位:明细表 + 明细端点 + 导出,卡片视图与删除入口已下架', () => {
const src = readFileSync(resolve(process.cwd(), PAGE_PATH), 'utf-8')
@@ -244,13 +215,14 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([{ id: 7, name: '甲组', leaderUserId: 9 }])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
const textInputs = wrapper.findAll('.form-group input[type="text"]:not(.el-select__input)')
const textInputs = wrapper.findAll('.form-group input[type="text"]')
expect(textInputs).toHaveLength(2, '任务号+ASIN 两个筛选框恢复(客户要一目了然)')
await textInputs[0].setValue('33874')
await textInputs[1].setValue('B0CLEAN')
await pickSelectOption(wrapper, '筛选国家', '德国') // 国家排在前(模板顺序:任务号/ASIN/国家/分组)
await pickSelectOption(wrapper, '筛选分组', '甲组') // 分组(主管=组长)
const selects = wrapper.findAll('select')
await selects[0].setValue('DE') // 国家排在前(模板顺序:任务号/ASIN/国家/分组)
await selects[1].setValue('7') // 分组(主管=组长)
const dateInputs = wrapper.findAll('input[type="date"]')
await dateInputs[0].setValue('2026-11-01')
await dateInputs[1].setValue('2026-11-09')
@@ -277,12 +249,13 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
expect(cleanApi.fetchDedupeTotalGroups).toHaveBeenCalledWith(1)
const groups = optionLabels(wrapper, '筛选分组')
expect(groups).toContain('全部分组')
expect(groups).toContain('甲组')
const groupSelect = wrapper.findAll('select')[1] // 模板顺序:国家在前、分组在后
const optionTexts = groupSelect.findAll('option').map((o) => o.text())
expect(optionTexts).toContain('全部分组')
expect(optionTexts).toContain('甲组')
const callsBeforeSelect = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
await pickSelectOption(wrapper, '筛选分组', '甲组')
await groupSelect.setValue('7')
await flushPromises()
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBe(callsBeforeSelect + 1,
'选中分组必须立刻重查')
@@ -294,7 +267,7 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
it('重置把筛选面回空并回第一页重取', async () => {
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
const textInputs = wrapper.findAll('.form-group input[type="text"]:not(.el-select__input)')
const textInputs = wrapper.findAll('.form-group input[type="text"]')
await textInputs[0].setValue('33874')
await textInputs[1].setValue('B0CLEAN')
const callsBefore = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
@@ -315,9 +288,8 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
expect(cleanApi.fetchAppearancePatentCleanList).toHaveBeenCalledTimes(2)
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls[1][0].page).toBe(3)
// 每页条数下拉 2026-11-17 随分页条一起换 el-select(OldPagination 内局部注册)。
expect(wrapper.find('.page-size-select').exists()).toBe(true, '分页条下拉保留 .page-size-select 定位类')
await pickSelectOption(wrapper, '每页条数', '50条/页')
const sizeSelect = wrapper.find('.page-size-select')
await sizeSelect.setValue('50')
await flushPromises()
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
expect(last.pageSize).toBe(50)
@@ -342,10 +314,11 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
it('切公司 Tab 重取并清掉上一家的筛选(company-tab-wiring 同口径)', async () => {
cleanApi.fetchDedupeTotalGroups.mockResolvedValue([{ id: 7, name: '甲组', leaderUserId: 9 }])
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 10 })
const textInputs = wrapper.findAll('.form-group input[type="text"]:not(.el-select__input)')
const textInputs = wrapper.findAll('.form-group input[type="text"]')
await textInputs[0].setValue('33874')
await textInputs[1].setValue('B0CLEAN')
await pickSelectOption(wrapper, '筛选分组', '甲组')
const groupSelect = wrapper.findAll('select')[1]
await groupSelect.setValue('7')
const callsBefore = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
useCompanyTabStore().setActiveId(2)
@@ -18,9 +18,8 @@
* 跑法:`npx vitest run tests/mount/jd-database-page.mount.test.ts`
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import { ElOption, ElSelect } from 'element-plus'
import JdDatabasePage from '@/pages/jd/JdDatabasePage.vue'
import OldPagination from '@/components/OldPagination.vue'
@@ -108,44 +107,12 @@ beforeEach(() => {
async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
jdApi.fetchJdProductList.mockImplementation(() => Promise.resolve(payload))
const wrapper = mount(JdDatabasePage, { global: { plugins: [pinia, ElSelect, ElOption] } })
const wrapper = mount(JdDatabasePage, { global: { plugins: [pinia] } })
await flushPromises()
await flushPromises()
return wrapper
}
// ---------------- el-select 交互助手(2026-11-17 两颗下拉换 el-select,与亚马逊面统一) ----------------
// aria-label 经 EP 的 ariaLabel prop 落在内层 combobox input 上;选项弹层 teleport 到 body,
// 但 ElOption/ElSelect 组件仍在挂载树里 ⇒ 选项清单走组件树读,点选走「点开→点选项」真实路径。
/** 按 aria-label 找对应的 ElSelect 组件实例(页面有两颗下拉,靠内层 input 的 aria-label 区分)。 */
function selectByLabel(wrapper: VueWrapper<Element>, label: string) {
const found = wrapper.findAllComponents(ElSelect).find((s) => s.find(`[aria-label="${label}"]`).exists())
expect(found, `应存在 aria-label="${label}" 的下拉`).toBeTruthy()
return found!
}
/** 读某颗下拉的全部选项文案(label prop;组件树查询不受弹层 teleport 影响)。 */
function optionLabels(wrapper: VueWrapper<Element>, label: string): string[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('label') as string)
}
/** 点开指定下拉并点选目标文案的选项(触发 update:modelValue + change,与真实用户一致)。
* 面板按内层 input 的 aria-controls 圈定,避免另一颗(可能仍挂着的)弹层串台。 */
async function pickSelectOption(wrapper: VueWrapper<Element>, label: string, optionText: string): Promise<void> {
const input = wrapper.get(`[aria-label="${label}"]`)
await input.trigger('click')
await flushPromises()
const contentId = input.attributes('aria-controls')
const scope = (contentId && document.getElementById(contentId)) ?? document.body
const items = [...scope.querySelectorAll('.el-select-dropdown__item')]
.filter((el) => !el.classList.contains('is-hidden'))
const target = items.find((el) => (el.textContent ?? '').trim() === optionText)
expect(target, `下拉应弹出「${optionText}」选项`).toBeTruthy()
await new DOMWrapper(target as Element).trigger('click')
await flushPromises()
}
/** 批量编辑分类(2026-11-17 用户口径「店铺分类弹窗删了,加个批量编辑分类」):
* 勾选跨页累计记忆(翻页/重取不清)→ 对话框选目标分类归入或移出 → 按 (ids, groupId,
* ownerGroupId) 提交;成功后清勾选并重取。旧弹窗的「勾选翻页即清」口径同日废止。 */
@@ -154,7 +121,7 @@ describe('批量编辑分类(店铺分类弹窗 2026-11-17 下线后的替代
jdApi.fetchJdProductList
.mockImplementationOnce(() => Promise.resolve({ items: [item(1)], total: 40, page: 1, pageSize: 20 }))
.mockImplementation(() => Promise.resolve({ items: [item(2)], total: 40, page: 2, pageSize: 20 }))
const wrapper = mount(JdDatabasePage, { global: { plugins: [pinia, ElSelect, ElOption] } })
const wrapper = mount(JdDatabasePage, { global: { plugins: [pinia] } })
await flushPromises()
await flushPromises()
const deleteBtn = () => wrapper.get('.jd-delete-btn')
@@ -297,7 +264,7 @@ describe('分类管理入口(V204 独立页并入京东数据库页)', () =>
: Promise.resolve([{ id: 8, name: '裤装', sortOrder: 1, productCount: 1 }])
})
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
expect(optionLabels(wrapper, '筛选店铺分类')).toContain('裙装', '首屏下拉含首取分类')
expect(wrapper.get('[aria-label="筛选店铺分类"]').text()).toContain('裙装', '首屏下拉含首取分类')
await wrapper.findAll('button').find((b) => b.text() === '分类管理')!.trigger('click')
await flushPromises()
@@ -309,8 +276,9 @@ describe('分类管理入口(V204 独立页并入京东数据库页)', () =>
await flushPromises()
expect(jdApi.deleteJdProductGroup, '删除按钮属于当前列表行').toHaveBeenCalledWith(8)
// changed → 父页 loadGroupOptions:下拉按新列表重取(最后一次调用拿到删后列表)。
expect(optionLabels(wrapper, '筛选店铺分类')).toContain('裤装', '下拉刷新出新一轮分类')
expect(optionLabels(wrapper, '筛选店铺分类')).not.toContain('裙装', '删掉的分类不再出现在筛选下拉')
const select = wrapper.get('[aria-label="筛选店铺分类"]')
expect(select.text()).toContain('裤装', '下拉刷新出新一轮分类')
expect(select.text()).not.toContain('裙装', '删掉的分类不再出现在筛选下拉')
wrapper.unmount()
})
})
@@ -450,7 +418,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(textInputs).toHaveLength(2, '商品编码+标题关键字两个文本筛选框(店铺/商品状态已下线)')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
await pickSelectOption(wrapper, '筛选店铺分类', '甲组')
await wrapper.get('[aria-label="筛选店铺分类"]').setValue('7')
const dateInputs = wrapper.findAll('input[type="date"]')
await dateInputs[0].setValue('2026-11-01')
await dateInputs[1].setValue('2026-11-09')
@@ -573,8 +541,9 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
it('重置把筛选面回空并回第一页重取', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 1 }])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
expect(optionLabels(wrapper, '筛选店铺分类')[0]).toBe('全部分类', '「全部分类」常驻列表首位(与旧原生下拉同语义)')
await pickSelectOption(wrapper, '筛选店铺分类', '甲组')
const select = wrapper.get('[aria-label="筛选店铺分类"]')
expect(select.text()).toContain('全部分类')
await select.setValue('7')
await wrapper.get('.cat-trigger').trigger('click')
await wrapper.get('.cat-search').setValue('艺考')
await wrapper.get('.cat-col-search .cat-row').trigger('click')
@@ -589,7 +558,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({ productCode: '', titleKeyword: '', groupId: '', category: '', page: 1 }, '重置后筛选全空、回第一页')
expect(selectByLabel(wrapper, '筛选店铺分类').props('modelValue')).toBe('', '重置后分类筛选回「全部分类」')
expect((select.element as HTMLSelectElement).value).toBe('')
})
it('翻页与改每页条数都重发请求,改条数回第一页', async () => {
@@ -600,10 +569,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList).toHaveBeenCalledTimes(2)
expect(jdApi.fetchJdProductList.mock.calls[1][0].page).toBe(3)
// 每页条数下拉 2026-11-17 随分页条一起换 el-select(OldPagination 内局部注册):
// 点开→点选项,不再走原生 setValue。
expect(wrapper.find('.page-size-select').exists()).toBe(true, '分页条下拉保留 .page-size-select 定位类')
await pickSelectOption(wrapper, '每页条数', '50条/页')
const sizeSelect = wrapper.find('.page-size-select')
await sizeSelect.setValue('50')
await flushPromises()
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last.pageSize).toBe(50)
@@ -878,12 +845,12 @@ describe('京东数据库分类按数据权限分组隔离(V203)', () => {
const picker = wrapper.get('[aria-label="当前分组"]')
// 2026-11-16 用户口径「做成分组」:分组在筛选行里是带标签的表单控件(与其他筛选同壳同圆角),
// 不再是工具栏裸下拉——钉住形状,防止搬回工具栏或丢标签。
const groupField = picker.element.closest('.form-group')
const groupField = (picker.element as HTMLSelectElement).closest('.form-group')
expect(groupField?.querySelector('label')?.textContent).toBe('分组')
expect(optionLabels(wrapper, '当前分组')).toEqual(['甲公司 / A组', '甲公司 / B组'],
expect(picker.findAll('option').map((o) => o.text())).toEqual(['甲公司 / A组', '甲公司 / B组'],
'跨公司组名由后端拼进 label,前端不解析公司字段')
await pickSelectOption(wrapper, '当前分组', '甲公司 / B组')
await picker.setValue('12')
await flushPromises()
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith(12)
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ ownerGroupId: 12, page: 1 },
@@ -909,12 +876,13 @@ describe('京东数据库分类按数据权限分组隔离(V203)', () => {
],
})
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
await pickSelectOption(wrapper, '当前分组', '甲公司 / B组')
const picker = wrapper.get('[aria-label="当前分组"]')
await picker.setValue('12')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ ownerGroupId: 12 })
await wrapper.findAll('button').find((b) => b.text() === '重置')!.trigger('click')
await flushPromises()
expect(selectByLabel(wrapper, '当前分组').props('modelValue')).toBe(12, '重置不清当前分组(作用域语义,搬进筛选行也不变)')
expect((picker.element as HTMLSelectElement).value).toBe('12', '重置不清当前分组(作用域语义,搬进筛选行也不变)')
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ ownerGroupId: 12 },
'重置后的重取仍带当前分组')
wrapper.unmount()
@@ -925,7 +893,7 @@ describe('京东数据库分类按数据权限分组隔离(V203)', () => {
const wrapper = await mountWith({ items: [item(1, { groupId: null, groupName: '' })], total: 1, page: 1, pageSize: 20 })
expect(wrapper.find('[aria-label="当前分组"]').exists()).toBe(false)
expect(wrapper.find('.jd-group-locked').exists()).toBe(false, '没有分组就没有可锁定的组名')
expect(optionLabels(wrapper, '筛选店铺分类')).toEqual(['全部分类'], '分类筛选只剩「全部分类」')
expect(wrapper.find('[aria-label="筛选店铺分类"]').text()).toContain('全部分类', '分类筛选只剩「全部分类」')
expect(wrapper.findAll('tbody tr')[0].findAll('td')[1].text()).toBe('未分类')
expect(wrapper.findAll('button').some((b) => b.text() === '批量编辑分类')).toBe(false, '没有分组就没有可写的分类面')
expect(jdApi.batchAssignJdProductGroup).not.toHaveBeenCalled()
@@ -1,215 +0,0 @@
/**
* 日志管理页 / 生成记录页的原生 <select> → el-select(2026-11-17 用户口径「和亚马逊不统一」:
* 原生 select 的弹层是浏览器直角原生物 ⇒ 换 EP 圆角弹层,外壳走全局 .admin-filter)。
*
* 这里钉住换壳时最容易错的两件事:
* 1. **值形状逐字不变**——「全部来源」/「全部用户」空行仍是 ''、用户仍是 String(id)、
* 终端仍是 `${source}|${deviceId}`、模式仍是 'full'/'selected' 常量(后端按这些字符串解析,
* 形状一动就错单,而界面上看起来只是"选了个下拉");
* 2. **选中 → 落参的链路仍只有一处**——来源 source、用户 Number(uid)、终端 '|' 切分与 mode 常量。
*
* aria-label 经 EP 的 ariaLabel prop 落在内层 combobox input 上,选项清单走组件树读
* (弹层 teleport 到 body),点选走「点开→点选项」真实路径。
* 不用 readFileSync(source-pin-ratchet 对台账外新文件带读点即红),全部走真实挂载断言。
*
* 跑法:`npx vitest run tests/mount/records-select-el.mount.test.ts`
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import { defineComponent, h } from 'vue'
import { ElOption, ElSelect } from 'element-plus'
import DeviceLogsPage from '@/pages/records/DeviceLogsPage.vue'
import RecordsHistoryPage from '@/pages/records/RecordsHistoryPage.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
const deviceLogsApi = vi.hoisted(() => ({
fetchDeviceLogFiles: vi.fn(),
fetchDeviceLogContent: vi.fn(),
fetchDeviceLogConfig: vi.fn(),
fetchDeviceLogDevices: vi.fn(),
deviceLogDownloadUrl: vi.fn((id: number) => `/api/admin/device-logs/${id}/download`),
deleteDeviceLogFile: vi.fn(),
deleteDeviceLogOverride: vi.fn(),
updateDeviceLogGlobalMode: vi.fn(),
updateDeviceLogOverride: vi.fn(),
}))
const historyApi = vi.hoisted(() => ({
fetchHistoryList: vi.fn(),
fetchHistoryUserOptions: vi.fn(),
}))
vi.mock('@/api/device-logs', () => deviceLogsApi)
vi.mock('@/pages/records/history-api.ts', () => historyApi)
/** 采集配置弹窗(el-dialog)用桩:真实 dialog 把内容 teleport 到 body,wrapper 里就查不到;
* 桩只留一层 div 并把默认插槽摊在挂载树里,modelValue 与真实一样控制开关。 */
const DialogStub = defineComponent({
name: 'ElDialogStub',
props: { modelValue: { type: Boolean, default: false } },
setup(props, { slots }) {
return () => (props.modelValue ? h('div', { class: 'dialog-stub' }, slots.default?.()) : null)
},
})
// ---------------- el-select 交互助手(与京东数据库页/亚马逊面同一套口径) ----------------
/** 按 aria-label 找对应的 ElSelect 组件实例(页面里还有 OldPagination 的「每页条数」,靠 aria-label 区分)。 */
function selectByLabel(wrapper: VueWrapper<Element>, label: string) {
const found = wrapper.findAllComponents(ElSelect).find((s) => s.find(`[aria-label="${label}"]`).exists())
expect(found, `应存在 aria-label="${label}" 的下拉`).toBeTruthy()
return found!
}
/** 读某颗下拉的全部选项文案(label prop;组件树查询不受弹层 teleport 影响)。 */
function optionLabels(wrapper: VueWrapper<Element>, label: string): string[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('label') as string)
}
/** 读某颗下拉的全部选项 value(形状判据:空串/字符串 id/`source|deviceId`/mode 常量)。 */
function optionValues(wrapper: VueWrapper<Element>, label: string): unknown[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('value'))
}
/** 点开指定下拉并点选目标文案的选项(触发 update:modelValue + change,与真实用户一致)。
* 面板按内层 input 的 aria-controls 圈定,避免另一颗(可能仍挂着的)弹层串台。 */
async function pickSelectOption(wrapper: VueWrapper<Element>, label: string, optionText: string): Promise<void> {
const input = wrapper.get(`[aria-label="${label}"]`)
await input.trigger('click')
await flushPromises()
const contentId = input.attributes('aria-controls')
const scope = (contentId && document.getElementById(contentId)) ?? document.body
const items = [...scope.querySelectorAll('.el-select-dropdown__item')].filter((el) => !el.classList.contains('is-hidden'))
const target = items.find((el) => (el.textContent ?? '').trim() === optionText)
expect(target, `下拉应弹出「${optionText}」选项`).toBeTruthy()
await new DOMWrapper(target as Element).trigger('click')
await flushPromises()
}
/** 按文案点按钮(筛选条上的查询/重置、弹窗里的添加/更新覆盖)。 */
async function clickButton(wrapper: VueWrapper<Element>, text: string): Promise<void> {
const button = wrapper.findAll('button').find((b) => b.text().trim() === text)
expect(button, `应存在「${text}」按钮`).toBeTruthy()
await button!.trigger('click')
await flushPromises()
await flushPromises()
}
/** 最近一次调用的入参(首屏 + 公司 tab watch 可能各发一次,判"选完落什么参"只认最后一次)。 */
function lastArgs(fn: { mock: { calls: unknown[][] } }): Record<string, unknown> {
const calls = fn.mock.calls
expect(calls.length, '接口应至少被调用一次').toBeGreaterThan(0)
return calls[calls.length - 1][0] as Record<string, unknown>
}
const USERS = [
{ id: 7, username: '张三' },
{ id: 8, username: '李四' },
]
let pinia: Pinia
beforeEach(() => {
vi.clearAllMocks()
pinia = createPinia()
setActivePinia(pinia)
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
historyApi.fetchHistoryUserOptions.mockResolvedValue(USERS)
})
async function mountDeviceLogs(): Promise<VueWrapper<Element>> {
deviceLogsApi.fetchDeviceLogFiles.mockResolvedValue({ items: [], total: 0, page: 1, pageSize: 15, retentionDays: 7 })
deviceLogsApi.fetchDeviceLogConfig.mockResolvedValue({ globalMode: 'full', overrides: [] })
deviceLogsApi.fetchDeviceLogDevices.mockResolvedValue([
{ source: 'client', deviceId: 'dev-1', deviceName: '工位A', lastUploadAt: null },
])
const wrapper = mount(DeviceLogsPage, {
global: { plugins: [pinia, ElSelect, ElOption], stubs: { ElDialog: DialogStub } },
})
await flushPromises()
await flushPromises()
return wrapper
}
describe('日志管理页 × el-select', () => {
it('筛选条两颗下拉:空行/字符串 id/来源常量逐字不变', async () => {
const wrapper = await mountDeviceLogs()
expect(optionLabels(wrapper, '来源')).toEqual(['全部来源', '桌面客户端', '麦象采集机'])
expect(optionValues(wrapper, '来源')).toEqual(['', 'client', 'maixiang'])
// 用户清单很长 ⇒ filterable;值仍是 String(id)(下游 `uidFilter.value ? Number(...)` 判空)
expect(selectByLabel(wrapper, '指定用户').props('filterable')).toBe(true)
expect(optionLabels(wrapper, '指定用户')).toEqual(['全部用户', '张三', '李四'])
expect(optionValues(wrapper, '指定用户')).toEqual(['', '7', '8'])
wrapper.unmount()
})
it('选中来源/用户后查询:source 走常量、uid 仍是数字', async () => {
const wrapper = await mountDeviceLogs()
await pickSelectOption(wrapper, '来源', '麦象采集机')
await pickSelectOption(wrapper, '指定用户', '李四')
await clickButton(wrapper, '查询')
const args = lastArgs(deviceLogsApi.fetchDeviceLogFiles)
expect(args.source).toBe('maixiang')
expect(args.uid).toBe(8)
expect(typeof args.uid).toBe('number')
wrapper.unmount()
})
it('重置回到空值首行:不发 source、不发 uid(空串的「全部」语义不变)', async () => {
const wrapper = await mountDeviceLogs()
await pickSelectOption(wrapper, '来源', '桌面客户端')
await pickSelectOption(wrapper, '指定用户', '张三')
await clickButton(wrapper, '重置')
const args = lastArgs(deviceLogsApi.fetchDeviceLogFiles)
expect(args.source).toBeUndefined()
expect(args.uid).toBeUndefined()
wrapper.unmount()
})
it('采集配置弹窗:终端值仍是 `source|deviceId`、模式仍是 full/selected 常量', async () => {
const wrapper = await mountDeviceLogs()
await clickButton(wrapper, '采集配置')
expect(optionLabels(wrapper, '选择终端')).toEqual(['选择终端(最近上报的设备)', '桌面客户端 · 工位A(dev-1)'])
expect(optionValues(wrapper, '选择终端')).toEqual(['', 'client|dev-1'])
expect(optionLabels(wrapper, '覆盖模式')).toEqual(['全量采集', '精选采集'])
expect(optionValues(wrapper, '覆盖模式')).toEqual(['full', 'selected'])
await pickSelectOption(wrapper, '选择终端', '桌面客户端 · 工位A(dev-1)')
await pickSelectOption(wrapper, '覆盖模式', '全量采集')
await clickButton(wrapper, '添加/更新覆盖')
expect(deviceLogsApi.updateDeviceLogOverride).toHaveBeenCalledWith('client', 'dev-1', '工位A', 'full')
wrapper.unmount()
})
})
describe('生成记录页 × el-select', () => {
async function mountHistory(): Promise<VueWrapper<Element>> {
historyApi.fetchHistoryList.mockResolvedValue({ items: [], total: 0, page: 1, pageSize: 10 })
const wrapper = mount(RecordsHistoryPage, { global: { plugins: [pinia, ElSelect, ElOption] } })
await flushPromises()
await flushPromises()
return wrapper
}
it('指定用户下拉:空行 + String(id) 值形状不变', async () => {
const wrapper = await mountHistory()
expect(selectByLabel(wrapper, '指定用户').props('filterable')).toBe(true)
expect(optionLabels(wrapper, '指定用户')).toEqual(['全部用户', '张三', '李四'])
expect(optionValues(wrapper, '指定用户')).toEqual(['', '7', '8'])
wrapper.unmount()
})
it('选用户查询发数字 userId;选回「全部用户」不发 userId', async () => {
const wrapper = await mountHistory()
await pickSelectOption(wrapper, '指定用户', '李四')
await clickButton(wrapper, '查询')
expect(lastArgs(historyApi.fetchHistoryList).userId).toBe(8)
await pickSelectOption(wrapper, '指定用户', '全部用户')
await clickButton(wrapper, '查询')
expect(lastArgs(historyApi.fetchHistoryList).userId).toBeUndefined()
wrapper.unmount()
})
})
@@ -9,7 +9,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import { ElOption, ElSelect } from 'element-plus'
import KeywordUsagePage from '@/pages/tasks/KeywordUsagePage.vue'
import BrandGatingPanel from '@/pages/tasks/BrandGatingPanel.vue'
@@ -51,9 +50,7 @@ const loadingDirective = { mounted() {}, updated() {} }
function mountPage(component: Parameters<typeof mount>[0], pinia: Pinia): VueWrapper {
return mount(component, {
global: {
// 筛选下拉 2026-11-17 换成 el-select(原生 select 弹层是直角原生物,与亚马逊页不统一),
// 两支页面都要把 EP 组件注册进来,否则渲染成未解析标签。
plugins: [pinia, ElSelect, ElOption],
plugins: [pinia],
directives: { loading: loadingDirective },
},
})
@@ -17,30 +17,12 @@
*/
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
import { ElOption, ElSelect } from 'element-plus'
import { createPinia, setActivePinia, type Pinia } from 'pinia'
import UserSecretsPage from '@/pages/account/UserSecretsPage.vue'
import { useAdminSessionStore } from '@/stores/admin-session'
import { useCompanyTabStore } from '@/stores/company-tab'
/* 筛选下拉 2026-11-17 起是 el-select(原生 select 的弹层是浏览器直角原生物,用户要求与亚马逊统一)。
页面模板不带局部 import、靠 main.ts 全局注册,挂载测试不跑 main.ts ⇒ 必须在这里显式注册,
否则拿到的是未解析的空壳,`findAllComponents(ElSelect)` 一条也找不到。 */
const EL_PLUGINS = [ElSelect, ElOption]
/** 按 aria-label 找下拉:EP 把该属性落在内层 combobox input 上,比按节点顺序取更稳。 */
function selectByLabel(wrapper: VueWrapper<Element>, label: string) {
const found = wrapper.findAllComponents(ElSelect).find((s) => s.find(`[aria-label="${label}"]`).exists())
expect(found, `应存在 aria-label="${label}" 的下拉`).toBeTruthy()
return found!
}
/** 下拉里每一档的文案(读 el-option 的 label prop,不依赖插槽文本)。 */
function optionLabels(wrapper: VueWrapper<Element>, label: string): string[] {
return selectByLabel(wrapper, label).findAllComponents(ElOption).map((o) => o.props('label') as string)
}
const secretsApi = vi.hoisted(() => ({
fetchUserSecretList: vi.fn(),
fetchAdminSecretBalances: vi.fn(),
@@ -124,7 +106,7 @@ describe('密钥管理页:检测结果按 check_code 分档渲染', () => {
async function mountWith(rowValue: Record<string, unknown>) {
secretsApi.fetchUserSecretList.mockResolvedValue({ items: [rowValue], total: 1, page: 1, pageSize: 15, groupOptions: [] })
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia, ...EL_PLUGINS] } })
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia] } })
await flushPromises()
return wrapper
}
@@ -257,7 +239,7 @@ describe('密钥管理页:检测结果按 check_code 分档渲染', () => {
it('筛选项把 error 这一档的两个可能读法都点名(选了要能筛到无可用通道的行)', async () => {
const wrapper = await mountWith(busyRow())
const options = optionLabels(wrapper, '筛选密钥状态')
const options = wrapper.findAll('.secrets-filter-row select')[0].findAll('option').map((option) => option.text().trim())
expect(options).toContain('无法判定/可重试')
expect(options).not.toContain('无法判定')
})
@@ -267,7 +249,7 @@ describe('密钥管理页:检测结果按 check_code 分档渲染', () => {
secretsApi.checkUserSecret.mockResolvedValue([
{ moduleKey: 'proxy', checkStatus: 'error', checkCode: 'channel_busy', checkMessage: BUSY_MESSAGE, checkLatencyMs: 30, checkedAt: '2026-11-02T15:51:07', viaProxy: false },
])
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia, ...EL_PLUGINS] } })
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia] } })
await flushPromises()
const checkButton = wrapper.findAll('button').find((button) => button.text().trim() === '立即检测')
expect(checkButton, '行内应有「立即检测」入口').toBeDefined()
@@ -19,14 +19,7 @@ const messageMock = vi.hoisted(() => ({ success: vi.fn() }))
vi.mock('@/pages/records/workbench-client-api.ts', () => api)
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmMock }))
vi.mock('@/components/admin-feedback-ui', () => ({ showAdminFeedback: feedbackMock }))
// 整包 mock element-plus 时,凡被挂载树里其它组件「局部 import」的 EP 组件都要一并给桩:
// OldPagination 2026-11-17 起用 ElSelect/ElOption 渲染每页条数下拉,缺桩会
// 让 render 拿到 undefined 抛 shapeFlag 错(本文件曾因此红)。样式与弹层不参与本页断言。
vi.mock('element-plus', () => ({
ElMessage: messageMock,
ElSelect: { name: 'ElSelect', render: () => null },
ElOption: { name: 'ElOption', render: () => null },
}))
vi.mock('element-plus', () => ({ ElMessage: messageMock }))
const SHA = 'c'.repeat(64)
const row = {
@@ -120,6 +120,9 @@ public class AdminJdProductController {
@RequestParam(name = "synced_from", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedFrom,
@Parameter(description = "同步结束时间(包含,ISO datetime)")
@RequestParam(name = "synced_to", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime syncedTo,
@Parameter(description = "分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」):"
+ "true=当前分组下有分类,false=未分类,缺省=全部;按 V203 归属表 SQL 侧下推")
@RequestParam(name = "classified", required = false) Boolean classified,
HttpServletRequest request) {
RequestOperator operator = requireJdAccess(request);
if (request.getParameter("grouped") != null || request.getParameter("ungrouped") != null) {
@@ -131,7 +134,8 @@ public class AdminJdProductController {
requireVisibleCategory(scope, groupId);
}
return ApiResponse.success(jdProductQueryService.page(page, pageSize,
productCode, titleKeyword, category, groupId, syncedFrom, syncedTo, scopedOwnerGroupId));
productCode, titleKeyword, category, groupId, syncedFrom, syncedTo, classified,
scopedOwnerGroupId));
}
@GetMapping("/categories")
@@ -49,13 +49,18 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
* 「分类不要了,全部整合到类目里」撤掉(独立「分类」筛选框前端下线,
* {@code groupId} 改由类目面板「自定义分类」选中驱动)。
* 店铺名过滤参数已随 2026-11-15 客户口径「店铺不需要」同窗撤掉(DB 列与详情/回传链不动)。
* {@code classified}+{@code ownerGroupId}(2026-11-17 用户口径「加个已分类和未分类的筛选」):
* 按 V203 归属表 EXISTS/NOT EXISTS 快筛分类状态,NULL=不过滤;与 11-16 撤掉的旧
* grouped/ungrouped(读已停用的 biz_jd_product.group_id 列)不是一回事。
*/
long countProducts(@Param("productCode") String productCode,
@Param("titleKeyword") String titleKeyword,
@Param("category") String category,
@Param("groupId") Long groupId,
@Param("syncedFrom") LocalDateTime syncedFrom,
@Param("syncedTo") LocalDateTime syncedTo);
@Param("syncedTo") LocalDateTime syncedTo,
@Param("classified") Boolean classified,
@Param("ownerGroupId") Long ownerGroupId);
/**
* 商品上架配额计数({@code JdPublishQuotaService}):按 owner uid 集(管理员本人+
@@ -95,6 +100,8 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
@Param("groupId") Long groupId,
@Param("syncedFrom") LocalDateTime syncedFrom,
@Param("syncedTo") LocalDateTime syncedTo,
@Param("classified") Boolean classified,
@Param("ownerGroupId") Long ownerGroupId,
@Param("offset") long offset,
@Param("limit") int limit);
@@ -79,14 +79,18 @@ public class JdProductQueryService {
* 分页查询商品行({@code synced_at} 倒序)。
*
* <p>过滤面:商品编码 contains、标题关键词 contains、类目 eq、分组 eq(2026-11-16 起
* 由类目面板「自定义分类」选中驱动)、同步起止(datetime 闭区间)。
* 未分类/已分类两档(ungrouped/grouped)与独立「分类」筛选框随同日口径
* 「分类不要了,全部整合到类目里」整批撤掉。
* 由类目面板「自定义分类」选中驱动)、同步起止(datetime 闭区间)、分类状态档
* {@code classified}(2026-11-17 用户口径「加个已分类和未分类的筛选」:true=当前分组下
* 有分类、false=没有、null=全部;按 V203 归属表 EXISTS/NOT EXISTS 在 SQL 侧下推,
* 判据与 {@link #fillGroupNames} 填分类列的条件同形——「筛选说未分类的行,列表分类列
* 也必须是未分类」)。
* 2026-11-16 撤掉的旧 ungrouped/grouped 两档读的是已停用的 biz_jd_product.group_id 列,
* 与本档不是一回事;独立「分类」筛选框的撤掉口径不变。
* 公司维过滤已随 2026-11-16 摘公司 tab 整批撤掉(全平台公共)。</p>
*/
public JdProductPageVo page(Long page, Long pageSize,
String productCode, String titleKeyword, String category, Long groupId,
LocalDateTime syncedFrom, LocalDateTime syncedTo, Long ownerGroupId) {
LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified, Long ownerGroupId) {
if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) {
throw new BusinessException("开始时间不能晚于结束时间");
}
@@ -94,14 +98,14 @@ public class JdProductQueryService {
long safeSize = pageSize == null ? PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT
: Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE);
Filter filter = filter(productCode, titleKeyword, category,
groupId, syncedFrom, syncedTo);
groupId, syncedFrom, syncedTo, classified);
long total = jdProductMapper.countProducts(filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(),
filter.syncedFrom(), filter.syncedTo());
filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId);
List<JdProductEntity> rows = total <= 0 ? List.of()
: jdProductMapper.selectProductPage(filter.productCode(),
filter.titleKeyword(), filter.category(), filter.groupId(),
filter.syncedFrom(), filter.syncedTo(),
filter.syncedFrom(), filter.syncedTo(), filter.classified(), ownerGroupId,
(safePage - 1) * safeSize, (int) safeSize);
List<JdProductListItemVo> items = rows.stream().map(this::toListItem).toList();
fillGroupNames(items, ownerGroupId);
@@ -176,18 +180,19 @@ public class JdProductQueryService {
// ---------------------------------------------------------------- 过滤面
/** 服务侧过滤面归一:groupId ≤0 按没选处理,文本 trim 后空串归 null(无公司维,2026-11-16 摘)。 */
/** 服务侧过滤面归一:groupId ≤0 按没选处理,文本 trim 后空串归 null(无公司维,2026-11-16 摘);
* classified 原样直传(null=不过滤该面,2026-11-17 分类状态快筛)。 */
private record Filter(String productCode, String titleKeyword,
String category, Long groupId,
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified) {
}
private static Filter filter(String productCode, String titleKeyword,
String category, Long groupId,
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
LocalDateTime syncedFrom, LocalDateTime syncedTo, Boolean classified) {
Long safeGroupId = groupId != null && groupId > 0 ? groupId : null;
return new Filter(trimToNull(productCode), trimToNull(titleKeyword),
trimToNull(category), safeGroupId, syncedFrom, syncedTo);
trimToNull(category), safeGroupId, syncedFrom, syncedTo, classified);
}
// ---------------------------------------------------------------- 列表/详情搬运
@@ -122,6 +122,29 @@
WHERE a.product_id = p.id AND a.category_id = #{groupId}
)
</if>
<!-- 分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」):已分类=在
「当前数据权限分组」(owner_group_id)下有 category_id 非空的归属行——与读侧
fillGroupNames 把分类列填出来的条件同形;未分类=NOT EXISTS。谓词 SQL 侧下推
(铁律 20 同形,不得 Java 侧对已取页 filter)。owner_group_id 为 NULL(作用域
无可分组)时 EXISTS 恒假、NOT EXISTS 恒真——与列表「分类列全空」口径天然一致,
不需要服务侧特判。与 2026-11-16 撤掉的旧 grouped/ungrouped 不是一回事:那两档
读的是已停用的 biz_jd_product.group_id 列,本档读 V203 归属表。 -->
<if test="classified != null">
<choose>
<when test="classified == true">
AND EXISTS (
SELECT 1 FROM biz_jd_product_group_assign cs
WHERE cs.product_id = p.id AND cs.owner_group_id = #{ownerGroupId} AND cs.category_id IS NOT NULL
)
</when>
<otherwise>
AND NOT EXISTS (
SELECT 1 FROM biz_jd_product_group_assign cs
WHERE cs.product_id = p.id AND cs.owner_group_id = #{ownerGroupId} AND cs.category_id IS NOT NULL
)
</otherwise>
</choose>
</if>
<if test="syncedFrom != null">AND p.synced_at &gt;= #{syncedFrom}</if>
<if test="syncedTo != null">AND p.synced_at &lt;= #{syncedTo}</if>
</sql>
@@ -164,6 +164,10 @@ class AdminJdProductControllerTest {
}
assertFalse(source.contains("@RequestParam(name = \"ungrouped\""));
assertFalse(source.contains("@RequestParam(name = \"grouped\""));
// 2026-11-17 分类状态快筛:新参数名 classified(不复用旧 grouped/ungrouped 两档——
// 那两档读已停用的 biz_jd_product.group_id 列,语义不同,旧参数仍必须被拒收)。
assertTrue(source.contains("@RequestParam(name = \"classified\""),
"分类状态快筛参数 classified 必须在册(2026-11-17 用户口径)");
// company_id 参数已随 2026-11-16「删除掉公司 tab」整批摘除(读侧零公司维度支另有反向钉)。
assertFalse(source.contains("company_id"), "company_id 请求参数必须已删除,不得回潜");
// 商品状态筛选框已随 2026-11-15 客户口径从前端下线 ⇒ 服务端同名参数一起撤(反向钉住防回潜)。
@@ -279,8 +283,8 @@ class AdminJdProductControllerTest {
// 读:菜单权限命中即放行(公共库一人一份全量)。
JdProductPageVo pageVo = new JdProductPageVo();
pageVo.setItems(List.of());
when(queryService.page(1L, 20L, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo);
assertEquals(Boolean.TRUE, controller.page(1L, 20L, null, null, null, null, null, null, null, request)
when(queryService.page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo);
assertEquals(Boolean.TRUE, controller.page(1L, 20L, null, null, null, null, null, null, null, null, request)
.isSuccess(), "非超管有菜单权限时读必须放行(读写分档只收窄写)");
// 商品行写:四条写入口一律 403,且业务服务一次都没被调到(不能「先写再拒」)。
@@ -429,11 +433,11 @@ class AdminJdProductControllerTest {
when(groupService.requireCategory(8L)).thenReturn(category(8L, 20L));
BusinessException ex = assertThrows(BusinessException.class,
() -> controller.page(1L, 20L, null, null, null, 8L, null, null, null, request));
() -> controller.page(1L, 20L, null, null, null, 8L, null, null, null, null, request));
assertTrue(ex.getMessage().contains("无权查看该分组的分类"),
"跨组分类筛选必须 403 点名分组,不做空结果降级");
verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any(), any());
}
// ===================== 行为样本 =====================
@@ -461,13 +465,13 @@ class AdminJdProductControllerTest {
pageVo.setTotal(0L);
pageVo.setPage(1L);
pageVo.setPageSize((long) PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT);
when(queryService.page(1L, 20L, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo);
when(queryService.page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID)).thenReturn(pageVo);
// 请求面没有 company_id:任何授权身份看到的都是同一份全量;分类列按 owner_group_id 取。
ApiResponse<JdProductPageVo> response = controller.page(1L, 20L, null, null, null, null,
GROUP_ID, null, null, request);
GROUP_ID, null, null, null, request);
verify(queryService).page(1L, 20L, null, null, null, null, null, null, GROUP_ID);
verify(queryService).page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID);
assertEquals(Boolean.TRUE, response.isSuccess(), "拒绝走 403 业务码,放行必须是 success 信封(B80-03)");
assertEquals(pageVo, response.getData());
}
@@ -491,12 +495,12 @@ class AdminJdProductControllerTest {
for (String value : List.of("true", "false", "")) {
when(request.getParameter(name)).thenReturn(value);
BusinessException ex = assertThrows(BusinessException.class,
() -> controller.page(1L, 20L, null, null, null, 7L, null, null, null, request));
() -> controller.page(1L, 20L, null, null, null, 7L, null, null, null, null, request));
assertTrue(ex.getMessage().contains("刷新页面"));
when(request.getParameter(name)).thenReturn(null);
}
}
verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any());
verify(queryService, never()).page(any(), any(), any(), any(), any(), any(), any(), any(), any(), any());
}
@Test
@@ -615,23 +619,23 @@ class AdminJdProductControllerTest {
void 查询服务分页钳制防溢出() {
JdProductMapper mapper = mock(JdProductMapper.class);
JdProductQueryService service = queryService(mapper);
when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(1L);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
// page=0 / size=null ⇒ 归一为第 1 页、默认 20 条;offset = 0。
service.page(0L, null, null, null, null, null, null, null, null);
service.page(0L, null, null, null, null, null, null, null, null, null);
ArgumentCaptor<Long> offset = ArgumentCaptor.forClass(Long.class);
ArgumentCaptor<Integer> limit = ArgumentCaptor.forClass(Integer.class);
verify(mapper).selectProductPage(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(),
offset.capture(), limit.capture());
isNull(), isNull(), offset.capture(), limit.capture());
assertEquals(0L, offset.getValue());
assertEquals(PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT, limit.getValue());
// page=Long.MAX_VALUE / size=500 ⇒ 钳到 10_000 页、100 条;乘积 999_900 不得变负(铁律 15)。
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null);
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null, null);
ArgumentCaptor<Long> offsetMax = ArgumentCaptor.forClass(Long.class);
ArgumentCaptor<Integer> limitMax = ArgumentCaptor.forClass(Integer.class);
verify(mapper, times(2)).selectProductPage(any(), any(), any(), any(), any(), any(),
offsetMax.capture(), limitMax.capture());
any(), any(), offsetMax.capture(), limitMax.capture());
assertEquals(999_900L, offsetMax.getValue(), "(page-1)*page_size 最大 999_900,钳制后不得溢出变负");
assertEquals(100, limitMax.getValue());
}
@@ -643,23 +647,77 @@ class AdminJdProductControllerTest {
LocalDateTime from = LocalDateTime.of(2026, 11, 14, 12, 0);
LocalDateTime to = LocalDateTime.of(2026, 11, 14, 8, 0);
BusinessException ex = assertThrows(BusinessException.class,
() -> service.page(1L, 20L, null, null, null, null, from, to, null));
() -> service.page(1L, 20L, null, null, null, null, from, to, null, null));
assertTrue(ex.getMessage().contains("开始时间不能晚于结束时间"), "倒挂时间按业务异常拒绝");
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any());
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any());
}
@Test
void 查询服务过滤面原样直传且空串归null() {
JdProductMapper mapper = mock(JdProductMapper.class);
JdProductQueryService service = queryService(mapper);
when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(1L);
service.page(1L, 20L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 7L, null, null, null);
verify(mapper).countProducts("SKU-1", "连衣裙", "艺考形体服", 7L, null, null);
verify(mapper).selectProductPage("SKU-1", "连衣裙", "艺考形体服", 7L, null, null, 0L, 20);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
service.page(1L, 20L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 7L, null, null, null, null);
verify(mapper).countProducts("SKU-1", "连衣裙", "艺考形体服", 7L, null, null, null, null);
verify(mapper).selectProductPage("SKU-1", "连衣裙", "艺考形体服", 7L, null, null, null, null, 0L, 20);
service.page(1L, 20L, " ", null, null, 0L, null, null, null);
verify(mapper).countProducts(null, null, null, null, null, null);
verify(mapper).selectProductPage(null, null, null, null, null, null, 0L, 20);
service.page(1L, 20L, " ", null, null, 0L, null, null, null, null);
verify(mapper).countProducts(null, null, null, null, null, null, null, null);
verify(mapper).selectProductPage(null, null, null, null, null, null, null, null, 0L, 20);
}
/**
* 分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」):
* ① classified+ownerGroupId 必须原样下传给 mapper(谓词在 XML 的 EXISTS/NOT EXISTS 段,
* 铁律 20 同形——不得 Java 侧对已取页 filter);
* ② XML 绊线:两分支谓词逐字在册(改回 Java filter 或摘掉 owner_group_id 关联即红);
* ③ 控制器把请求的 classified 直传服务(不吞、不改写)。
*/
@Test
void 分类状态快筛必须SQL下推且classified与ownerGroupId成对直传() throws IOException {
// ② XML 绊线:classified 档的 EXISTS/NOT EXISTS 两分支都在 productConds 里,
// 且按「当前分组」owner_group_id+category_id 非空判——与读侧填分类列同形。
Path xml = findJdProductMapperXml();
String xmlText = stripComments(Files.readString(xml)).replaceAll("(?s)<!--.*?-->", "");
assertTrue(xmlText.contains("classified == true"),
"XML 必须有 classified==true 的已分类分支(SQL 侧下推,铁律 20 同形)");
assertTrue(xmlText.contains("cs.owner_group_id = #{ownerGroupId}")
&& xmlText.contains("cs.category_id IS NOT NULL"),
"已分类判据必须按当前分组归属行且 category_id 非空(与 fillGroupNames 同形)");
assertTrue(xmlText.contains("NOT EXISTS"), "未分类档必须是 NOT EXISTS(不是空结果降级)");
assertEquals(2, count(xmlText, "cs.product_id = p.id"),
"EXISTS/NOT EXISTS 两分支各一处商品关联,缺一个即红");
// ① 服务直传:classified 与 ownerGroupId 成对进 mapper(计数与分页同一过滤面)。
JdProductMapper mapper = mock(JdProductMapper.class);
JdProductQueryService service = queryService(mapper);
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, GROUP_ID);
verify(mapper).countProducts(null, null, null, null, null, null, true, GROUP_ID);
verify(mapper).selectProductPage(null, null, null, null, null, null, true, GROUP_ID, 0L, 20);
service.page(1L, 20L, null, null, null, null, null, null, Boolean.FALSE, GROUP_ID);
verify(mapper).countProducts(null, null, null, null, null, null, false, GROUP_ID);
verify(mapper).selectProductPage(null, null, null, null, null, null, false, GROUP_ID, 0L, 20);
// ③ 控制器直传:classified 原样进服务(owner_group_id 仍按作用域收敛后的值)。
JdProductQueryService queryService = mock(JdProductQueryService.class);
JdCategoryScopeService scopeService = mock(JdCategoryScopeService.class);
AdminAuthSupport authSupport = mock(AdminAuthSupport.class);
AdminJdProductController controller = new AdminJdProductController(
queryService, mock(JdProductDeleteService.class), mock(JdProductUpdateService.class),
mock(JdProductGroupService.class), scopeService, authSupport,
mock(PermissionMenuService.class));
AdminUserEntity operator = new AdminUserEntity();
operator.setId(7L);
HttpServletRequest request = mock(HttpServletRequest.class);
when(authSupport.requireUser(request)).thenReturn(operator);
when(authSupport.currentRole(operator)).thenReturn("super_admin");
JdCategoryScopeService.JdCategoryScope scope = writableScope(GROUP_ID, COMPANY_ID);
when(scopeService.resolve(operator)).thenReturn(scope);
when(scopeService.readGroupOrNull(scope, null)).thenReturn(GROUP_ID);
controller.page(1L, 20L, null, null, null, null, null, null, null, Boolean.TRUE, request);
verify(queryService).page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, GROUP_ID);
}
@Test
@@ -807,8 +865,8 @@ class AdminJdProductControllerTest {
JdProductEntity categorized = productEntity(1L);
JdProductEntity missing = productEntity(2L);
when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(2L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(),
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(),
anyLong(), anyInt())).thenReturn(List.of(categorized, missing));
when(assignMapper.selectList(any())).thenReturn(List.of(
assign(1L, GROUP_ID, 3L), assign(2L, GROUP_ID, 99L)));
@@ -817,7 +875,7 @@ class AdminJdProductControllerTest {
category.setName("秋冬款");
when(categoryMapper.selectBatchIds(any())).thenReturn(List.of(category));
JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, GROUP_ID);
JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null, GROUP_ID);
assertEquals(3L, vo.getItems().get(0).getGroupId(), "分类 id 取本组归属行");
assertEquals("秋冬款", vo.getItems().get(0).getGroupName(), "行集归属一次取齐分类名(无逐行查询)");
@@ -832,11 +890,11 @@ class AdminJdProductControllerTest {
JdProductGroupAssignMapper assignMapper = mock(JdProductGroupAssignMapper.class);
JdProductQueryService service = queryService(mapper, mock(JdProductImageMapper.class),
mock(JdProductSkuMapper.class), mock(JdProductGroupMapper.class), assignMapper);
when(mapper.countProducts(any(), any(), any(), any(), any(), any())).thenReturn(1L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(),
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(),
anyLong(), anyInt())).thenReturn(List.of(productEntity(1L)));
JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null);
JdProductPageVo vo = service.page(1L, 20L, null, null, null, null, null, null, null, null);
assertNull(vo.getItems().get(0).getGroupId(), "不属于任何分组的账号:分类列一律空(未分类)");
assertNull(vo.getItems().get(0).getGroupName());