7299166e96
范围: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 两支换壳契约(值形状 + 空值行 + 点开→点选项)。
140 lines
4.0 KiB
Vue
140 lines
4.0 KiB
Vue
<script setup lang="ts">
|
||
/** 旧版风格分页(像素复刻 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<{
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
sizes?: number[]
|
||
showTotal?: boolean
|
||
jump?: boolean
|
||
}>(),
|
||
{ sizes: () => [10, 20, 50, 100], showTotal: true, jump: true },
|
||
)
|
||
const emit = defineEmits<{
|
||
(e: 'change', page: number): void
|
||
(e: 'size-change', size: number): void
|
||
}>()
|
||
|
||
const jumpPage = ref('')
|
||
const totalPages = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))
|
||
|
||
function go(next: number) {
|
||
if (next < 1 || next > totalPages.value || next === props.page) return
|
||
emit('change', next)
|
||
}
|
||
|
||
function goJump() {
|
||
const n = Number.parseInt(jumpPage.value, 10)
|
||
if (Number.isNaN(n)) return
|
||
jumpPage.value = ''
|
||
go(Math.min(Math.max(n, 1), totalPages.value))
|
||
}
|
||
|
||
function onSizeChange(value: number) {
|
||
if (Number.isFinite(value) && value > 0) emit('size-change', value)
|
||
}
|
||
</script>
|
||
|
||
<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>
|
||
<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>
|
||
<span v-if="jump" class="page-jump">
|
||
跳至
|
||
<input v-model="jumpPage" type="text" inputmode="numeric" @keyup.enter="goJump" />
|
||
页
|
||
<button type="button" @click="goJump">跳转</button>
|
||
</span>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.old-pagination {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
align-items: center;
|
||
gap: 10px;
|
||
margin-top: 18px;
|
||
color: #5b6f83;
|
||
font-size: 13px;
|
||
}
|
||
.old-pagination button {
|
||
min-height: 30px;
|
||
padding: 4px 12px;
|
||
border: 1px solid #c7d7e5;
|
||
border-radius: 8px;
|
||
background: #ffffff;
|
||
color: #5b6f83;
|
||
font-family: inherit;
|
||
font-size: 13px;
|
||
cursor: pointer;
|
||
}
|
||
.old-pagination button:hover:not(:disabled) {
|
||
background: #edf5fb;
|
||
border-color: #95b1cb;
|
||
color: #2f5d8b;
|
||
}
|
||
.old-pagination button:disabled {
|
||
background: #eef3f7;
|
||
color: #9baaba;
|
||
cursor: not-allowed;
|
||
}
|
||
.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-radius: 8px;
|
||
background: #f8fbfd;
|
||
box-shadow: 0 0 0 1px #cbd9e6 inset;
|
||
font-size: 13px;
|
||
line-height: 22px;
|
||
}
|
||
.page-size-select :deep(.el-select__wrapper:hover) {
|
||
box-shadow: 0 0 0 1px #9fb7cd inset;
|
||
}
|
||
.page-jump {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
.page-jump input {
|
||
width: 56px;
|
||
min-height: 30px;
|
||
padding: 4px 8px;
|
||
border: 1px solid #cbd9e6;
|
||
border-radius: 8px;
|
||
background: #f8fbfd;
|
||
color: #24384d;
|
||
font-size: 13px;
|
||
font-family: inherit;
|
||
}
|
||
</style>
|