feat(phase-5): 京东数据库页重写装配——侧栏+卡片网格+居中详情弹窗;级联面板/详情抽屉退役(AC-9 参数逐字等价)
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
/** 京东公共商品库:支持分类和京麦类目组合筛选。
|
||||
/** 京东公共商品库(v1.6 蓝图 Phase 5 重写装配:侧栏+卡片网格+居中详情弹窗)。
|
||||
* V203(2026-11-16 用户口径):分类按「数据权限分组」隔离——不同组看不到彼此的分类,
|
||||
* 能看多组的人用筛选行「分组」下拉切换当前组(只有一组时锁定显示)。
|
||||
* 2026-11-17 用户口径:店铺分类弹窗下线,本页工具栏改「批量编辑分类」——勾选商品
|
||||
* (翻页累计记忆)后选目标分类归入或移出;同日第二刀「京东分类管理并到京东数据库分类
|
||||
* 编辑里」:V204 独立子菜单页(JdCategoryManagerPage)下线,建/改名/删分类收进工具栏
|
||||
* 「分类管理」对话框(JdCategoryManageDialog,带名称搜索)。 */
|
||||
* 2026-11-17 用户口径:店铺分类弹窗下线,工具栏「归入分类」——勾选商品(翻页累计记忆)
|
||||
* 后选目标分类归入或取消归属;建/改名/删分类收进侧栏「分类管理」对话框(带名称搜索)。
|
||||
* v1.6 形态(2026-11-21 蓝图):类目筛选(京麦授权类目树+计数徽标+树外兜底)与店铺
|
||||
* 分类平铺收进左侧栏 JdCategorySidebar;列表改卡片网格 JdProductCard(商城款式);
|
||||
* 详情由侧滑抽屉改居中弹窗 JdProductDetailModal(Phase 4 壳,行级编辑/删除入口随
|
||||
* 操作列下线收进弹窗顶部动作区)。旧表格/级联面板/详情抽屉三件随本 Phase 退役。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import {
|
||||
batchAssignJdProductGroup,
|
||||
createJdProductGroup,
|
||||
deleteJdProducts,
|
||||
fetchJdCategoryScope,
|
||||
fetchJdProductCategories,
|
||||
@@ -17,12 +21,12 @@ import {
|
||||
type JdProductCategoryOption,
|
||||
type JdProductGroup,
|
||||
} from './jd-product-api.ts'
|
||||
import type { JdProductItem } from './jd-product-model.ts'
|
||||
import { jdPriceRange } from './jd-product-model.ts'
|
||||
import { createJdProductFilterState } from './jd-product-filter.ts'
|
||||
import JdProductDetailDrawer from './JdProductDetailDrawer.vue'
|
||||
import { createJdProductFilterState, JD_PRODUCT_PAGE_SIZE_OPTIONS } from './jd-product-filter.ts'
|
||||
import { JD_PRODUCT_DEFAULT_SIZE, type JdProductItem } from './jd-product-model.ts'
|
||||
import JdCategorySidebar from './JdCategorySidebar.vue'
|
||||
import JdProductCard from './JdProductCard.vue'
|
||||
import JdProductDetailModal from './JdProductDetailModal.vue'
|
||||
import JdProductEditDrawer from './JdProductEditDrawer.vue'
|
||||
import JdCategoryCascader from './JdCategoryCascader.vue'
|
||||
import JdBatchAssignDialog from './JdBatchAssignDialog.vue'
|
||||
import JdCategoryManageDialog from './JdCategoryManageDialog.vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
@@ -32,7 +36,7 @@ import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { isAdminRole, isCompanySuperAdminRole } from '@/types/admin'
|
||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||
import { orderedPair } from '@/utils/datetime'
|
||||
|
||||
/** 写权限口径(2026-11-17 用户口径「超管+管理员都可以,只有普通员工不能操作」):
|
||||
* 商品行写(编辑/删除/批量删除/传图)对管理员级(超级管理员/公司超级管理员/admin 档)渲染,
|
||||
@@ -50,9 +54,10 @@ const loadFailure = ref('')
|
||||
const rows = ref<JdProductItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
/** 每页条数默认 50(v1.6 Phase 1 新契约),档位 20/50/100 收敛在 filter 层单一出处。 */
|
||||
const pageSize = ref(JD_PRODUCT_DEFAULT_SIZE)
|
||||
const filter = reactive(createJdProductFilterState())
|
||||
/** 分类作用域(V203):可见分组 + 每组可写标记。失败静默回空作用域(分类列全空但商品照常)。 */
|
||||
/** 分类作用域(V203):可见分组 + 每组可写标记。失败静默回空作用域(分类面全空但商品照常)。 */
|
||||
const categoryScope = ref<JdCategoryGroupOption[]>([])
|
||||
const scopeDefaultGroupId = ref(0)
|
||||
/** 操作者是否平台超管(scope 原样透传):京东侧还没有任何分组时,分类管理弹窗
|
||||
@@ -61,49 +66,66 @@ const scopeDefaultGroupId = ref(0)
|
||||
const scopeSuperAdmin = ref(false)
|
||||
/** 当前分组(数据权限分组 id):分类列/分类筛选/分类管理的共同作用域。 */
|
||||
const ownerGroupId = ref(0)
|
||||
/** 当前分组的分类下拉选项(按 ownerGroupId 取,切组即换)。 */
|
||||
/** 当前分组的分类选项(按 ownerGroupId 取,切组即换;侧栏店铺分类 Tab 与归类对话框共用)。 */
|
||||
const groupOptions = ref<JdProductGroup[]>([])
|
||||
/** 类目下拉选项(京麦末级类目):与当前行集同源(公共库全量);失败静默回空。 */
|
||||
/** 类目计数行(京麦末级类目+商品数):侧栏商品目录树的徽标数据源;失败静默回空。 */
|
||||
const categoryOptions = ref<JdProductCategoryOption[]>([])
|
||||
const detailItem = ref<JdProductItem | null>(null)
|
||||
const detailVisible = ref(false)
|
||||
/** 批量编辑分类对话框(2026-11-17 替代下线的店铺分类弹窗)。 */
|
||||
/** 归类对话框(2026-17 替代下线的店铺分类弹窗,工具栏「归入分类」打开)。 */
|
||||
const batchEditVisible = ref(false)
|
||||
/** 分类管理对话框(2026-11-17 第二刀:独立子菜单页并进来,建/改名/删+搜索)。 */
|
||||
const manageVisible = ref(false)
|
||||
/** 行级编辑抽屉(2026-11-15 用户口径「每一条数据后面 需要编辑或者删除;编辑的话
|
||||
* 这里面都是可以编辑的」):删除走下面的 removeOne(同一条删除链),编辑走独立抽屉。 */
|
||||
/** 行级编辑抽屉(2026-11-15 用户口径「每一条数据后面 需要编辑或者删除」):入口随操作列
|
||||
* 下线收进详情弹窗顶部动作区(Phase 4 Modal emit edit),删除走 removeOne 同一条链。 */
|
||||
const editItem = ref<JdProductItem | null>(null)
|
||||
const editVisible = ref(false)
|
||||
|
||||
/** 当前分组的下拉项(带 editable)——分类写入口与「店铺分类」弹窗的可管理档都读它。 */
|
||||
/** 当前分组的下拉项(带 editable)——分类写入口与侧栏新建分类行的可写档都读它。 */
|
||||
const currentGroupOption = computed<JdCategoryGroupOption | null>(() =>
|
||||
categoryScope.value.find((group) => group.id === ownerGroupId.value) || null)
|
||||
const currentGroupName = computed(() => currentGroupOption.value?.name || '')
|
||||
/** 分类可管理(建/改名/删除/归类):本组管理员、公司超管、平台超管(后端 scope 判)。 */
|
||||
const canManageCategories = computed(() => currentGroupOption.value?.editable === true)
|
||||
/** 勾选列服务两类写:批量删除(管理员级)+批量编辑分类(本组可写分类的管理员也要勾)。
|
||||
* 2026-11-17 弹窗下线后管理员失去弹窗右栏的勾选面 ⇒ 勾选列必须对「本组可写」放开,
|
||||
* 否则本组管理员没有归类入口。 */
|
||||
const hasSelectionColumn = computed(() => canWriteProducts.value || canManageCategories.value)
|
||||
/** 空态行 colspan:勾选列有无决定 5/6/7 列三种形状(管理员级含操作列)。 */
|
||||
const emptyColspan = computed(() => (canWriteProducts.value ? 7 : hasSelectionColumn.value ? 6 : 5))
|
||||
/** 勾选面(卡片勾选框+工具栏全选/批量动作)服务两类写:批量删除(管理员级)+
|
||||
* 归类/取消归属(本组可写分类的管理员也要勾)。2026-11-17 弹窗下线后管理员失去
|
||||
* 弹窗右栏的勾选面 ⇒ 勾选面对「本组可写」放开,否则本组管理员没有归类入口。 */
|
||||
const hasSelection = computed(() => canWriteProducts.value || canManageCategories.value)
|
||||
/** 分组下拉只在能看多组时才渲染;只有一组(含无可见组)时按锁定态展示。 */
|
||||
const canSwitchGroup = computed(() => categoryScope.value.length > 1)
|
||||
|
||||
function openEdit(item: JdProductItem): void {
|
||||
editItem.value = item
|
||||
editVisible.value = true
|
||||
/** 侧栏选中回显:类目(name+完整名称路径;树外名 path 空数组)与分类 id。 */
|
||||
const selectedCategoryInfo = computed(() =>
|
||||
filter.category ? { name: filter.category, path: filter.categoryPath ?? [] } : null)
|
||||
const selectedGroupIdNum = computed(() => {
|
||||
const id = Number.parseInt(filter.groupId, 10)
|
||||
return Number.isFinite(id) && id > 0 ? id : null
|
||||
})
|
||||
|
||||
/** 侧栏选类目:树内节点带完整路径(序列化按子树展开 IN 下发)、树外兜底名 path 空=
|
||||
* 单名等值旧形状;null=「全部商品」清选重查。选中即查(回第一页)。 */
|
||||
function onSelectCategory(value: { name: string; path: string[] } | null): void {
|
||||
filter.category = value?.name || ''
|
||||
filter.categoryPath = value?.path ?? []
|
||||
apply()
|
||||
}
|
||||
|
||||
function closeEdit(): void {
|
||||
editVisible.value = false
|
||||
editItem.value = null
|
||||
/** 侧栏选分类:id 或 null(清选,与旧「全部分类」下拉行同语义)。选中即查。 */
|
||||
function onSelectGroup(id: number | null): void {
|
||||
filter.groupId = id ? String(id) : ''
|
||||
apply()
|
||||
}
|
||||
|
||||
/** 编辑保存成功:刷新列表(该行已置人工编辑锁,标题/价格等即时可见且不再被采集覆盖)。 */
|
||||
async function onEditSaved(): Promise<void> {
|
||||
await load()
|
||||
/** 侧栏新建分类(可写档):落当前分组,成功后刷新分类(侧栏徽标随 props 流回)。 */
|
||||
async function onCreateCategory(name: string): Promise<void> {
|
||||
try {
|
||||
await createJdProductGroup({ name, sortOrder: 0, ownerGroupId: ownerGroupId.value })
|
||||
showAdminFeedback(`已创建分类「${name}」`, 'success')
|
||||
await loadGroupOptions()
|
||||
} catch (error) {
|
||||
const text = error instanceof Error && error.message ? error.message : '创建分类失败,请稍后重试'
|
||||
showAdminFeedback(text, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||||
@@ -142,7 +164,7 @@ async function loadGroupOptions(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 类目选项同分组口径:失败静默回空下拉(可见「全部类目」),不拦首屏行集。 */
|
||||
/** 类目计数行同分组口径:失败静默回空(侧栏只剩「全部商品」行),不拦首屏行集。 */
|
||||
async function loadCategoryOptions(): Promise<void> {
|
||||
try {
|
||||
categoryOptions.value = await fetchJdProductCategories()
|
||||
@@ -153,7 +175,7 @@ async function loadCategoryOptions(): Promise<void> {
|
||||
|
||||
/** 切换「分组」下拉:分类筛选(属于上一组的分类)清空,分类选项换成本组,回第一页重取。
|
||||
* 勾选集是按商品 id 记的(跨页累计),切组不清——归类的落点组随 ownerGroupId 走,
|
||||
* 误跨组批量归类由批量对话框里的组名标注防住。 */
|
||||
* 误跨组批量归类由归类对话框里的组名标注防住。 */
|
||||
async function changeOwnerGroup(next: number): Promise<void> {
|
||||
if (next === ownerGroupId.value) return
|
||||
ownerGroupId.value = next
|
||||
@@ -163,33 +185,52 @@ async function changeOwnerGroup(next: number): Promise<void> {
|
||||
await load()
|
||||
}
|
||||
|
||||
/** 打开批量编辑分类:先刷一遍当前组分类(商品数徽标要新鲜),再亮对话框。 */
|
||||
/** 打开归类对话框:先刷一遍当前组分类(商品数徽标要新鲜),再亮对话框。 */
|
||||
async function openBatchEdit(): Promise<void> {
|
||||
await loadGroupOptions()
|
||||
batchEditVisible.value = true
|
||||
}
|
||||
|
||||
/** 工具栏「取消归属」=批量解挂(groupId null,后端只解挂本组归属行):
|
||||
* 与归类对话框的「移出分类」同一端点同语义;归类可重做(再归入即可)故不设二次确认。 */
|
||||
async function detachSelected(): Promise<void> {
|
||||
const ids = [...selectedIds.value]
|
||||
if (!ids.length || assigning.value) return
|
||||
assigning.value = true
|
||||
try {
|
||||
const updated = await batchAssignJdProductGroup(ids, null, ownerGroupId.value)
|
||||
showAdminFeedback(`已把 ${updated} 个商品移出分类`, 'success')
|
||||
selectedIds.value = new Set()
|
||||
await load()
|
||||
} catch (error) {
|
||||
const text = error instanceof Error && error.message ? error.message : '移出分类失败,请稍后重试'
|
||||
showAdminFeedback(text, 'error')
|
||||
} finally {
|
||||
assigning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开分类管理(对话框自取列表);入口对所有人渲染——同组普通号只读可看(V203),
|
||||
* 写控件由对话框按 editable 分档。 */
|
||||
function openManage(): void {
|
||||
manageVisible.value = true
|
||||
}
|
||||
|
||||
/** 分类管理里有写操作(建/改/删):刷一遍筛选下拉与商品数徽标。 */
|
||||
/** 分类管理里有写操作(建/改/删):刷一遍侧栏分类与商品数徽标。 */
|
||||
async function onManaged(): Promise<void> {
|
||||
await loadGroupOptions()
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类管理里新建了第一个数据权限分组(平台超管空态直建,2026-11-17 用户口径「admin
|
||||
* 权限最大」):整条作用域重取——新组会进可见集并把「当前分组」翻过去,分类下拉、
|
||||
* 权限最大」):整条作用域重取——新组会进可见集并把「当前分组」翻过去,侧栏分类、
|
||||
* 弹窗内分类列表随之按新组取,操作者接着就能建分类,不用关弹窗再开一遍。
|
||||
*/
|
||||
async function onGroupCreated(): Promise<void> {
|
||||
await loadCategoryScope()
|
||||
}
|
||||
|
||||
/** 批量归类完成(对话框已关):清勾选+重取列表(行集 groupName 变了)。
|
||||
/** 归类完成(对话框已关):清勾选+重取列表(行集分组变了)。
|
||||
* 移出分类 targetName 为 null;updated 是后端实际写入/解挂的归属行数。 */
|
||||
async function onBatchAssigned(updated: number, targetName: string | null): Promise<void> {
|
||||
showAdminFeedback(
|
||||
@@ -221,7 +262,7 @@ async function load(): Promise<void> {
|
||||
total.value = result.total
|
||||
if (result.page >= 1) page.value = result.page
|
||||
// 勾选跨页记忆(2026-11-17 用户口径「支持勾选翻页也要记住」):翻页/重取/改筛选都
|
||||
// 不清勾选集——批量编辑分类与批量删除都按累计 id 提交,操作前的确认弹窗点名数量;
|
||||
// 不清勾选集——归类与批量删除都按累计 id 提交,操作前的确认弹窗点名数量;
|
||||
// 「清除勾选」按钮同日用户口径删除,勾选只在批量操作成功后自动清。
|
||||
} catch (error) {
|
||||
loadFailure.value = loadFailureMessage(error, '京东商品列表加载失败')
|
||||
@@ -236,16 +277,7 @@ function apply(): void {
|
||||
void load()
|
||||
}
|
||||
|
||||
/** 类目级联面板选中即查:选完立刻按该类目过滤刷新(回第一页),同分组下拉口径;
|
||||
* 点「全部类目」/触发框 × = 清选重查。2026-11-18 一级/二级类目可选中:path 非空时
|
||||
* 序列化按子树展开类目名集合下发(后端 IN),末级/树外行 path 空=单名等值旧形状。 */
|
||||
function onCategoryPicked(name: string, path: string[]): void {
|
||||
filter.category = name
|
||||
filter.categoryPath = path
|
||||
apply()
|
||||
}
|
||||
|
||||
/** 重置:筛选面回出厂空态,回第一页重取。 */
|
||||
/** 重置:筛选面回出厂空态(类目/分类选中随 filter 回空=侧栏高亮自动清),回第一页重取。 */
|
||||
function reset(): void {
|
||||
Object.assign(filter, createJdProductFilterState())
|
||||
page.value = 1
|
||||
@@ -274,24 +306,55 @@ function closeDetail(): void {
|
||||
detailItem.value = null
|
||||
}
|
||||
|
||||
/** 商品编码一键复制(京麦同款 ⧉):@click.stop 防冒泡开抽屉;剪贴板不可用(非安全上下文)时弹失败文案。 */
|
||||
async function copyText(text: string): Promise<void> {
|
||||
if (!text) return
|
||||
/** 商品编码一键复制(卡片 ⧉,@click.stop 防冒泡开详情):剪贴板不可用(非安全上下文)时弹失败文案。 */
|
||||
async function copyProductCode(row: JdProductItem): Promise<void> {
|
||||
const code = row.productCode
|
||||
if (!code) return
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
showAdminFeedback(`已复制 ${text}`, 'success')
|
||||
await navigator.clipboard.writeText(code)
|
||||
showAdminFeedback(`已复制 ${code}`, 'success')
|
||||
} catch {
|
||||
showAdminFeedback('复制失败,请手动选择复制', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** 详情弹窗顶部「编辑/删除」(Phase 4 emit):先关弹窗再走既有链,与旧操作列同源。 */
|
||||
function onDetailEdit(): void {
|
||||
const item = detailItem.value
|
||||
closeDetail()
|
||||
if (item) openEdit(item)
|
||||
}
|
||||
|
||||
function onDetailRemove(): void {
|
||||
const item = detailItem.value
|
||||
closeDetail()
|
||||
if (item) void removeOne(item)
|
||||
}
|
||||
|
||||
function openEdit(item: JdProductItem): void {
|
||||
editItem.value = item
|
||||
editVisible.value = true
|
||||
}
|
||||
|
||||
function closeEdit(): void {
|
||||
editVisible.value = false
|
||||
editItem.value = null
|
||||
}
|
||||
|
||||
/** 编辑保存成功:刷新列表(该行已置人工编辑锁,标题/价格等即时可见且不再被采集覆盖)。 */
|
||||
async function onEditSaved(): Promise<void> {
|
||||
await load()
|
||||
}
|
||||
|
||||
// ---------------- 删除(先删桶、全成功才删库行,语义在后端 JdProductDeleteService) ----------------
|
||||
|
||||
/** 勾选集(按商品 id,跨页累计记忆,2026-11-17 用户口径)。翻页/重取不清;显式出口
|
||||
* 曾是工具栏「清除勾选」,同日用户口径「清除勾选这个按钮删除」后只剩批量删除/
|
||||
* 批量归类成功后自动清。 */
|
||||
* 曾是工具栏「清除勾选」,同日用户口径「清除勾选这个按钮删除」后只剩批量动作
|
||||
* 成功后自动清。 */
|
||||
const selectedIds = ref<Set<number>>(new Set())
|
||||
const deleting = ref(false)
|
||||
/** 归类/取消归属进行中(对话框提交与工具栏「取消归属」共用一颗互斥灯)。 */
|
||||
const assigning = ref(false)
|
||||
|
||||
const selectedCount = computed(() => selectedIds.value.size)
|
||||
|
||||
@@ -302,23 +365,25 @@ function toggleSelect(row: JdProductItem, checked: boolean): void {
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
const allSelected = computed(() => rows.value.length > 0 && rows.value.every((row) => selectedIds.value.has(row.id)))
|
||||
|
||||
function toggleSelectAll(checked: boolean): void {
|
||||
/** 工具栏「全选本页/取消本页」:按当前页行集增删勾选(跨页累计集里其他页的行不动)。 */
|
||||
function selectPage(): void {
|
||||
const next = new Set(selectedIds.value)
|
||||
for (const row of rows.value) {
|
||||
if (checked) next.add(row.id)
|
||||
else next.delete(row.id)
|
||||
}
|
||||
for (const row of rows.value) next.add(row.id)
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
/** 单行删除入口(行内按钮):确认弹窗点名商品编码与「桶内图片一并删除」。 */
|
||||
function unselectPage(): void {
|
||||
const next = new Set(selectedIds.value)
|
||||
for (const row of rows.value) next.delete(row.id)
|
||||
selectedIds.value = next
|
||||
}
|
||||
|
||||
/** 单行删除入口(详情弹窗顶部动作):确认弹窗点名商品编码与「桶内图片一并删除」。 */
|
||||
async function removeOne(row: JdProductItem): Promise<void> {
|
||||
await removeMany([row.id], `确定删除商品「${row.productCode || row.title}」吗?`)
|
||||
}
|
||||
|
||||
/** 批量删除入口(筛选行右侧按钮):按累计勾选 id 直删(跨页的行也在内),确认弹窗点名总数。 */
|
||||
/** 批量删除入口(工具栏按钮):按累计勾选 id 直删(跨页的行也在内),确认弹窗点名总数。 */
|
||||
async function removeSelected(): Promise<void> {
|
||||
await removeMany([...selectedIds.value], `确定批量删除选中的 ${selectedIds.value.size} 个商品吗?`)
|
||||
}
|
||||
@@ -345,7 +410,7 @@ async function removeMany(ids: number[], message: string): Promise<void> {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 先解析作用域再取列表:首屏的 owner_group_id 必须与分类下拉同一个组(铁律 30 同形——
|
||||
// 先解析作用域再取列表:首屏的 owner_group_id 必须与分类侧栏同一个组(铁律 30 同形——
|
||||
// 不要先发一条不带 owner_group_id 的列表请求再补,两次请求会落在不同默认组上)。
|
||||
await loadCategoryScope()
|
||||
void loadCategoryOptions()
|
||||
@@ -355,7 +420,21 @@ onMounted(async () => {
|
||||
|
||||
<template>
|
||||
<div class="jd-database-view">
|
||||
<section class="panel-box">
|
||||
<!-- 左侧栏(v1.6):商品目录(京麦授权类目树+计数徽标+树外兜底)/店铺分类
|
||||
(当前分组分类平铺+新建+分类管理入口)。取数在页面,侧栏纯展示。 -->
|
||||
<JdCategorySidebar
|
||||
:category-options="categoryOptions"
|
||||
:categories="groupOptions"
|
||||
:editable="canManageCategories"
|
||||
:selected-category="selectedCategoryInfo"
|
||||
:selected-group-id="selectedGroupIdNum"
|
||||
@select-category="onSelectCategory"
|
||||
@select-group="onSelectGroup"
|
||||
@create-category="onCreateCategory"
|
||||
@manage-categories="openManage"
|
||||
/>
|
||||
|
||||
<section class="panel-box jd-main-panel">
|
||||
<div class="jd-panel-head">
|
||||
<h3>京东数据库</h3>
|
||||
</div>
|
||||
@@ -369,28 +448,12 @@ onMounted(async () => {
|
||||
<label>标题关键字</label>
|
||||
<input v-model="filter.titleKeyword" type="text" placeholder="输入标题关键字" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>类目</label>
|
||||
<!-- 类目(京麦授权类目树)京麦同款级联面板(2026-11-16 真树取证):点行下钻、
|
||||
末级点行选中;2026-11-18 客户口径「一级/二级也要能选来搜索」——任意层级点
|
||||
圆点选中,序列化按子树展开类目名集合下发(后端 IN),选中即查(回第一页)。 -->
|
||||
<JdCategoryCascader
|
||||
:options="categoryOptions"
|
||||
:model-value="filter.category"
|
||||
:selected-path="filter.categoryPath"
|
||||
tree-only
|
||||
@change="onCategoryPicked"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="canFilterGroup && categoryScope.length" class="form-group">
|
||||
<label>分组</label>
|
||||
<!-- 当前分组(V203):超管档(平台/公司超管)专属——2026-11-17 用户口径
|
||||
「超管可以有分组筛选,管理员及以下则没有」,本控件对管理员及以下整块不渲染
|
||||
(其分类面固定落在作用域默认分组)。能看多组的人下拉切换;只有一组时锁定显示组名。
|
||||
2026-11-16 用户口径「做成分组」:从工具栏裸下拉上移进筛选行,做成带标签的表单控件
|
||||
(与其他筛选同壳同圆角)。2026-11-17 用户口径「和亚马逊不统一」:原生 <select> 的
|
||||
弹层是浏览器直角原生物,换 el-select(同亚马逊面 admin-filter 同壳),组多时可搜索。
|
||||
分组是分类列/分类筛选/分类管理的作用域,不是筛选条件 ⇒ 放在筛选行也只是占位,
|
||||
分组是侧栏分类/分类筛选/分类管理的作用域,不是筛选条件 ⇒ 放在筛选行也只是占位,
|
||||
「重置」不清它(挂载测试钉住)。 -->
|
||||
<el-select
|
||||
v-if="canSwitchGroup"
|
||||
@@ -416,42 +479,12 @@ onMounted(async () => {
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
||||
</div>
|
||||
<!-- 批量动作条(2026-11-17 用户口径「共X条京东商品删掉,工具栏整体上移」):
|
||||
原「汇总+工具栏」整行上移并入筛选行,与查询/重置同排;汇总数字删除。
|
||||
放不下的项随 .jd-filter-row 的 flex-wrap 自然折行。 -->
|
||||
<!-- 批量编辑分类(2026-11-17 用户口径「店铺分类弹窗删了,加个批量编辑分类」):
|
||||
只对当前分组可写档(本组管理员/公司超管/平台超管)渲染;勾选 0 时置灰(与
|
||||
批量删除同款常显口径),打开后按累计勾选(跨页)提交归入/移出。 -->
|
||||
<button
|
||||
v-if="canManageCategories"
|
||||
class="btn btn-secondary"
|
||||
type="button"
|
||||
:disabled="!selectedCount"
|
||||
@click="openBatchEdit"
|
||||
>批量编辑分类</button>
|
||||
<!-- 商品行写对管理员级(超管+管理员)开放,普通账号看到只读提示;分类写由当前分组
|
||||
editable 决定(本组管理员/公司超管/平台超管),分类维护入口=「分类管理」
|
||||
(只读可看,写控件按 editable 分档)。 -->
|
||||
<span v-if="!canWriteProducts" class="jd-readonly-tip">只读:编辑/删除需超级管理员或管理员;分类在本页「分类管理」查看与维护</span>
|
||||
<!-- 分类筛选(2026-11-17 与分组同刀换 el-select,弹层圆角与亚马逊统一):保留显式
|
||||
「全部分类」行(value='',与旧原生下拉同语义——列表里永远有回全量的出口),
|
||||
选中它/重置回 '' 时闭壳显示同文案占位。 -->
|
||||
<el-select
|
||||
v-model="filter.groupId"
|
||||
class="admin-filter"
|
||||
placeholder="全部分类"
|
||||
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>
|
||||
<!-- 分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」+同日收敛
|
||||
<!-- 归属三档快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」+同日收敛
|
||||
「默认卡在未分类上就行」;2026-11-18 用户口径「加个全部选项」恢复全量档):
|
||||
已分类=当前分组下有分类(V203 归属表,与列表分类列同形——筛"未分类"的行
|
||||
分类列必显示未分类);三档下拉、出厂默认仍卡「未分类」(11-17 口径不动),
|
||||
「全部」(value='')选中即查当前分组全部商品(序列化不下发 classified 参数,
|
||||
后端 required=false 跳过谓词);选中即查(回第一页);「重置」仍回未分类档。 -->
|
||||
已分类=当前分组下有分类(V203 归属表,与侧栏分类选中同形);三档下拉、
|
||||
出厂默认仍卡「未分类」(11-17 口径不动),「全部」(value='')选中即查当前
|
||||
分组全部商品(序列化不下发 classified 参数,后端 required=false 跳过谓词);
|
||||
选中即查(回第一页);「重置」仍回未分类档。 -->
|
||||
<el-select
|
||||
v-model="filter.classified"
|
||||
class="admin-filter"
|
||||
@@ -463,17 +496,30 @@ onMounted(async () => {
|
||||
<el-option label="已分类" value="classified" />
|
||||
<el-option label="未分类" value="ungrouped" />
|
||||
</el-select>
|
||||
<!-- 分类管理(2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里」):V204 独立
|
||||
子菜单页整体并入本对话框(搜索+新建+改名+删除)。入口对所有人渲染(同组普通号
|
||||
只读可看,V203),写控件由对话框按当前分组 editable 分档。 -->
|
||||
<button
|
||||
class="btn btn-secondary jd-manage-btn"
|
||||
type="button"
|
||||
@click="openManage"
|
||||
>分类管理</button>
|
||||
<!-- 批量删除 2026-11-16 客户口径「不要勾选后才显示」:常显,勾选 0 时置灰。
|
||||
写权限 2026-11-17 口径放宽到管理员级:普通账号整颗按钮不渲染(勾选列 2026-11-17
|
||||
起对本组可写分类管理员开放,服务批量归类)。文案 2026-11-17 用户口径「删除勾选改成批量删除」。 -->
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
|
||||
<!-- 工具栏(v1.6 重排):全选本页/取消本页|归入分类/取消归属(分类写档)|
|
||||
删除商品(管理员级)。行级编辑/删除入口随操作列下线收进详情弹窗顶部动作区;
|
||||
勾选 0 时批量动作置灰(与旧批量删除同款常显口径)。 -->
|
||||
<div v-if="hasSelection" class="jd-toolbar">
|
||||
<button class="btn btn-secondary" type="button" :disabled="!rows.length" @click="selectPage">全选本页</button>
|
||||
<button class="btn btn-secondary" type="button" :disabled="!selectedCount" @click="unselectPage">取消本页</button>
|
||||
<template v-if="canManageCategories">
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
type="button"
|
||||
:disabled="!selectedCount"
|
||||
@click="openBatchEdit"
|
||||
>归入分类</button>
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
type="button"
|
||||
:disabled="assigning || !selectedCount"
|
||||
@click="detachSelected"
|
||||
>取消归属</button>
|
||||
</template>
|
||||
<button
|
||||
v-if="canWriteProducts"
|
||||
class="btn btn-danger jd-delete-btn"
|
||||
@@ -481,77 +527,41 @@ onMounted(async () => {
|
||||
:disabled="deleting || !selectedCount"
|
||||
@click="removeSelected"
|
||||
>
|
||||
{{ deleting ? '删除中...' : `批量删除(${selectedCount})` }}
|
||||
{{ deleting ? '删除中...' : `删除商品(${selectedCount})` }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- 商品行写对管理员级(超管+管理员)开放,普通账号看到只读提示;分类写由当前分组
|
||||
editable 决定(本组管理员/公司超管/平台超管),分类维护入口=侧栏「分类管理」
|
||||
(只读可看,写控件按 editable 分档)。 -->
|
||||
<span v-if="!canWriteProducts" class="jd-readonly-tip">只读:编辑/删除需超级管理员或管理员;分类在左侧「分类管理」查看与维护</span>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll jd-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-if="hasSelectionColumn" style="width: 42px"><input type="checkbox" :checked="allSelected" @change="toggleSelectAll(($event.target as HTMLInputElement).checked)" /></th>
|
||||
<th style="width: 92px">分类</th>
|
||||
<th style="width: 520px">商品信息</th>
|
||||
<th style="width: 76px">总库存</th>
|
||||
<th style="width: 120px">价格</th>
|
||||
<!-- 同步时间收尾(创建/修改两列 2026-11-16 客户口径「不要」下线,仍收详情抽屉);
|
||||
操作列 2026-11-16「操作放最后一列」口径置末;写权限 2026-11-17 放宽到
|
||||
管理员级 ⇒ 普通账号不渲染该列。 -->
|
||||
<th style="width: 170px">同步时间</th>
|
||||
<th v-if="canWriteProducts" style="width: 138px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="row in rows" :key="row.id" class="jd-row" @click="openDetail(row)">
|
||||
<td v-if="hasSelectionColumn" @click.stop><input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row, ($event.target as HTMLInputElement).checked)" /></td>
|
||||
<td :title="row.groupName || ''">{{ row.groupName || '未分类' }}</td>
|
||||
<td class="jd-info-cell">
|
||||
<div class="jd-info-wrap">
|
||||
<div class="jd-info-figure">
|
||||
<img v-if="row.mainImageUrl" class="jd-thumb" :src="row.mainImageUrl" alt="" loading="lazy" />
|
||||
<span v-else class="jd-thumb jd-thumb-empty">无图</span>
|
||||
<span v-if="row.healthScore !== null" class="jd-health">信息分 {{ row.healthScore }}</span>
|
||||
</div>
|
||||
<div class="jd-info-body">
|
||||
<div class="jd-info-title" :title="row.title">{{ row.title || '-' }}</div>
|
||||
<div class="jd-info-meta">
|
||||
商品编码:<span class="jd-info-code">{{ row.productCode || '-' }}</span>
|
||||
<button v-if="row.productCode" class="jd-copy-btn" type="button" title="复制商品编码" @click.stop="copyText(row.productCode)">⧉</button>
|
||||
</div>
|
||||
<div class="jd-info-meta">货号:<span class="jd-info-code">{{ row.itemNum || '-' }}</span></div>
|
||||
<!-- 品牌·类目行:京麦列表同款(末级类目名紧随品牌),字段与顺序 2026-11-15 对齐京麦。 -->
|
||||
<div v-if="row.brand || row.categoryPath" class="jd-info-meta jd-brand-cat">
|
||||
<span class="jd-brand-name">{{ row.brand || '' }}</span> {{ row.categoryPath || '' }}
|
||||
</div>
|
||||
<div v-if="row.skuCount" class="jd-info-tags"><span class="jd-tag">{{ row.skuCount }}个SKU</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ row.stockTotal ?? '-' }}</td>
|
||||
<td>{{ jdPriceRange(row) || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
|
||||
<!-- 操作列(2026-11-15 用户口径):编辑/删除;@click.stop 防冒泡开详情抽屉。
|
||||
2026-11-16「操作放最后一列」口径置末;「上架时间 / 商品状态」列同日整列下线;
|
||||
写权限 2026-11-17 口径放宽到管理员级 ⇒ 普通账号不渲染该列。 -->
|
||||
<td v-if="canWriteProducts" class="jd-ops-cell" @click.stop>
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="deleting" @click="removeOne(row)">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="emptyColspan" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="emptyColspan" class="empty-tip">暂无京东商品数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- 卡片网格(v1.6):商城款式;卡片整体点击=开详情弹窗,勾选/复制 @click.stop 防冒泡。 -->
|
||||
<div class="jd-card-grid">
|
||||
<template v-if="rows.length">
|
||||
<JdProductCard
|
||||
v-for="row in rows"
|
||||
:key="row.id"
|
||||
:item="row"
|
||||
:selected="selectedIds.has(row.id)"
|
||||
:selectable="hasSelection"
|
||||
@toggle-select="(checked: boolean) => toggleSelect(row, checked)"
|
||||
@open="openDetail(row)"
|
||||
@copy="copyProductCode(row)"
|
||||
/>
|
||||
</template>
|
||||
<div v-else-if="loading" class="jd-empty-tip">加载中...</div>
|
||||
<div v-else class="jd-empty-tip">暂无京东商品数据</div>
|
||||
</div>
|
||||
|
||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||
<!-- 每页条数档位 20/50/100(v1.6 Phase 1 契约)随分页条下发。 -->
|
||||
<OldPagination
|
||||
:total="total"
|
||||
:page="page"
|
||||
:page-size="pageSize"
|
||||
:sizes="[...JD_PRODUCT_PAGE_SIZE_OPTIONS]"
|
||||
@change="changePage"
|
||||
@size-change="changeSize"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<JdBatchAssignDialog
|
||||
@@ -573,10 +583,13 @@ onMounted(async () => {
|
||||
@changed="onManaged"
|
||||
@group-created="onGroupCreated"
|
||||
/>
|
||||
<JdProductDetailDrawer
|
||||
<JdProductDetailModal
|
||||
:item="detailItem"
|
||||
:visible="detailVisible"
|
||||
:can-write="canWriteProducts"
|
||||
@close="closeDetail"
|
||||
@edit="onDetailEdit"
|
||||
@remove="onDetailRemove"
|
||||
/>
|
||||
<JdProductEditDrawer
|
||||
:item="editItem"
|
||||
|
||||
Reference in New Issue
Block a user