c5712f6b17
用户 10-07 报「用其他公司登录后品牌数据库没共享到、看不到数据」。页面文案写着 "本页全平台共享,不按公司区分",读侧却仍按操作者换一份可见集。真凶不是 company_id (V151 已把它退掉),而是 10-04 就记下的那条:非站点超管一律 `record_source='MANUAL' AND group_id=<可访问分组里 id 最小的那一个>`,账号没有分组时 更狠——`id = -1` 整页判空。`company_super_admin` 在控制器那句 `"super_admin".equals(currentRole)` 上判 false,于是整页落成 0 行。 上线前只读取证(内部令牌通道,公开链 api.aishufu.top): - operatorId=1205 张三(company_super_admin,公司3)→ total=0 - operatorId=1193 华华11(admin,公司2)→ total=0 - operatorId=1(站点超管)→ total=15234 - 库侧:biz_invalid_asin_data 共 15234 行,其中 AUTO 15174 行的 group_id 全为 NULL, MANUAL 只有 60 行 → "只给 MANUAL + 单个分组"这条谓词必然筛空。 改法(用户选「全放开:读+改+删都不锁分组」+「显示分组列」): - InvalidAsinDataService 的 page/create/update/delete 形参表里不再有 superAdmin, page 连 operatorId 都不收 ⇒ 想把「按人收窄」接回来必须先改签名,这是编译期护栏。 - 分组只在校验「存在」这一步过(getAccessibleById 的 superAdmin=true 是正当用法)。 AUTO 行仍不在这一页重归分组——那是来源语义,与角色无关。 - 新增 GET /api/admin/invalid-asin-data/groups:这一页自己的全平台分组名册,走与列表 同一道页面准入门,不开成匿名口。不能复用店铺页的 /shop-manages/groups——它对非超管 只返回本人可访问的分组,共享列表里别家的分组就筛不动。 - 前端:分组列/筛选/表单下拉对所有拿到这一页的人展示且可选,lockedGroupId 模型退役。 护栏: - InvalidAsinDataServiceTest 13 例 + InvalidAsinDataControllerTest 9 例。反向钉成对配尺子 自证(rulersCanMeasureThePreRevertPredicate 把退回前那半条谓词原样搭一遍,证明 「sql 里没有 record_source」「参数表里没有 -1」这几条断言真的量得到)。 - 前端删掉钉老锁形状的 align-invalid-asin-lock.test.ts,改由 align-invalid-asin-shared.test.ts 5 例反向钉(先让同一把尺子在 QueryAsinPage/ShopManagePage 量出 v-if="isSuperAdmin" 命中, 再断本页 0 命中;并钉分组列/筛选确实还在——「把列删了」也能满足 0 命中)。 - align-group-visibility.test.ts 是「分组列只对超管显示」的全站口径表,本页按用户批准移出 两张 gate 表并在表头写明例外。 口径来源:用户 10-07 定的「company_super_admin 在业务数据面与 super_admin 同套逻辑, 差别只在管理动作(公司管理、建别家公司超管)」。本轮只落品牌库这一页,其余 15 个仍按 公司隔离的注册表页没动;准入门(能不能进这一页)也不变。 门禁:后端全量 3957 例 / 0 红 / 7 跳;admin-frontend-vue 1737 例全绿;vue-tsc rc=0; 变异自证 6/6 KILLED(注入 record_source 谓词 / 恒筛 group_id / id=-1 空集兜底 / 写侧改回要求可访问分组 / AUTO 行也被重归分组 / 名册端点去掉准入门),每轮还原后哈希一致。
469 lines
13 KiB
Vue
469 lines
13 KiB
Vue
<script setup lang="ts">
|
|
import { formatDateTime } from '@/utils/datetime'
|
|
/** 品牌数据库(不符合ASIN)页 · 像素复刻旧版 admin.html panel-invalid-asin-data(自绘:面板头+新增、筛选、旧式表格/分页、原生 confirm 删除)。
|
|
* 全平台一份黑名单:分组是行上的归类标签,对任何角色都不构成可见性边界(2026-10-07 定档)。
|
|
* 弹窗保留现有组件。 */
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
import { ElMessage } from 'element-plus'
|
|
import { createInvalidAsin, deleteInvalidAsin, fetchInvalidAsinGroupOptions, fetchInvalidAsinPage, updateInvalidAsin } from '../invalidasin/invalid-asin-api.ts'
|
|
import type { InvalidAsinItem } from '../invalidasin/invalid-asin-model.ts'
|
|
import { invalidAsinDeleteText, recordSourceLabel } from '../invalidasin/invalid-asin-model.ts'
|
|
import { createEmptyInvalidAsinForm, invalidAsinFormFromItem, validateInvalidAsinForm } from '../invalidasin/invalid-asin-form-model.ts'
|
|
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
|
import OldPagination from '@/components/OldPagination.vue'
|
|
|
|
const loading = ref(false)
|
|
const rows = ref<InvalidAsinItem[]>([])
|
|
const total = ref(0)
|
|
const page = ref(1)
|
|
const pageSize = ref(10)
|
|
const groupOptions = ref<ShopGroupOption[]>([])
|
|
const jumpPage = ref('')
|
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
|
|
|
const filter = reactive({ dataValue: '', brand: '', groupId: null as number | null })
|
|
|
|
const dialogVisible = ref(false)
|
|
const editingId = ref<number | null>(null)
|
|
/** 当前编辑行来源:自动导入(AUTO)记录不在此页改分组。 */
|
|
const editingSource = ref('')
|
|
const saving = ref(false)
|
|
const form = reactive(createEmptyInvalidAsinForm())
|
|
|
|
async function loadGroups() {
|
|
try {
|
|
groupOptions.value = await fetchInvalidAsinGroupOptions()
|
|
} catch {
|
|
groupOptions.value = []
|
|
}
|
|
}
|
|
|
|
async function load() {
|
|
loading.value = true
|
|
try {
|
|
const result = await fetchInvalidAsinPage({
|
|
page: page.value,
|
|
pageSize: pageSize.value,
|
|
dataValue: filter.dataValue.trim() || undefined,
|
|
brand: filter.brand.trim() || undefined,
|
|
groupId: filter.groupId,
|
|
})
|
|
rows.value = result.items
|
|
total.value = result.total
|
|
page.value = result.page
|
|
} catch (error) {
|
|
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
function apply() {
|
|
page.value = 1
|
|
load()
|
|
}
|
|
|
|
function changePage(next: number) {
|
|
if (next < 1 || next > totalPages.value) return
|
|
page.value = next
|
|
load()
|
|
}
|
|
|
|
|
|
function changeSize(size: number) {
|
|
pageSize.value = size
|
|
page.value = 1
|
|
load()
|
|
}
|
|
|
|
function goJump() {
|
|
const n = Number.parseInt(jumpPage.value, 10)
|
|
if (Number.isNaN(n)) {
|
|
ElMessage.warning('请输入页码')
|
|
return
|
|
}
|
|
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
|
}
|
|
|
|
function openCreate() {
|
|
editingId.value = null
|
|
editingSource.value = ''
|
|
Object.assign(form, createEmptyInvalidAsinForm())
|
|
dialogVisible.value = true
|
|
}
|
|
|
|
function openEdit(row: InvalidAsinItem) {
|
|
editingId.value = row.id
|
|
editingSource.value = row.recordSource
|
|
Object.assign(form, invalidAsinFormFromItem(row))
|
|
dialogVisible.value = true
|
|
}
|
|
|
|
async function submit() {
|
|
const { valid, errors } = validateInvalidAsinForm({ ...form }, { requireGroup: editingId.value == null })
|
|
if (!valid) {
|
|
ElMessage.warning(Object.values(errors)[0] || '表单校验未通过')
|
|
return
|
|
}
|
|
saving.value = true
|
|
try {
|
|
if (editingId.value == null) {
|
|
await createInvalidAsin({ ...form })
|
|
ElMessage.success('已新增')
|
|
} else {
|
|
const includeGroup = editingSource.value.toUpperCase() !== 'AUTO'
|
|
await updateInvalidAsin(editingId.value, { ...form }, includeGroup)
|
|
ElMessage.success('已保存')
|
|
}
|
|
dialogVisible.value = false
|
|
load()
|
|
} catch (error) {
|
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
|
} finally {
|
|
saving.value = false
|
|
}
|
|
}
|
|
|
|
async function remove(row: InvalidAsinItem) {
|
|
// 对齐旧版:原生 confirm。
|
|
if (!window.confirm(invalidAsinDeleteText(row))) return
|
|
try {
|
|
await deleteInvalidAsin(row.id)
|
|
ElMessage.success('已删除')
|
|
load()
|
|
} catch (error) {
|
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
loadGroups()
|
|
load()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="invalid-view">
|
|
<section class="panel-box">
|
|
<div class="invalid-head">
|
|
<h3>品牌数据列表</h3>
|
|
<button class="btn" type="button" @click="openCreate">新增</button>
|
|
</div>
|
|
|
|
<div class="form-row invalid-filter-row">
|
|
<div class="form-group" style="min-width: 200px">
|
|
<label>ASIN</label>
|
|
<input v-model="filter.dataValue" type="text" placeholder="输入 ASIN" @keyup.enter="apply" />
|
|
</div>
|
|
<div class="form-group" style="min-width: 200px">
|
|
<label>品牌</label>
|
|
<input v-model="filter.brand" type="text" placeholder="输入品牌" @keyup.enter="apply" />
|
|
</div>
|
|
<div class="form-group" style="min-width: 180px">
|
|
<label>分组</label>
|
|
<el-select v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组">
|
|
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
|
|
</el-select>
|
|
</div>
|
|
<button class="btn" type="button" @click="apply">查询</button>
|
|
</div>
|
|
|
|
<div class="table-scroll invalid-asin-table-scroll">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 70px">ID</th>
|
|
<th style="width: 170px">ASIN</th>
|
|
<th style="width: 150px">品牌</th>
|
|
<th style="width: 140px">分组</th>
|
|
<th style="width: 110px">来源</th>
|
|
<th style="width: 170px">创建时间</th>
|
|
<th style="width: 170px">更新时间</th>
|
|
<th style="width: 150px">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<template v-if="rows.length">
|
|
<tr v-for="row in rows" :key="row.id">
|
|
<td>{{ row.id }}</td>
|
|
<td class="mono-cell">{{ row.dataValue }}</td>
|
|
<td>{{ row.brand || '—' }}</td>
|
|
<td>{{ row.groupName || '未分组' }}</td>
|
|
<td>
|
|
<span class="source-text" :class="{ 'is-auto': row.recordSource !== 'MANUAL' }">
|
|
{{ recordSourceLabel(row.recordSource) }}
|
|
</span>
|
|
</td>
|
|
<td>{{ formatDateTime(row.createdAt) }}</td>
|
|
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
|
<td class="ops-cell">
|
|
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
|
<button class="btn btn-sm btn-danger" type="button" @click="remove(row)">删除</button>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
<tr v-else-if="loading">
|
|
<td colspan="8" class="empty-tip">加载中...</td>
|
|
</tr>
|
|
<tr v-else>
|
|
<td colspan="8" class="empty-tip">暂无数据</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
|
</section>
|
|
|
|
<el-dialog v-model="dialogVisible" :title="editingId == null ? '新增不符合ASIN' : '编辑不符合ASIN'" width="520px">
|
|
<el-form label-width="110px">
|
|
<el-form-item label="ASIN" required>
|
|
<el-input v-model="form.dataValue" placeholder="不符合的 ASIN" />
|
|
</el-form-item>
|
|
<el-form-item label="品牌">
|
|
<el-input v-model="form.brand" placeholder="可选" />
|
|
</el-form-item>
|
|
<el-form-item v-if="editingId == null || editingSource.toUpperCase() !== 'AUTO'" label="分组" required>
|
|
<el-select v-model="form.groupId" placeholder="选择分组" filterable>
|
|
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button @click="dialogVisible = false">取消</el-button>
|
|
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
/* 像素复刻旧版 admin.html panel-invalid-asin-data(蓝白末层)。 */
|
|
.invalid-view {
|
|
font-family: inherit;
|
|
color: #24384d;
|
|
}
|
|
.panel-box {
|
|
width: 100%;
|
|
min-width: 0;
|
|
padding: 20px 22px 24px;
|
|
border: 1px solid #d8e3ee;
|
|
border-radius: 14px;
|
|
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
|
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
|
}
|
|
h3 {
|
|
margin: 0;
|
|
font-size: 15px;
|
|
font-weight: 650;
|
|
color: #24384d;
|
|
letter-spacing: 0.2px;
|
|
}
|
|
.invalid-head {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
margin-bottom: 16px;
|
|
}
|
|
.form-row {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: flex-end;
|
|
gap: 14px 18px;
|
|
margin-bottom: 16px;
|
|
}
|
|
.form-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 7px;
|
|
margin-bottom: 0;
|
|
}
|
|
.form-group label {
|
|
color: #5b6f83;
|
|
font-size: 12.5px;
|
|
font-weight: 600;
|
|
}
|
|
.form-group input,
|
|
.form-group select {
|
|
min-width: 0;
|
|
min-height: 42px;
|
|
padding: 8px 12px;
|
|
border: 1px solid #cbd9e6;
|
|
border-radius: 9px;
|
|
background: #f8fbfd;
|
|
color: #24384d;
|
|
font-size: 13.5px;
|
|
font-family: inherit;
|
|
color-scheme: light;
|
|
outline: none;
|
|
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
|
}
|
|
.form-group input:hover,
|
|
.form-group select:hover {
|
|
border-color: #9fb7cd;
|
|
}
|
|
.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);
|
|
}
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
min-height: 42px;
|
|
padding: 9px 18px;
|
|
border: 1px solid #4f78a5;
|
|
border-radius: 9px;
|
|
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
|
color: #ffffff;
|
|
font-family: inherit;
|
|
font-size: 13.5px;
|
|
cursor: pointer;
|
|
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
|
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
|
}
|
|
.btn:hover:not(:disabled) {
|
|
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
|
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
|
}
|
|
.btn:disabled {
|
|
cursor: not-allowed;
|
|
opacity: 0.55;
|
|
}
|
|
.btn-danger {
|
|
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
|
border-color: #b35f6a;
|
|
}
|
|
.btn-danger:hover:not(:disabled) {
|
|
background: linear-gradient(135deg, #cb7c84, #b96570);
|
|
}
|
|
.btn-sm {
|
|
min-height: 36px;
|
|
padding: 7px 12px;
|
|
}
|
|
.table-scroll {
|
|
width: 100%;
|
|
min-width: 0;
|
|
overflow-x: auto;
|
|
border: 1px solid #dbe5ee;
|
|
border-radius: 10px;
|
|
background: #ffffff;
|
|
}
|
|
.table-scroll table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
table-layout: fixed;
|
|
}
|
|
.invalid-asin-table-scroll > table {
|
|
min-width: 860px;
|
|
}
|
|
.table-scroll th,
|
|
.table-scroll td {
|
|
padding: 10px 12px;
|
|
text-align: left;
|
|
font-size: 13.5px;
|
|
line-height: 1.5;
|
|
border-bottom: 1px solid #e0e8ef;
|
|
vertical-align: middle;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.table-scroll th {
|
|
background: #edf4fa;
|
|
color: #4e6479;
|
|
border-bottom-color: #d5e1eb;
|
|
font-size: 12.5px;
|
|
font-weight: 600;
|
|
letter-spacing: 0.4px;
|
|
}
|
|
.table-scroll tbody tr:hover td {
|
|
background: #f1f7fb;
|
|
}
|
|
.table-scroll tbody tr:last-child td {
|
|
border-bottom: 0;
|
|
}
|
|
.mono-cell {
|
|
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
|
font-size: 12.5px;
|
|
}
|
|
.source-text {
|
|
padding: 2px 8px;
|
|
border-radius: 6px;
|
|
border: 1px solid #cbd9e6;
|
|
background: #fff;
|
|
color: #5b6f83;
|
|
font-size: 12px;
|
|
}
|
|
.source-text.is-auto {
|
|
background: #e7f0f8;
|
|
border-color: #c2d5e6;
|
|
color: #2f5d8b;
|
|
}
|
|
.ops-cell {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.empty-tip {
|
|
padding: 44px 24px;
|
|
text-align: center;
|
|
color: #8293a5;
|
|
font-size: 13.5px;
|
|
}
|
|
.pagination {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-top: 18px;
|
|
color: #5b6f83;
|
|
font-size: 13px;
|
|
}
|
|
.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;
|
|
}
|
|
.pagination button:hover:not(:disabled) {
|
|
background: #edf5fb;
|
|
border-color: #95b1cb;
|
|
color: #2f5d8b;
|
|
}
|
|
.pagination button:disabled {
|
|
background: #eef3f7;
|
|
color: #9baaba;
|
|
cursor: not-allowed;
|
|
}
|
|
.page-total {
|
|
margin-right: 4px;
|
|
}
|
|
.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>
|