898e8a5ea9
- BatchDeleteActions margin-left:auto 右对齐、不再独占一行,14 页迁入各自筛选/工具行(Users/Groups/Menus/UserSecrets/QueryAsin/AsinInvalid/SkipPrice/DedupeRegistry/ProductCategory/DeviceLogs/DigitalHuman/ShopManage/ShopKeys/BrandGating);主按钮沿用全局 34px 同高,align-batch-toolbar-inline.test.ts 钉形状防回归
- 公司删除:DELETE /api/admin/companies/{id}(仅超管,名下有账号拒并带数量),只收公司行+columns 菜单树(PermissionMenuService.deleteTreeByCompany 与 copyTreeFromTemplate 对称),业务数据不级联;列表 VO 带 user_count 供前端置灰勾选/删除按钮;批量删除按用户管理同形走前端逐条循环
- CompaniesPage 加勾选列+行删除按钮(ops-cell 补 flex-wrap 过 ops-cell-must-wrap),删除后 refreshCompanyDirectory 同步 tab 条
- 测试:CompanyServiceDeleteTest 6+PermissionMenuServiceDeleteTreeTest 2+CompanyVoTest user_count 契约+CompanyControllerEndpointTest 翻转 exposesNoDeleteEndpoint→点名 DELETE 端点+CompanyReadPathMenuGateTest ensureSuperAdmin 3→4(delete 入册)+company-directory/row-buttons 补例;source-pin 基线重生成(265 文件/1859 例)
- 验证:admin-vue vue-tsc rc=0、node --test 1976 全绿、vitest mount 247 全绿;backend test-compile rc=0、Company*/PermissionMenu*/跨切守卫点名全绿(CatchSilenceRatchet 红因=另一路在飞件 JdPublishFillAiService 3 个 catch,归属京东窗不代抬)
577 lines
24 KiB
Vue
577 lines
24 KiB
Vue
<script setup lang="ts">
|
||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||
import { useRowSelection } from '@/utils/use-row-selection'
|
||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||
/** 查询 ASIN · 像素复刻旧版 admin.html panel-query-asin(自绘:面板头操作组、筛选+导出 XLSX、原生 rowspan 表格+可复制 ASIN、旧式分页)。
|
||
* script 逻辑沿用现有 Vue 实现(新增级联/配置抽屉/导入轮询/导出)。 */
|
||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import CopyText from '@/components/CopyText.vue'
|
||
import { formatDateTime } from '@/utils/datetime'
|
||
import { createQueryAsin, fetchQueryAsinList, fetchShopNamesByGroup } from './query-asin-api.ts'
|
||
import { QUERY_ASIN_COUNTRIES, queryAsinDisplayRows, type QueryAsinItem } from './query-asin-model.ts'
|
||
import { asinCountryLabel } from './asin-country.ts'
|
||
import { createQueryAsinFilterState, type QueryAsinFilterState } from './query-asin-filter.ts'
|
||
import { toQueryAsinExportUrl } from './query-asin-export.ts'
|
||
import { deleteQueryAsinCountryAsin, updateQueryAsinCountryAsin } from './query-asin-detail-api.ts'
|
||
import { fetchQueryAsinImportProgress, startQueryAsinImport } from './query-asin-import-api.ts'
|
||
import { fetchQueryAsinDeleteImportProgress, startQueryAsinDeleteImport } from './query-asin-delete-import-api.ts'
|
||
import { isAllowedExcelImportFile } from './import-progress-model.ts'
|
||
import { fetchShopManageGroups } from '../shop/shop-manage-api.ts'
|
||
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||
import OldPagination from '@/components/OldPagination.vue'
|
||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||
|
||
const session = useAdminSessionStore()
|
||
const companyTab = useCompanyTabStore()
|
||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||
|
||
const loading = ref(false)
|
||
const loadFailure = ref('')
|
||
const rows = ref<QueryAsinItem[]>([])
|
||
const total = ref(0)
|
||
const page = ref(1)
|
||
const pageSize = ref(10)
|
||
const groups = ref<ShopGroupOption[]>([])
|
||
/** 非超管仅有一个可访问分组时,弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
||
const lockedGroupId = computed<number | null>(() => {
|
||
if (isSuperAdmin.value) return null
|
||
return groups.value.length === 1 ? groups.value[0].id : null
|
||
})
|
||
const filter = reactive<QueryAsinFilterState>(createQueryAsinFilterState())
|
||
const jumpPage = ref('')
|
||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||
|
||
/** 纵向展示行:分组/店铺/操作 按 rowspan 合并,逐国一行(对齐 admin.js renderQueryAsinRows)。 */
|
||
const displayRows = computed(() => queryAsinDisplayRows(rows.value, (page.value - 1) * pageSize.value + 1))
|
||
|
||
function asinOf(row: QueryAsinItem, country: string): string {
|
||
const map: Record<string, string> = { DE: row.asinDe, UK: row.asinUk, FR: row.asinFr, IT: row.asinIt, ES: row.asinEs }
|
||
return map[country] || ''
|
||
}
|
||
|
||
// ---- 行内配置抽屉 ----
|
||
const drawerVisible = ref(false)
|
||
const drawerItem = ref<QueryAsinItem | null>(null)
|
||
const drawerSaving = ref(false)
|
||
const draftAsin = reactive<Record<string, string>>({ DE: '', UK: '', FR: '', IT: '', ES: '' })
|
||
|
||
function openConfig(row: QueryAsinItem): void {
|
||
drawerItem.value = row
|
||
for (const country of QUERY_ASIN_COUNTRIES) {
|
||
draftAsin[country] = asinOf(row, country)
|
||
}
|
||
drawerVisible.value = true
|
||
}
|
||
|
||
function normalizeAsinInput(country: string): void {
|
||
draftAsin[country] = draftAsin[country].trim().toUpperCase()
|
||
}
|
||
|
||
|
||
// 同一家店铺部分站点删除成功后,重试只发未完成的站点。
|
||
const pendingCountries = new WeakMap<QueryAsinItem, Set<(typeof QUERY_ASIN_COUNTRIES)[number]>>()
|
||
|
||
async function deleteShopCountries(item: QueryAsinItem, isCurrent: () => boolean = () => true) {
|
||
const pending = pendingCountries.get(item) ?? new Set(QUERY_ASIN_COUNTRIES.filter((country) => asinOf(item, country)))
|
||
pendingCountries.set(item, pending)
|
||
for (const country of pending) {
|
||
if (!isCurrent()) throw new Error('列表范围已切换,店铺剩余站点未删除')
|
||
await deleteQueryAsinCountryAsin(item.id, country)
|
||
pending.delete(country)
|
||
}
|
||
}
|
||
|
||
const batch = useRowSelection({
|
||
pageRows: () => rows.value,
|
||
rowId: (row) => row.id,
|
||
rowLabel: (row) => row.groupName ? `${row.shopName}(${row.groupName})` : row.shopName,
|
||
deleteOne: (_id, row, isCurrent) => deleteShopCountries(row, isCurrent),
|
||
refresh: load,
|
||
blocked: () => loading.value || !!loadFailure.value,
|
||
scope: () => companyTab.activeId,
|
||
consequence: '将删除所选店铺全部站点的 ASIN 配置,此操作不可恢复。',
|
||
})
|
||
|
||
async function removeShopAsin(item: QueryAsinItem) {
|
||
if (batch.busy) return
|
||
// 删除该店铺全部站点的 ASIN 配置(逐国调用现有端点)。
|
||
if (!(await openAdminConfirm({ message: `确定删除店铺“${item.shopName}”的全部站点 ASIN 配置吗?`, danger: true }))) return
|
||
try {
|
||
await deleteShopCountries(item)
|
||
batch.removeFromSelection(item.id)
|
||
ElMessage.success('已删除')
|
||
await load()
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||
}
|
||
}
|
||
|
||
async function saveConfig(): Promise<void> {
|
||
const item = drawerItem.value
|
||
if (!item) return
|
||
drawerSaving.value = true
|
||
const errors: string[] = []
|
||
try {
|
||
for (const country of QUERY_ASIN_COUNTRIES) {
|
||
const oldAsin = asinOf(item, country)
|
||
const next = (draftAsin[country] || '').trim().toUpperCase()
|
||
if (next === oldAsin) continue
|
||
try {
|
||
if (!next) {
|
||
if (oldAsin) await deleteQueryAsinCountryAsin(item.id, country)
|
||
} else {
|
||
await updateQueryAsinCountryAsin(item.id, country, next)
|
||
}
|
||
} catch (error) {
|
||
errors.push(`${asinCountryLabel(country)}:${error instanceof Error ? error.message : '保存失败'}`)
|
||
}
|
||
}
|
||
if (errors.length) {
|
||
showAdminFeedback(errors.join(';'), 'error')
|
||
} else {
|
||
ElMessage.success('保存成功')
|
||
drawerVisible.value = false
|
||
drawerItem.value = null
|
||
await load()
|
||
}
|
||
} finally {
|
||
drawerSaving.value = false
|
||
}
|
||
}
|
||
|
||
// ---- 新增 ASIN 弹窗(对齐 admin.js btnOpenCreateQueryAsin/btnCreateQueryAsin) ----
|
||
const createVisible = ref(false)
|
||
const createGroupId = ref<number | null>(null)
|
||
const createShopName = ref('')
|
||
const createCountry = ref('')
|
||
const createAsin = ref('')
|
||
const createMsg = ref('')
|
||
const createMsgOk = ref(false)
|
||
const shopNames = ref<string[]>([])
|
||
const shopNamesLoading = ref(false)
|
||
const creating = ref(false)
|
||
const createAsinInputRef = ref<InstanceType<typeof import('element-plus').ElInput> | null>(null)
|
||
|
||
function openCreate(): void {
|
||
createGroupId.value = lockedGroupId.value
|
||
createShopName.value = ''
|
||
createCountry.value = ''
|
||
createAsin.value = ''
|
||
createMsg.value = ''
|
||
createMsgOk.value = false
|
||
shopNames.value = []
|
||
createVisible.value = true
|
||
// 非超管分组已锁定:直接联动加载该分组店铺,省去一次无意义的选择。
|
||
if (createGroupId.value != null) void onCreateGroupChange()
|
||
}
|
||
|
||
async function onCreateGroupChange(): Promise<void> {
|
||
createShopName.value = ''
|
||
if (createGroupId.value == null) {
|
||
shopNames.value = []
|
||
return
|
||
}
|
||
shopNamesLoading.value = true
|
||
try {
|
||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
||
} catch (error) {
|
||
shopNames.value = []
|
||
showAdminFeedback(error instanceof Error ? error.message : '店铺列表加载失败', 'error')
|
||
} finally {
|
||
shopNamesLoading.value = false
|
||
}
|
||
}
|
||
|
||
function onCreateAsinInput(): void {
|
||
createAsin.value = createAsin.value.toUpperCase()
|
||
}
|
||
|
||
async function submitCreate(): Promise<void> {
|
||
createMsg.value = ''
|
||
createMsgOk.value = false
|
||
const groupId = createGroupId.value
|
||
const shopName = createShopName.value.trim()
|
||
const country = (createCountry.value || '').trim()
|
||
const asin = createAsin.value.trim().toUpperCase()
|
||
if (!groupId || !shopName || !country || !asin) {
|
||
createMsg.value = '请完整填写分组、店铺名、国家和 ASIN'
|
||
return
|
||
}
|
||
creating.value = true
|
||
try {
|
||
const message = await createQueryAsin({
|
||
groupId,
|
||
shopName,
|
||
countries: [country],
|
||
asin,
|
||
asinMappings: { [country]: asin },
|
||
})
|
||
// 对齐 admin:保留分组/店铺/国家,清空 ASIN 方便连续录入,成功后刷新列表。
|
||
createMsg.value = message
|
||
createMsgOk.value = true
|
||
createAsin.value = ''
|
||
createAsinInputRef.value?.focus()
|
||
await load()
|
||
} catch (error) {
|
||
createMsg.value = error instanceof Error ? error.message : '保存失败'
|
||
} finally {
|
||
creating.value = false
|
||
}
|
||
}
|
||
|
||
// ---- 导入添加 / 删除导入 ----
|
||
type ImportMode = 'add' | 'delete'
|
||
const importVisible = ref(false)
|
||
const importMode = ref<ImportMode>('add')
|
||
const importGroupId = ref<number | null>(null)
|
||
const importFile = ref<File | null>(null)
|
||
const importRunning = ref(false)
|
||
const importProgress = ref('')
|
||
|
||
function resetImport(): void {
|
||
importGroupId.value = lockedGroupId.value
|
||
importFile.value = null
|
||
importProgress.value = ''
|
||
importRunning.value = false
|
||
}
|
||
|
||
function openImportAdd(): void {
|
||
importMode.value = 'add'
|
||
resetImport()
|
||
importVisible.value = true
|
||
}
|
||
|
||
function openImportDelete(): void {
|
||
importMode.value = 'delete'
|
||
resetImport()
|
||
importVisible.value = true
|
||
}
|
||
|
||
function onPickImportFile(event: Event): void {
|
||
const input = event.target as HTMLInputElement
|
||
importFile.value = input.files?.[0] ?? null
|
||
}
|
||
|
||
function sleep(ms: number): Promise<void> {
|
||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||
}
|
||
|
||
async function submitImport(): Promise<void> {
|
||
const file = importFile.value
|
||
if (!file) {
|
||
ElMessage.warning('请选择 Excel 文件')
|
||
return
|
||
}
|
||
if (!isAllowedExcelImportFile(file.name)) {
|
||
ElMessage.warning('仅支持 .xlsx/.xls 文件')
|
||
return
|
||
}
|
||
if (importMode.value === 'delete') {
|
||
if (!(await openAdminConfirm({ message: '确定按 Excel 中的分组、店铺名和国家 ASIN 批量删除吗?', danger: true }))) return
|
||
}
|
||
const mode = importMode.value
|
||
const groupId = importGroupId.value ?? undefined
|
||
importRunning.value = true
|
||
importProgress.value = '正在上传并解析文件…'
|
||
try {
|
||
const started = mode === 'add' ? await startQueryAsinImport(file, groupId) : await startQueryAsinDeleteImport(file, groupId)
|
||
const poll = mode === 'add' ? () => fetchQueryAsinImportProgress(started) : () => fetchQueryAsinDeleteImportProgress(started)
|
||
for (let i = 0; i < 300; i += 1) {
|
||
const progress = await poll()
|
||
if (progress.status === 'success') {
|
||
importVisible.value = false
|
||
resetImport()
|
||
ElMessage.success(mode === 'add' ? '导入完成' : '删除导入完成')
|
||
await load()
|
||
return
|
||
}
|
||
if (progress.status === 'failed') {
|
||
importVisible.value = false
|
||
resetImport()
|
||
showAdminFeedback((progress as { errorMessage?: string }).errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'), 'error')
|
||
return
|
||
}
|
||
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
||
await sleep(1200)
|
||
}
|
||
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
||
} catch (error) {
|
||
showAdminFeedback(error instanceof Error ? error.message : '导入失败', 'error')
|
||
} finally {
|
||
importRunning.value = false
|
||
}
|
||
}
|
||
|
||
// ---- 导出 ----
|
||
function doExport(): void {
|
||
// 带当前筛选(分组/店铺名/ASIN/国家)导出,范围与列表筛选一致(此前不带参数导致导出恒为全量)。
|
||
const anchor = document.createElement('a')
|
||
anchor.href = toQueryAsinExportUrl(filter, companyTab.requestCompanyId)
|
||
document.body.appendChild(anchor)
|
||
anchor.click()
|
||
anchor.remove()
|
||
ElMessage.success('导出文件已开始下载')
|
||
}
|
||
|
||
async function loadGroups() {
|
||
try {
|
||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||
} catch {
|
||
groups.value = []
|
||
}
|
||
}
|
||
|
||
const batchListGate = createLatestRequestGate()
|
||
|
||
async function load() {
|
||
const token = batchListGate.begin()
|
||
loading.value = true
|
||
loadFailure.value = ''
|
||
try {
|
||
const result = await fetchQueryAsinList({
|
||
page: page.value,
|
||
pageSize: pageSize.value,
|
||
groupId: filter.groupId,
|
||
shopName: filter.shopName.trim() || undefined,
|
||
asin: filter.asin.trim() || undefined,
|
||
country: filter.country || undefined,
|
||
companyId: companyTab.requestCompanyId,
|
||
})
|
||
if (!batchListGate.isCurrent(token)) return
|
||
rows.value = result.items
|
||
total.value = result.total
|
||
page.value = result.page
|
||
} catch (error) {
|
||
if (!batchListGate.isCurrent(token)) return
|
||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
||
showAdminFeedback(loadFailure.value, 'error')
|
||
} finally {
|
||
if (batchListGate.isCurrent(token)) loading.value = false
|
||
}
|
||
}
|
||
|
||
function apply() {
|
||
page.value = 1
|
||
void load()
|
||
}
|
||
|
||
function changePage(next: number) {
|
||
if (next < 1 || next > totalPages.value) return
|
||
page.value = next
|
||
void 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))
|
||
}
|
||
|
||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||
// groupId 与 shopName 必须一起清:上一家选中的分组/店铺名在新一家的可见集与候选字典里根本不存在,
|
||
// 留着会把切 tab 后的首屏筛成空列表(请求、后端、权限三处都没错,最难查的那一型)。
|
||
watch(() => companyTab.activeId, () => { filter.groupId = null; filter.shopName = ''; void loadGroups(); void load() })
|
||
|
||
onMounted(() => {
|
||
void loadGroups()
|
||
void load()
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<div class="query-view">
|
||
<section class="panel-box">
|
||
<div class="query-head">
|
||
<h3>店铺列表</h3>
|
||
<div class="query-head-actions">
|
||
<button class="btn" type="button" @click="openCreate">新增 ASIN</button>
|
||
<button class="btn btn-secondary" type="button" @click="openImportAdd">导入添加</button>
|
||
<button class="btn" type="button" @click="openImportDelete">导入删除</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row query-filter-row">
|
||
<div v-if="isSuperAdmin" class="form-group">
|
||
<label>分组</label>
|
||
<el-select v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组">
|
||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||
</el-select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>店铺名</label>
|
||
<input v-model="filter.shopName" type="text" placeholder="请输入店铺名" @keyup.enter="apply" />
|
||
</div>
|
||
<div class="form-group">
|
||
<label>国家</label>
|
||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||
⇒ 换 el-select(与上面分组同一套 admin-filter 壳 42px/9px,弹层是 EP 圆角面板)。
|
||
「全部国家」保留为空值首行(value="" 与改前同语义,下发仍是空串=不限);
|
||
EP 把 '' 视作空值 ⇒ 闭壳走 placeholder,因此同步钉 placeholder="全部国家" 保持文案。 -->
|
||
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
|
||
<el-option label="全部国家" value="" />
|
||
<el-option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :label="asinCountryLabel(code)" :value="code" />
|
||
</el-select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>ASIN</label>
|
||
<input v-model="filter.asin" type="text" placeholder="请输入 ASIN" @keyup.enter="apply" />
|
||
</div>
|
||
<button class="btn" type="button" @click="apply">查询</button>
|
||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||
<BatchDeleteActions :batch="batch" />
|
||
</div>
|
||
|
||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||
<div class="table-scroll query-asin-table-scroll">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th class="batch-delete-cell" scope="col">
|
||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||
</th>
|
||
<th style="width: 6%">序号</th>
|
||
<th v-if="isSuperAdmin" style="width: 13%">分组</th>
|
||
<th style="width: 15%">店铺名</th>
|
||
<th style="width: 24%">ASIN</th>
|
||
<th style="width: 12%">国家</th>
|
||
<th style="width: 170px">创建时间</th>
|
||
<th style="width: 170px">更新时间</th>
|
||
<th style="width: 140px">操作</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<template v-if="displayRows.length">
|
||
<tr v-for="row in displayRows" :key="`${row.item.id}-${row.country}`" :class="{ 'batch-selected': batch.isSelected(row.item) }">
|
||
<template v-if="row.isFirst">
|
||
<td class="batch-delete-cell" :rowspan="row.rowspan">
|
||
<BatchDeleteCheckbox :label="batch.reason(row.item) || `选择 ${batch.label(row.item)}`" :checked="batch.isSelected(row.item)"
|
||
:disabled="batch.disabled || !!batch.reason(row.item)" @change="batch.toggle(row.item)" />
|
||
</td>
|
||
<td :rowspan="row.rowspan">{{ row.rowNo }}</td>
|
||
<td v-if="isSuperAdmin" :rowspan="row.rowspan">{{ row.item.groupName || '—' }}</td>
|
||
<td :rowspan="row.rowspan">{{ row.item.shopName }}</td>
|
||
</template>
|
||
<td>
|
||
<template v-if="row.asin">
|
||
<CopyText :text="row.asin" class="asin-cell" />
|
||
</template>
|
||
<span v-else class="asin-empty">-</span>
|
||
</td>
|
||
<td>{{ asinCountryLabel(row.country || '') }}</td>
|
||
<template v-if="row.isFirst">
|
||
<td :rowspan="row.rowspan">{{ formatDateTime(row.item.createdAt) }}</td>
|
||
<td :rowspan="row.rowspan">{{ formatDateTime(row.item.updatedAt) }}</td>
|
||
<td :rowspan="row.rowspan" class="asin-col-actions">
|
||
<button class="btn btn-sm" type="button" @click="openConfig(row.item as QueryAsinItem)">配置</button>
|
||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="removeShopAsin(row.item as QueryAsinItem)">删除</button>
|
||
</td>
|
||
</template>
|
||
</tr>
|
||
</template>
|
||
<tr v-else-if="loading">
|
||
<td :colspan="isSuperAdmin ? 9 : 8" class="empty-tip">加载中...</td>
|
||
</tr>
|
||
<tr v-else>
|
||
<td :colspan="isSuperAdmin ? 9 : 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="createVisible" title="新增查询 ASIN" width="560px" :close-on-click-modal="false">
|
||
<el-form label-position="top" @submit.prevent>
|
||
<el-form-item label="分组">
|
||
<el-select v-model="createGroupId" placeholder="请选择分组" filterable clearable style="width: 100%" :disabled="lockedGroupId != null" @change="onCreateGroupChange">
|
||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="店铺名">
|
||
<el-select
|
||
v-model="createShopName"
|
||
:disabled="createGroupId == null"
|
||
:loading="shopNamesLoading"
|
||
:placeholder="createGroupId == null ? '请先选择分组' : '请选择店铺'"
|
||
filterable
|
||
style="width: 100%"
|
||
>
|
||
<el-option v-for="name in shopNames" :key="name" :label="name" :value="name" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="国家">
|
||
<el-select filterable v-model="createCountry" placeholder="请选择国家" clearable style="width: 100%">
|
||
<el-option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :label="asinCountryLabel(code)" :value="code" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="ASIN">
|
||
<el-input ref="createAsinInputRef" v-model="createAsin" placeholder="请输入 ASIN" @input="onCreateAsinInput" />
|
||
</el-form-item>
|
||
<el-alert v-if="createMsg" :title="createMsg" :type="createMsgOk ? 'success' : 'error'" :closable="false" show-icon />
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="createVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="creating" @click="submitCreate">保存</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-drawer v-model="drawerVisible" :title="drawerItem ? `${drawerItem.shopName} · ASIN 配置` : 'ASIN 配置'" size="min(520px, 92%)">
|
||
<p class="drawer-tip">留空表示删除该站点已有的 ASIN 与记录。</p>
|
||
<el-form label-position="top">
|
||
<el-form-item v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :label="`${asinCountryLabel(code)} ASIN`">
|
||
<el-input
|
||
v-model="draftAsin[code]"
|
||
:placeholder="asinOf(drawerItem as QueryAsinItem, code) ? '留空删除该站点 ASIN' : '输入 ASIN'"
|
||
@input="normalizeAsinInput(code)"
|
||
/>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="drawerVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="drawerSaving" @click="saveConfig">保存</el-button>
|
||
</template>
|
||
</el-drawer>
|
||
|
||
<el-dialog v-model="importVisible" :title="importMode === 'add' ? '导入添加查询 ASIN' : '删除导入查询 ASIN'" width="520px">
|
||
<el-form label-position="top">
|
||
<el-form-item label="分组(Excel 未提供时的兜底,可选)">
|
||
<el-select filterable v-model="importGroupId" placeholder="可不选" clearable style="width: 100%" :disabled="lockedGroupId != null">
|
||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="Excel 文件">
|
||
<input type="file" accept=".xlsx,.xls" :disabled="importRunning" @change="onPickImportFile" />
|
||
<p class="import-tip">按 Excel 中的分组、店铺名与国家 ASIN 批量{{ importMode === 'add' ? '添加' : '删除' }},仅支持 .xlsx/.xls。</p>
|
||
</el-form-item>
|
||
<el-alert v-if="importProgress" :title="importProgress" type="info" :closable="false" show-icon />
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button :disabled="importRunning" @click="importVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="importRunning" @click="submitImport">
|
||
{{ importMode === 'add' ? '开始导入' : '开始删除导入' }}
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped src="./QueryAsinPage.css"></style>
|