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:
2026-11-17 13:49:39 +08:00
parent 80060912ca
commit 7299166e96
25 changed files with 859 additions and 266 deletions
@@ -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)