style(admin): 全站原生下拉统一换 el-select——弹层圆角与亚马逊面一致(2026-11-17 用户口径「样式咋不是圆角 和亚马逊不统一 其他地方也要看看」)
范围:src 里原生 <select> 由 36 处清零(含全站共享分页条),15 个页面 + 1 个组件。
换法统一:class="admin-filter"(main.css 皮肤 42px/9px/#f8fbfd/focus ring)+
aria-label 定位 + el-option 显式 label;「全部 XX」空值行与 value 形状逐字保留
('' / null / String(id) / '1'/'0' / `${source}|${deviceId}` 等,下游查询参数与后端枚举不动)。
- OldPagination:每页条数下拉换 el-select(局部 import,挂载测试单 mount 也能渲染),壳压回分页条 30px/8px 档
- account 三页(菜单类型/密钥状态/分组)+ GroupsPage/UsersPage 清死 select 规则
- asin 三页(国家/弹窗分组):弹窗分组用 placeholder+clearable+:value-on-clear 钉回 null,守 number|null 契约
- patent 页(国家/分组)
- records 两页(来源/用户/终端覆盖):终端覆盖 value 仍 source|deviceId
- tasks 四页 + 任务看板(业务/状态/类型/来源/店铺/分组/场景):BrandGating/DuplicateCheck/KeywordUsage 三页本地是 34px 紧凑档,
故把 el-select 壳压回本地 34px/7px 与同行输入框齐高(否则高 8px 错位)
测试:mount 全量 21 文件 164 passed;node --test 1924 例 1922 passed(2 红为在册:
date-range-order 环境红、company-config-entry-super-only 由 ee613db0 引入与本次无关);
vue-tsc rc=0。新增 account-select-el / records-select-el 两支换壳契约(值形状 + 空值行 + 点开→点选项)。
This commit is contained in:
@@ -2,6 +2,11 @@
|
||||
/** 旧版风格分页(像素复刻 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<{
|
||||
@@ -34,8 +39,7 @@ function goJump() {
|
||||
go(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
function onSizeChange(event: Event) {
|
||||
const value = Number((event.target as HTMLSelectElement).value)
|
||||
function onSizeChange(value: number) {
|
||||
if (Number.isFinite(value) && value > 0) emit('size-change', value)
|
||||
}
|
||||
</script>
|
||||
@@ -43,9 +47,16 @@ function onSizeChange(event: Event) {
|
||||
<template>
|
||||
<div class="old-pagination">
|
||||
<span v-if="showTotal" class="page-total">共 {{ total }} 条</span>
|
||||
<select class="page-size-select" :value="pageSize" @change="onSizeChange">
|
||||
<option v-for="size in sizes" :key="size" :value="size">{{ size }}条/页</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
<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>
|
||||
@@ -92,15 +103,22 @@ function onSizeChange(event: Event) {
|
||||
.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;
|
||||
color: #24384d;
|
||||
box-shadow: 0 0 0 1px #cbd9e6 inset;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
line-height: 22px;
|
||||
}
|
||||
.page-size-select :deep(.el-select__wrapper:hover) {
|
||||
box-shadow: 0 0 0 1px #9fb7cd inset;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -228,8 +228,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -243,12 +242,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -236,11 +236,15 @@ onMounted(loadMenus)
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 160px">
|
||||
<label>菜单类型</label>
|
||||
<select v-model="filterType">
|
||||
<option value="">全部</option>
|
||||
<option value="admin">后台</option>
|
||||
<option value="app">软件</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -398,8 +402,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -413,12 +416,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -151,10 +151,14 @@ onMounted(load)
|
||||
</div>
|
||||
<div class="form-group" v-if="isSuperAdmin && groupOptions.length" style="min-width: 170px">
|
||||
<label>分组</label>
|
||||
<select v-model="groupFilter">
|
||||
<option :value="null">全部分组</option>
|
||||
<option v-for="group in groupOptions" :key="group.id" :value="group.id">{{ group.groupName }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
@@ -290,8 +294,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -305,12 +308,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -324,16 +324,23 @@ onMounted(load)
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 170px">
|
||||
<label>状态(三项都通过才算通过)</label>
|
||||
<select v-model="statusFilter">
|
||||
<option v-for="option in STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group" v-if="isSuperAdmin && groupOptions.length" style="min-width: 170px">
|
||||
<label>分组</label>
|
||||
<select v-model="groupFilter">
|
||||
<option :value="null">全部分组</option>
|
||||
<option v-for="group in groupOptions" :key="group.id" :value="group.id">{{ group.groupName }}</option>
|
||||
</select>
|
||||
<!-- 同上(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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
@@ -553,8 +560,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -568,12 +574,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -390,8 +390,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -405,12 +404,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -290,8 +290,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -305,12 +304,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -70,6 +70,10 @@ 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)
|
||||
@@ -373,10 +377,14 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in ASIN_COUNTRY_CODES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="dedupe-filter-actions">
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
@@ -452,10 +460,23 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<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>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn" type="button" :disabled="editSaving" @click="saveEdit">保存</button>
|
||||
@@ -473,10 +494,20 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<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>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div v-if="importProgress" class="progress-wrap">
|
||||
<div class="progress-text">{{ importProgress }}</div>
|
||||
@@ -591,8 +622,9 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
|
||||
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -606,12 +638,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -387,10 +387,14 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>ASIN</label>
|
||||
@@ -582,8 +586,9 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
|
||||
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -597,12 +602,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -432,10 +432,14 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in COUNTRIES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>ASIN</label>
|
||||
@@ -646,8 +650,9 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
|
||||
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -661,12 +666,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -170,18 +170,22 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in ASIN_COUNTRY_CODES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
<!-- 下拉 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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<!-- 分组(主管)选中即查:选完立刻按该主管过滤刷新(回第一页),不必再点查询。 -->
|
||||
<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>
|
||||
<!-- 分组(主管)选中即查:选完立刻按该主管过滤刷新(回第一页),不必再点查询。
|
||||
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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>同步开始日期</label>
|
||||
@@ -306,8 +310,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -321,12 +324,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -221,6 +221,11 @@ 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()
|
||||
@@ -301,16 +306,20 @@ onMounted(() => {
|
||||
<div class="form-row logs-filter-row">
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>来源</label>
|
||||
<select v-model="sourceFilter">
|
||||
<option v-for="option in SOURCE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 180px">
|
||||
<label>指定用户</label>
|
||||
<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>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>日志日期(起)</label>
|
||||
@@ -425,15 +434,21 @@ onMounted(() => {
|
||||
<div class="config-block">
|
||||
<h4>终端覆盖</h4>
|
||||
<div class="override-add">
|
||||
<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>
|
||||
<!-- 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>
|
||||
<button class="btn btn-sm" type="button" @click="addOverride">添加/更新覆盖</button>
|
||||
</div>
|
||||
<table class="override-table">
|
||||
@@ -529,8 +544,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -543,8 +557,7 @@ h3 {
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
@@ -743,21 +756,15 @@ td {
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
/* 只管布局:外壳皮肤(42px/9 圆角/#f8fbfd/focus ring)由全局 .admin-filter 提供,
|
||||
这里不再重复描边(旧 `.override-add select` 那段原生下拉皮肤已随 el-select 删除)。 */
|
||||
.override-select {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.override-mode {
|
||||
flex: 0 0 140px;
|
||||
}
|
||||
.override-table td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
@@ -146,10 +146,12 @@ onMounted(() => {
|
||||
<div class="form-row">
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>指定用户</label>
|
||||
<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>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 176px">
|
||||
<label>开始时间</label>
|
||||
@@ -294,8 +296,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -309,12 +310,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -379,17 +379,19 @@ 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>
|
||||
<select v-model="filter.moduleType">
|
||||
<option v-for="option in MODULE_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 130px">
|
||||
<label>状态</label>
|
||||
<select v-model="filter.status">
|
||||
<option v-for="option in TASK_STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
<div class="form-group shop-filter">
|
||||
<label>店铺</label>
|
||||
@@ -447,9 +449,11 @@ onUnmounted(() => {
|
||||
<div class="form-row">
|
||||
<div class="form-group" style="min-width: 150px">
|
||||
<label>状态</label>
|
||||
<select v-model="variantFilter.status">
|
||||
<option v-for="option in VARIANT_STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
@@ -689,8 +693,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -703,8 +706,7 @@ h3 {
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -253,15 +253,16 @@ onMounted(() => {
|
||||
</label>
|
||||
<label class="g-field">
|
||||
<span>国家</span>
|
||||
<select v-model="form.country">
|
||||
<option v-for="country in GATING_COUNTRIES" :key="country" :value="country">{{ country }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</label>
|
||||
<label class="g-field">
|
||||
<span>类型</span>
|
||||
<select v-model="form.gatingType">
|
||||
<option v-for="type in typeOptions" :key="type" :value="type">{{ type }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</label>
|
||||
<label class="g-field">
|
||||
<span>ASIN</span>
|
||||
@@ -302,23 +303,25 @@ onMounted(() => {
|
||||
<div class="g-panel-body">
|
||||
<div class="g-filters">
|
||||
<input v-model="filter.keyword" placeholder="搜索品牌 / ASIN" @keyup.enter="query" />
|
||||
<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>
|
||||
<!-- 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>
|
||||
<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>
|
||||
@@ -522,10 +525,9 @@ onMounted(() => {
|
||||
.g-field-wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
/* 下拉已换 el-select(2026-11-17)⇒ 皮肤走全局 .admin-filter,这里只留原生输入框。 */
|
||||
.g-field input,
|
||||
.g-field select,
|
||||
.g-filters input,
|
||||
.g-filters select {
|
||||
.g-filters input {
|
||||
width: 100%;
|
||||
height: 34px;
|
||||
padding: 0 10px;
|
||||
@@ -538,13 +540,28 @@ onMounted(() => {
|
||||
outline: none;
|
||||
}
|
||||
.g-field input:focus,
|
||||
.g-field select:focus,
|
||||
.g-filters input:focus,
|
||||
.g-filters select:focus {
|
||||
.g-filters input: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;
|
||||
@@ -580,9 +597,6 @@ onMounted(() => {
|
||||
.g-filters input {
|
||||
width: 190px;
|
||||
}
|
||||
.g-filters select {
|
||||
width: 132px;
|
||||
}
|
||||
|
||||
.g-btn {
|
||||
height: 34px;
|
||||
|
||||
@@ -447,24 +447,26 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="f-group">
|
||||
<label>店铺</label>
|
||||
<select v-model="filter.shop">
|
||||
<option value="">全部店铺</option>
|
||||
<option v-for="shop in orderedShops" :key="shop.shopName" :value="shop.shopName">{{ shop.shopName }}</option>
|
||||
</select>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div v-if="isSuper" class="f-group">
|
||||
<label>分组</label>
|
||||
<select v-model="filter.group">
|
||||
<option value="">全部分组</option>
|
||||
<option v-for="group in groupStats" :key="group.name" :value="group.name">{{ group.name }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
<div class="f-group">
|
||||
<label>国家 / 站点</label>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in countryOptions" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</div>
|
||||
<div class="f-group">
|
||||
<label>上架时间开始</label>
|
||||
@@ -774,7 +776,8 @@ 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; }
|
||||
.dup-ref input, .dup-ref select { font-family: inherit; font-size: 13px; color: var(--text); }
|
||||
/* 原生 select 已换 el-select(2026-11-17)⇒ 选择器里不再列 select。 */
|
||||
.dup-ref input { 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; }
|
||||
@@ -801,14 +804,27 @@ 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); }
|
||||
.dup-ref .f-group input, .dup-ref .f-group select {
|
||||
/* 下拉已换 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;
|
||||
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: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: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[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,19 +185,21 @@ 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>
|
||||
<select v-model="filter.user">
|
||||
<option value="">全部使用者</option>
|
||||
<option v-for="user in userOptions" :key="user" :value="user">{{ user }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</label>
|
||||
<label class="kw-field">
|
||||
<span>国家</span>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="country in countryOptions" :key="country" :value="country">{{ country }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</label>
|
||||
<label class="kw-field kw-field-wide">
|
||||
<span>关键词</span>
|
||||
@@ -205,10 +207,10 @@ onMounted(() => {
|
||||
</label>
|
||||
<label class="kw-field">
|
||||
<span>场景</span>
|
||||
<select v-model="filter.scene">
|
||||
<option value="">全部场景</option>
|
||||
<option v-for="scene in KEYWORD_USAGE_SCENES" :key="scene" :value="scene">{{ scene }}</option>
|
||||
</select>
|
||||
<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>
|
||||
</label>
|
||||
<div class="kw-actions">
|
||||
<button class="kw-btn kw-btn-primary" type="button" @click="query">查询</button>
|
||||
@@ -405,8 +407,8 @@ onMounted(() => {
|
||||
font-size: 12px;
|
||||
color: #5a6474;
|
||||
}
|
||||
.kw-field input,
|
||||
.kw-field select {
|
||||
/* 下拉已换 el-select(2026-11-17)⇒ 皮肤走全局 .admin-filter,这里只留原生输入框。 */
|
||||
.kw-field input {
|
||||
height: 34px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #d7dce5;
|
||||
@@ -417,12 +419,26 @@ onMounted(() => {
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
}
|
||||
.kw-field input:focus,
|
||||
.kw-field select:focus {
|
||||
.kw-field input: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,10 +334,11 @@ onMounted(load)
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 130px">
|
||||
<label>国家</label>
|
||||
<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>
|
||||
<!-- 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>
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 176px">
|
||||
<label>创建开始</label>
|
||||
@@ -510,8 +511,7 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -525,12 +525,10 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* 账户域三页的原生 <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,8 +14,9 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { DOMWrapper, 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'
|
||||
@@ -74,12 +75,40 @@ beforeEach(() => {
|
||||
|
||||
async function mountWith(payload: unknown): Promise<VueWrapper<Element>> {
|
||||
cleanApi.fetchAppearancePatentCleanList.mockImplementation(() => Promise.resolve(payload))
|
||||
const wrapper = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia] } })
|
||||
const wrapper = mount(AppearancePatentCleanItemsPage, { global: { plugins: [pinia, ElSelect, ElOption] } })
|
||||
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')
|
||||
@@ -215,14 +244,13 @@ 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"]')
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]:not(.el-select__input)')
|
||||
expect(textInputs).toHaveLength(2, '任务号+ASIN 两个筛选框恢复(客户要一目了然)')
|
||||
await textInputs[0].setValue('33874')
|
||||
await textInputs[1].setValue('B0CLEAN')
|
||||
|
||||
const selects = wrapper.findAll('select')
|
||||
await selects[0].setValue('DE') // 国家排在前(模板顺序:任务号/ASIN/国家/分组)
|
||||
await selects[1].setValue('7') // 分组(主管=组长)
|
||||
await pickSelectOption(wrapper, '筛选国家', '德国') // 国家排在前(模板顺序:任务号/ASIN/国家/分组)
|
||||
await pickSelectOption(wrapper, '筛选分组', '甲组') // 分组(主管=组长)
|
||||
const dateInputs = wrapper.findAll('input[type="date"]')
|
||||
await dateInputs[0].setValue('2026-11-01')
|
||||
await dateInputs[1].setValue('2026-11-09')
|
||||
@@ -249,13 +277,12 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 10 })
|
||||
expect(cleanApi.fetchDedupeTotalGroups).toHaveBeenCalledWith(1)
|
||||
|
||||
const groupSelect = wrapper.findAll('select')[1] // 模板顺序:国家在前、分组在后
|
||||
const optionTexts = groupSelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts).toContain('全部分组')
|
||||
expect(optionTexts).toContain('甲组')
|
||||
const groups = optionLabels(wrapper, '筛选分组')
|
||||
expect(groups).toContain('全部分组')
|
||||
expect(groups).toContain('甲组')
|
||||
|
||||
const callsBeforeSelect = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
await groupSelect.setValue('7')
|
||||
await pickSelectOption(wrapper, '筛选分组', '甲组')
|
||||
await flushPromises()
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls.length).toBe(callsBeforeSelect + 1,
|
||||
'选中分组必须立刻重查')
|
||||
@@ -267,7 +294,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"]')
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]:not(.el-select__input)')
|
||||
await textInputs[0].setValue('33874')
|
||||
await textInputs[1].setValue('B0CLEAN')
|
||||
const callsBefore = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
@@ -288,8 +315,9 @@ describe('外观专利数据库页(明细表,2026-11-11 恢复「昨天那
|
||||
expect(cleanApi.fetchAppearancePatentCleanList).toHaveBeenCalledTimes(2)
|
||||
expect(cleanApi.fetchAppearancePatentCleanList.mock.calls[1][0].page).toBe(3)
|
||||
|
||||
const sizeSelect = wrapper.find('.page-size-select')
|
||||
await sizeSelect.setValue('50')
|
||||
// 每页条数下拉 2026-11-17 随分页条一起换 el-select(OldPagination 内局部注册)。
|
||||
expect(wrapper.find('.page-size-select').exists()).toBe(true, '分页条下拉保留 .page-size-select 定位类')
|
||||
await pickSelectOption(wrapper, '每页条数', '50条/页')
|
||||
await flushPromises()
|
||||
const last = cleanApi.fetchAppearancePatentCleanList.mock.calls.at(-1)![0]
|
||||
expect(last.pageSize).toBe(50)
|
||||
@@ -314,11 +342,10 @@ 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"]')
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]:not(.el-select__input)')
|
||||
await textInputs[0].setValue('33874')
|
||||
await textInputs[1].setValue('B0CLEAN')
|
||||
const groupSelect = wrapper.findAll('select')[1]
|
||||
await groupSelect.setValue('7')
|
||||
await pickSelectOption(wrapper, '筛选分组', '甲组')
|
||||
const callsBefore = cleanApi.fetchAppearancePatentCleanList.mock.calls.length
|
||||
|
||||
useCompanyTabStore().setActiveId(2)
|
||||
|
||||
@@ -600,8 +600,10 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(jdApi.fetchJdProductList).toHaveBeenCalledTimes(2)
|
||||
expect(jdApi.fetchJdProductList.mock.calls[1][0].page).toBe(3)
|
||||
|
||||
const sizeSelect = wrapper.find('.page-size-select')
|
||||
await sizeSelect.setValue('50')
|
||||
// 每页条数下拉 2026-11-17 随分页条一起换 el-select(OldPagination 内局部注册):
|
||||
// 点开→点选项,不再走原生 setValue。
|
||||
expect(wrapper.find('.page-size-select').exists()).toBe(true, '分页条下拉保留 .page-size-select 定位类')
|
||||
await pickSelectOption(wrapper, '每页条数', '50条/页')
|
||||
await flushPromises()
|
||||
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
|
||||
expect(last.pageSize).toBe(50)
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
/**
|
||||
* 日志管理页 / 生成记录页的原生 <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,6 +9,7 @@
|
||||
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'
|
||||
@@ -50,7 +51,9 @@ const loadingDirective = { mounted() {}, updated() {} }
|
||||
function mountPage(component: Parameters<typeof mount>[0], pinia: Pinia): VueWrapper {
|
||||
return mount(component, {
|
||||
global: {
|
||||
plugins: [pinia],
|
||||
// 筛选下拉 2026-11-17 换成 el-select(原生 select 弹层是直角原生物,与亚马逊页不统一),
|
||||
// 两支页面都要把 EP 组件注册进来,否则渲染成未解析标签。
|
||||
plugins: [pinia, ElSelect, ElOption],
|
||||
directives: { loading: loadingDirective },
|
||||
},
|
||||
})
|
||||
|
||||
@@ -17,12 +17,30 @@
|
||||
*/
|
||||
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(),
|
||||
@@ -106,7 +124,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] } })
|
||||
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia, ...EL_PLUGINS] } })
|
||||
await flushPromises()
|
||||
return wrapper
|
||||
}
|
||||
@@ -239,7 +257,7 @@ describe('密钥管理页:检测结果按 check_code 分档渲染', () => {
|
||||
|
||||
it('筛选项把 error 这一档的两个可能读法都点名(选了要能筛到无可用通道的行)', async () => {
|
||||
const wrapper = await mountWith(busyRow())
|
||||
const options = wrapper.findAll('.secrets-filter-row select')[0].findAll('option').map((option) => option.text().trim())
|
||||
const options = optionLabels(wrapper, '筛选密钥状态')
|
||||
expect(options).toContain('无法判定/可重试')
|
||||
expect(options).not.toContain('无法判定')
|
||||
})
|
||||
@@ -249,7 +267,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] } })
|
||||
const wrapper = mount(UserSecretsPage, { global: { plugins: [pinia, ...EL_PLUGINS] } })
|
||||
await flushPromises()
|
||||
const checkButton = wrapper.findAll('button').find((button) => button.text().trim() === '立即检测')
|
||||
expect(checkButton, '行内应有「立即检测」入口').toBeDefined()
|
||||
|
||||
@@ -19,7 +19,14 @@ 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 }))
|
||||
vi.mock('element-plus', () => ({ ElMessage: messageMock }))
|
||||
// 整包 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 },
|
||||
}))
|
||||
|
||||
const SHA = 'c'.repeat(64)
|
||||
const row = {
|
||||
|
||||
Reference in New Issue
Block a user