feat(jd-database): v1.7 侧栏店铺名单——分类下挂店铺、点店铺过滤、行内改名/移除、添加店铺弹窗
This commit is contained in:
@@ -18,15 +18,19 @@ import type { JdProductCategoryOption, JdProductGroup } from './jd-product-api.t
|
||||
const props = defineProps<{
|
||||
/** /categories 计数行(京麦末级类目+商品数;页面持有,失败静默回空数组)。 */
|
||||
categoryOptions: JdProductCategoryOption[]
|
||||
/** 当前数据权限分组的分类(V203 归属口径,带 productCount 徽标)。 */
|
||||
/** 当前数据权限分组的分类(V203 归属口径,带 productCount 徽标;v1.7 每行可带
|
||||
* shops 店铺名单——分类行出展开箭头,展开后店铺行点选过滤)。 */
|
||||
categories: JdProductGroup[]
|
||||
/** 当前分组分类可写(scope.editable 投影):可写档渲染「新建分类」行;
|
||||
* 「分类管理」入口对所有人渲染(同组普通号只读可看,V203,写控件由对话框分档)。 */
|
||||
/** 当前分组分类可写(scope.editable 投影):可写档渲染「新建分类」行、分类/店铺行的
|
||||
* hover 改名/删除与「添加店铺」入口;「分类管理」入口对所有人渲染(同组普通号只读可看,
|
||||
* V203,写控件由对话框分档)。 */
|
||||
editable: boolean
|
||||
/** 当前类目选中(name+完整名称路径;树外历史名 path 为空数组;null=全部商品)。 */
|
||||
selectedCategory?: { name: string; path: string[] } | null
|
||||
/** 当前分类选中 id(null=全部分类)。 */
|
||||
selectedGroupId?: number | null
|
||||
/** 当前店铺筛选(v1.7 店铺名单点选;空/缺省=未按店铺过滤)。 */
|
||||
selectedShopName?: string | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -35,9 +39,22 @@ const emit = defineEmits<{
|
||||
(event: 'select-category', value: { name: string; path: string[] } | null): void
|
||||
/** 选分类:分类 id;再点已选中的=清选(emit null,回全部分类)。 */
|
||||
(event: 'select-group', id: number | null): void
|
||||
/** 选店铺(v1.7 名单点选):分类+店铺名成对下发(点店铺=该分类归属 ∩ 该店铺,
|
||||
* 精确 eq);再点已选中的=emit null(只清店铺筛选,分类选中保留)。 */
|
||||
(event: 'select-shop', value: { groupId: number; shopName: string } | null): void
|
||||
/** 新建分类(可写档):页面调 createJdProductGroup 落当前分组,成功后刷新,
|
||||
* 侧栏数据随 props 流回(本组件不感知成功/失败,输入框提交即清)。 */
|
||||
(event: 'create-category', name: string): void
|
||||
/** 分类行内改名(可写档 hover ✎):分类 id+新名,API 调用与刷新在页面。 */
|
||||
(event: 'rename-category', category: JdProductGroup, name: string): void
|
||||
/** 分类行内删除(可写档 hover ✕):页面二次确认后调 deleteJdProductGroup。 */
|
||||
(event: 'delete-category', category: JdProductGroup): void
|
||||
/** 店铺行内改名(可写档 hover ✎):分类、老名、新名(同分类查重 409 由后端拒)。 */
|
||||
(event: 'rename-shop', category: JdProductGroup, oldName: string, newName: string): void
|
||||
/** 店铺行内移除(可写档 hover ✕):页面调 removeJdGroupShop。 */
|
||||
(event: 'remove-shop', category: JdProductGroup, shopName: string): void
|
||||
/** 打开添加店铺弹窗(可写档「+ 添加店铺」行):弹窗与提交在页面。 */
|
||||
(event: 'add-shops', category: JdProductGroup): void
|
||||
/** 打开分类管理对话框(建/改名/删+搜索,V204 并入的既有组件)。 */
|
||||
(event: 'manage-categories'): void
|
||||
}>()
|
||||
@@ -134,10 +151,11 @@ const isSelectedExtra = (name: string): boolean => {
|
||||
return !!selected && selected.path.length === 0 && selected.name === name
|
||||
}
|
||||
|
||||
// ---------------- 店铺分类 Tab(当前分组分类平铺) ----------------
|
||||
// ---------------- 店铺分类 Tab(当前分组分类平铺+店铺名单 v1.7) ----------------
|
||||
|
||||
function pickGroup(group: JdProductGroup): void {
|
||||
// 再点已选中的=清选(回全部分类),与旧「全部分类」下拉行的语义等价。
|
||||
// 店铺筛选随分类清选一起走(店铺名单挂在分类下,分类清了店铺筛选无意义——页面同清)。
|
||||
emit('select-group', props.selectedGroupId === group.id ? null : group.id)
|
||||
}
|
||||
|
||||
@@ -149,6 +167,85 @@ function submitCreate(): void {
|
||||
emit('create-category', name)
|
||||
newCategoryName.value = ''
|
||||
}
|
||||
|
||||
// ---------------- 店铺名单(v1.7 F6 完整对齐原型:分类下挂店铺名单) ----------------
|
||||
|
||||
/** 名单展开态(按分类 id 记):有名单的分类行出箭头,出厂收起。 */
|
||||
const expandedShops = ref<Set<number>>(new Set())
|
||||
|
||||
function toggleShops(group: JdProductGroup): void {
|
||||
const next = new Set(expandedShops.value)
|
||||
if (next.has(group.id)) next.delete(group.id)
|
||||
else next.add(group.id)
|
||||
expandedShops.value = next
|
||||
}
|
||||
|
||||
/** 店铺行点选:分类+店铺成对下发(页面发 group_id+shop_name 过滤);再点已选中的
|
||||
* =emit null(只清店铺筛选,分类选中保留——每层独立 toggle)。 */
|
||||
function pickShop(group: JdProductGroup, shopName: string): void {
|
||||
const picked = props.selectedGroupId === group.id && props.selectedShopName === shopName
|
||||
emit('select-shop', picked ? null : { groupId: group.id, shopName })
|
||||
}
|
||||
|
||||
/** 页面带着店铺筛选挂载/回流时(重置后再选、切页返回),宿主分类自动展开到位。 */
|
||||
watch(
|
||||
() => props.selectedShopName,
|
||||
(shop) => {
|
||||
if (!shop) return
|
||||
const host = (props.categories ?? []).find((group) => (group.shops ?? []).includes(shop))
|
||||
if (host && !expandedShops.value.has(host.id)) {
|
||||
const next = new Set(expandedShops.value)
|
||||
next.add(host.id)
|
||||
expandedShops.value = next
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// 行内改名(分类与店铺同构):点 hover ✎ 进编辑形态,Enter/✓ 提交、✕ 取消。
|
||||
const renamingCategory = ref<number | null>(null)
|
||||
const renameCategoryDraft = ref('')
|
||||
const renamingShop = ref<{ categoryId: number; name: string } | null>(null)
|
||||
const renameShopDraft = ref('')
|
||||
|
||||
function startRenameCategory(group: JdProductGroup): void {
|
||||
cancelShopRename()
|
||||
renamingCategory.value = group.id
|
||||
renameCategoryDraft.value = group.name
|
||||
}
|
||||
|
||||
function submitRenameCategory(group: JdProductGroup): void {
|
||||
const name = renameCategoryDraft.value.trim()
|
||||
cancelRenameCategory()
|
||||
// 空名/未改动不 emit(静默收编辑态,不白发请求)。
|
||||
if (!name || name === group.name) return
|
||||
emit('rename-category', group, name)
|
||||
}
|
||||
|
||||
function cancelRenameCategory(): void {
|
||||
renamingCategory.value = null
|
||||
renameCategoryDraft.value = ''
|
||||
}
|
||||
|
||||
function startRenameShop(group: JdProductGroup, shopName: string): void {
|
||||
cancelRenameCategory()
|
||||
renamingShop.value = { categoryId: group.id, name: shopName }
|
||||
renameShopDraft.value = shopName
|
||||
}
|
||||
|
||||
function submitRenameShop(group: JdProductGroup): void {
|
||||
const entry = renamingShop.value
|
||||
if (!entry) return
|
||||
const name = renameShopDraft.value.trim()
|
||||
cancelShopRename()
|
||||
if (!name || name === entry.name) return
|
||||
emit('rename-shop', group, entry.name, name)
|
||||
}
|
||||
|
||||
function cancelShopRename(): void {
|
||||
renamingShop.value = null
|
||||
renameShopDraft.value = ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -250,19 +347,112 @@ function submitCreate(): void {
|
||||
<button type="button" class="jd-side-manage" @click="emit('manage-categories')">分类管理</button>
|
||||
|
||||
<template v-if="categories.length">
|
||||
<button
|
||||
v-for="cat in categories"
|
||||
:key="cat.id"
|
||||
type="button"
|
||||
class="jd-side-row"
|
||||
:class="{ selected: selectedGroupId === cat.id }"
|
||||
:title="cat.name"
|
||||
@click="pickGroup(cat)"
|
||||
>
|
||||
<span class="jd-side-leaf-dot" />
|
||||
<span class="jd-side-name">{{ cat.name }}</span>
|
||||
<span class="jd-side-count">{{ cat.productCount }}</span>
|
||||
</button>
|
||||
<!-- 分类行(div role=button,行内要嵌 hover 操作按钮——button 嵌 button 非法 HTML):
|
||||
有名单(shops)出展开箭头;可写档 hover 出改名/删除;展开后店铺行+添加店铺入口。 -->
|
||||
<template v-for="cat in categories" :key="cat.id">
|
||||
<div
|
||||
class="jd-side-row jd-side-cat"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:class="{ selected: selectedGroupId === cat.id }"
|
||||
:title="cat.name"
|
||||
@click="pickGroup(cat)"
|
||||
@keydown.enter="pickGroup(cat)"
|
||||
>
|
||||
<span
|
||||
v-if="(cat.shops?.length || 0) > 0"
|
||||
class="jd-side-arrow"
|
||||
:class="{ open: expandedShops.has(cat.id) }"
|
||||
role="button"
|
||||
:aria-label="`展开或收起 ${cat.name} 的店铺名单`"
|
||||
@click.stop="toggleShops(cat)"
|
||||
>▸</span>
|
||||
<span v-else class="jd-side-leaf-dot" />
|
||||
<span class="jd-side-name">{{ cat.name }}</span>
|
||||
<span class="jd-side-count">{{ cat.productCount }}</span>
|
||||
<span v-if="editable" class="jd-side-ops">
|
||||
<button
|
||||
type="button"
|
||||
class="jd-side-op"
|
||||
:aria-label="`改名分类 ${cat.name}`"
|
||||
title="改名"
|
||||
@click.stop="startRenameCategory(cat)"
|
||||
>✎</button>
|
||||
<button
|
||||
type="button"
|
||||
class="jd-side-op jd-side-op-danger"
|
||||
:aria-label="`删除分类 ${cat.name}`"
|
||||
title="删除"
|
||||
@click.stop="emit('delete-category', cat)"
|
||||
>✕</button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- 分类行内改名(编辑形态替换该行):Enter/✓ 提交(空名/未改动静默收起)。 -->
|
||||
<div v-if="renamingCategory === cat.id" class="jd-side-inline-edit">
|
||||
<input
|
||||
v-model="renameCategoryDraft"
|
||||
type="text"
|
||||
:aria-label="`修改分类名称(原:${cat.name})`"
|
||||
@keyup.enter="submitRenameCategory(cat)"
|
||||
/>
|
||||
<button type="button" :aria-label="`确认改名分类 ${cat.name}`" @click.stop="submitRenameCategory(cat)">✓</button>
|
||||
<button type="button" aria-label="取消改名" @click.stop="cancelRenameCategory()">✕</button>
|
||||
</div>
|
||||
<!-- 展开的店铺名单(v1.7):点店铺=分类+店铺成对过滤;可写档 hover 改名/移除;
|
||||
名单尾「+ 添加店铺」入口开页面级弹窗。 -->
|
||||
<template v-if="expandedShops.has(cat.id)">
|
||||
<template v-for="shop in (cat.shops ?? [])" :key="`${cat.id}:${shop}`">
|
||||
<div
|
||||
class="jd-side-row jd-side-shop depth-1"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
:class="{ selected: selectedGroupId === cat.id && selectedShopName === shop }"
|
||||
:title="shop"
|
||||
@click="pickShop(cat, shop)"
|
||||
@keydown.enter="pickShop(cat, shop)"
|
||||
>
|
||||
<span class="jd-side-leaf-dot" />
|
||||
<span class="jd-side-name">{{ shop }}</span>
|
||||
<span v-if="editable" class="jd-side-ops">
|
||||
<button
|
||||
type="button"
|
||||
class="jd-side-op"
|
||||
:aria-label="`改名店铺 ${shop}`"
|
||||
title="改名"
|
||||
@click.stop="startRenameShop(cat, shop)"
|
||||
>✎</button>
|
||||
<button
|
||||
type="button"
|
||||
class="jd-side-op jd-side-op-danger"
|
||||
:aria-label="`移除店铺 ${shop}`"
|
||||
title="移除"
|
||||
@click.stop="emit('remove-shop', cat, shop)"
|
||||
>✕</button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- 店铺行内改名(编辑形态替换该行)。 -->
|
||||
<div v-if="renamingShop && renamingShop.categoryId === cat.id" class="jd-side-inline-edit jd-side-shop-edit depth-1">
|
||||
<input
|
||||
v-model="renameShopDraft"
|
||||
type="text"
|
||||
:aria-label="`修改店铺名称(原:${renamingShop.name})`"
|
||||
@keyup.enter="submitRenameShop(cat)"
|
||||
/>
|
||||
<button type="button" :aria-label="`确认改名店铺 ${renamingShop.name}`" @click.stop="submitRenameShop(cat)">✓</button>
|
||||
<button type="button" aria-label="取消改名" @click.stop="cancelShopRename()">✕</button>
|
||||
</div>
|
||||
</template>
|
||||
<button
|
||||
v-if="editable"
|
||||
type="button"
|
||||
class="jd-side-row jd-side-shop-add depth-1"
|
||||
@click="emit('add-shops', cat)"
|
||||
>
|
||||
<span class="jd-side-leaf-dot" />
|
||||
<span class="jd-side-name">+ 添加店铺</span>
|
||||
</button>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
<p v-else class="jd-side-empty">{{ editable ? '本组暂无分类,先新建一个' : '本组暂无分类' }}</p>
|
||||
</div>
|
||||
@@ -465,4 +655,92 @@ function submitCreate(): void {
|
||||
.jd-side-manage:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
/* 店铺名单(v1.7 F6):分类行 hover 操作钮(改名/删除)、店铺行缩进、行内改名编辑形态、
|
||||
「+ 添加店铺」入口。行本体是 div role=button(行内嵌操作按钮,button 嵌 button 非法)。 */
|
||||
.jd-side-row.jd-side-cat,
|
||||
.jd-side-row.jd-side-shop {
|
||||
cursor: pointer;
|
||||
}
|
||||
/* hover 操作钮:默认藏,行 hover 时浮出(占位 0 宽,不挤名字/徽标布局)。 */
|
||||
.jd-side-ops {
|
||||
display: inline-flex;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
width: 0;
|
||||
overflow: hidden;
|
||||
transition: width 120ms ease;
|
||||
}
|
||||
.jd-side-row:hover .jd-side-ops,
|
||||
.jd-side-row:focus-within .jd-side-ops {
|
||||
width: 36px;
|
||||
}
|
||||
.jd-side-op {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: #909399;
|
||||
font-size: 11px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.jd-side-op:hover {
|
||||
background: #e6edf4;
|
||||
color: #409eff;
|
||||
}
|
||||
.jd-side-op-danger:hover {
|
||||
background: #fdf1ef;
|
||||
color: #a04432;
|
||||
}
|
||||
/* 行内改名编辑形态:替换该行的紧凑输入行(Enter/✓ 提交、✕ 取消)。 */
|
||||
.jd-side-inline-edit {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 8px;
|
||||
}
|
||||
.jd-side-inline-edit.jd-side-shop-edit {
|
||||
padding-left: 22px;
|
||||
}
|
||||
.jd-side-inline-edit input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #9fc3e8;
|
||||
border-radius: 6px;
|
||||
font-size: 12.5px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
.jd-side-inline-edit input:focus {
|
||||
box-shadow: 0 0 0 2px rgba(95, 133, 173, 0.18);
|
||||
}
|
||||
.jd-side-inline-edit button {
|
||||
width: 22px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
color: #409eff;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.jd-side-inline-edit button:last-child {
|
||||
color: #909399;
|
||||
}
|
||||
/* 「+ 添加店铺」入口:名单尾部的弱化行(虚线上缘分隔),可写档才渲染(v-if 在模板)。 */
|
||||
.jd-side-shop-add {
|
||||
color: #409eff;
|
||||
border-top: 1px dashed #e4e7ed;
|
||||
border-radius: 0;
|
||||
}
|
||||
.jd-side-shop-add:hover {
|
||||
color: #2f7cd6;
|
||||
background: #f0f7ff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -19,11 +19,15 @@ import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import {
|
||||
batchAssignJdProductGroup,
|
||||
createJdProductGroup,
|
||||
deleteJdProductGroup,
|
||||
deleteJdProducts,
|
||||
fetchJdCategoryScope,
|
||||
fetchJdProductCategories,
|
||||
fetchJdProductGroups,
|
||||
fetchJdProductList,
|
||||
removeJdGroupShop,
|
||||
renameJdGroupShop,
|
||||
updateJdProductGroup,
|
||||
type JdCategoryGroupOption,
|
||||
type JdProductCategoryOption,
|
||||
type JdProductGroup,
|
||||
@@ -41,6 +45,7 @@ import JdProductDetailModal from './JdProductDetailModal.vue'
|
||||
import JdProductEditDrawer from './JdProductEditDrawer.vue'
|
||||
import JdBatchAssignDialog from './JdBatchAssignDialog.vue'
|
||||
import JdCategoryManageDialog from './JdCategoryManageDialog.vue'
|
||||
import JdShopPickerDialog from './JdShopPickerDialog.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
@@ -156,9 +161,110 @@ function onSelectCategory(value: { name: string; path: string[] } | null): void
|
||||
/** 侧栏选分类:id 或 null(清选,与旧「全部分类」下拉行同语义)。选中即查。 */
|
||||
function onSelectGroup(id: number | null): void {
|
||||
filter.groupId = id ? String(id) : ''
|
||||
// 店铺筛选挂在分类下(v1.7 名单维度):分类清选时店铺筛选一起清,否则发一条
|
||||
// 「分类不限 ∩ 店铺=X」的孤儿谓词(店铺全平台 DISTINCT,会命中别组分类下的同名店)。
|
||||
filter.shopName = ''
|
||||
apply()
|
||||
}
|
||||
|
||||
// ---------------- 店铺名单(v1.7 F6:侧栏展开/点店铺过滤/行内改名移除/添加店铺弹窗) ----------------
|
||||
|
||||
/** 添加店铺弹窗的目标分类(名单挂在分类下;null=弹窗关着)。 */
|
||||
const addShopsTarget = ref<JdProductGroup | null>(null)
|
||||
const addShopsVisible = ref(false)
|
||||
|
||||
/** 侧栏点店铺行:分类+店铺成对下发(精确 eq);null=清店铺筛选(分类选中保留)。 */
|
||||
function onSelectShop(value: { groupId: number; shopName: string } | null): void {
|
||||
if (!value) {
|
||||
filter.shopName = ''
|
||||
apply()
|
||||
return
|
||||
}
|
||||
filter.groupId = String(value.groupId)
|
||||
filter.shopName = value.shopName
|
||||
apply()
|
||||
}
|
||||
|
||||
/** 侧栏分类行内改名:成功后刷新分类(侧栏随 props 流回);失败弹后端中文文案(409 重名等)。 */
|
||||
async function onRenameCategory(category: JdProductGroup, name: string): Promise<void> {
|
||||
try {
|
||||
await updateJdProductGroup(category.id, { name, sortOrder: category.sortOrder })
|
||||
showAdminFeedback(`已把分类「${category.name}」改名为「${name}」`, 'success')
|
||||
await loadGroupOptions()
|
||||
} catch (error) {
|
||||
const text = error instanceof Error && error.message ? error.message : '改名失败,请稍后重试'
|
||||
showAdminFeedback(text, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** 侧栏分类行内删除:二次确认(点名只解挂归属、商品保留)→ 删除 → 若当前筛选停在该
|
||||
* 分类(含其店铺行)则清分类筛选,分类列表与行集都重取。 */
|
||||
async function onDeleteCategory(category: JdProductGroup): Promise<void> {
|
||||
const ok = await openAdminConfirm({ title: '删除分类', message: `确定删除分类「${category.name}」吗?只删除该分类的归属关系(${category.productCount} 个商品回到未分类),商品本身保留在公共库;分类下的店铺名单一并删除。此操作不可恢复。`, confirmText: '确认删除', danger: true })
|
||||
if (!ok) return
|
||||
try {
|
||||
await deleteJdProductGroup(category.id)
|
||||
showAdminFeedback(`已删除分类「${category.name}」`, 'success')
|
||||
if (filter.groupId === String(category.id)) {
|
||||
filter.groupId = ''
|
||||
filter.shopName = ''
|
||||
}
|
||||
await loadGroupOptions()
|
||||
await load()
|
||||
} catch (error) {
|
||||
const text = error instanceof Error && error.message ? error.message : '删除分类失败,请稍后重试'
|
||||
showAdminFeedback(text, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** 店铺行内改名:成功后刷新名单;若当前筛选正停在这个店(同分类)则把筛选词同步成新名。 */
|
||||
async function onRenameShop(category: JdProductGroup, oldName: string, newName: string): Promise<void> {
|
||||
try {
|
||||
await renameJdGroupShop(category.id, oldName, newName)
|
||||
showAdminFeedback(`已把店铺「${oldName}」改名为「${newName}」`, 'success')
|
||||
if (filter.groupId === String(category.id) && filter.shopName === oldName) {
|
||||
filter.shopName = newName
|
||||
await load()
|
||||
}
|
||||
await loadGroupOptions()
|
||||
} catch (error) {
|
||||
const text = error instanceof Error && error.message ? error.message : '改名失败,请稍后重试'
|
||||
showAdminFeedback(text, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** 店铺行内移除(可重做——再加回名单即可,不设二次确认);筛选正停在它身上则清店铺筛选。 */
|
||||
async function onRemoveShop(category: JdProductGroup, shopName: string): Promise<void> {
|
||||
try {
|
||||
await removeJdGroupShop(category.id, shopName)
|
||||
showAdminFeedback(`已把「${shopName}」移出「${category.name}」的名单`, 'success')
|
||||
if (filter.groupId === String(category.id) && filter.shopName === shopName) {
|
||||
filter.shopName = ''
|
||||
await load()
|
||||
}
|
||||
await loadGroupOptions()
|
||||
} catch (error) {
|
||||
const text = error instanceof Error && error.message ? error.message : '移除失败,请稍后重试'
|
||||
showAdminFeedback(text, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开添加店铺弹窗(侧栏「+ 添加店铺」行;名单写闸 editable 在侧栏已分档,后端同闸兜底)。 */
|
||||
function openAddShops(category: JdProductGroup): void {
|
||||
addShopsTarget.value = category
|
||||
addShopsVisible.value = true
|
||||
}
|
||||
|
||||
/** 添加店铺成功:回执=实际新增行数(幂等跳过不计)。只刷新名单(侧栏店铺行随 props
|
||||
* 流回)——名单是筛选器的候选面,不动商品行集,行集谓词 shop_name 无需重查。 */
|
||||
async function onShopsAdded(added: number, categoryName: string): Promise<void> {
|
||||
showAdminFeedback(
|
||||
added > 0 ? `已把 ${added} 个店铺加进「${categoryName}」` : '所选店铺都已在名单里,没有新增',
|
||||
'success',
|
||||
)
|
||||
await loadGroupOptions()
|
||||
}
|
||||
|
||||
/** 侧栏新建分类(可写档):落当前分组,成功后刷新分类(侧栏徽标随 props 流回)。 */
|
||||
async function onCreateCategory(name: string): Promise<void> {
|
||||
try {
|
||||
@@ -666,17 +772,25 @@ onMounted(async () => {
|
||||
</section>
|
||||
|
||||
<div class="jd-body">
|
||||
<!-- 左侧栏(v1.6):商品目录(京麦授权类目树+计数徽标+树外兜底)/店铺分类
|
||||
(当前分组分类平铺+新建+分类管理入口)。取数在页面,侧栏纯展示。 -->
|
||||
<!-- 左侧栏(v1.6 → v1.7 名单维度):商品目录(京麦授权类目树+计数徽标+树外兜底)/
|
||||
店铺分类(分类平铺+店铺名单展开/点选过滤/行内改名移除+添加店铺入口+新建+
|
||||
分类管理入口)。取数在页面,侧栏纯展示。 -->
|
||||
<JdCategorySidebar
|
||||
:category-options="categoryOptions"
|
||||
:categories="groupOptions"
|
||||
:editable="canManageCategories"
|
||||
:selected-category="selectedCategoryInfo"
|
||||
:selected-group-id="selectedGroupIdNum"
|
||||
:selected-shop-name="filter.shopName"
|
||||
@select-category="onSelectCategory"
|
||||
@select-group="onSelectGroup"
|
||||
@select-shop="onSelectShop"
|
||||
@create-category="onCreateCategory"
|
||||
@rename-category="onRenameCategory"
|
||||
@delete-category="onDeleteCategory"
|
||||
@rename-shop="onRenameShop"
|
||||
@remove-shop="onRemoveShop"
|
||||
@add-shops="openAddShops"
|
||||
@manage-categories="openManage"
|
||||
/>
|
||||
|
||||
@@ -751,6 +865,15 @@ onMounted(async () => {
|
||||
@close="batchEditVisible = false"
|
||||
@done="onBatchAssigned"
|
||||
/>
|
||||
<!-- 添加店铺弹窗(v1.7 F6):侧栏「+ 添加店铺」行打开,弹窗自取候选(available)
|
||||
与批量提交,done 回执带新增行数给页面刷名单。 -->
|
||||
<JdShopPickerDialog
|
||||
:visible="addShopsVisible"
|
||||
:category-id="addShopsTarget?.id ?? 0"
|
||||
:category-name="addShopsTarget?.name ?? ''"
|
||||
@close="addShopsVisible = false"
|
||||
@done="onShopsAdded"
|
||||
/>
|
||||
<JdCategoryManageDialog
|
||||
:visible="manageVisible"
|
||||
:owner-group-id="ownerGroupId"
|
||||
|
||||
@@ -0,0 +1,439 @@
|
||||
<script setup lang="ts">
|
||||
/** 添加店铺弹窗(v1.7 F6 对齐原型《商品数据商城》的「店铺名单维度」):
|
||||
* 侧栏店铺分类 Tab 展开某分类后的「+ 添加店铺」行打开。候选=服务端
|
||||
* fetchJdAvailableShops(biz_jd_product.shop_name DISTINCT,关键词包含匹配+排除本分类
|
||||
* 已有名单,limit ≤ 200——商品行 shop_name 是京麦店铺全名,与名单来源同源);
|
||||
* 勾选候选+手输自定义项(不在候选里的新店名)合并成一个待添加清单,一次批量提交
|
||||
* (服务侧 trim/去重/上限 100,INSERT IGNORE 幂等跳过已存在行,回执=实际新增行数)。
|
||||
* 结构复制 JdBatchAssignDialog(modal-mask+modal-head/tip/foot 同款皮肤)。 */
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { addJdGroupShops, fetchJdAvailableShops } from './jd-product-api.ts'
|
||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
/** 目标分类(名单挂在分类下)。 */
|
||||
categoryId: number
|
||||
categoryName: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ (event: 'close'): void; (event: 'done', added: number, categoryName: string): void }>()
|
||||
|
||||
/** 候选搜索(关键词输入后手动点「搜索」或 Enter 触发——不随输入逐键打后端)。 */
|
||||
const keyword = ref('')
|
||||
const candidates = ref<string[]>([])
|
||||
const searching = ref(false)
|
||||
const searched = ref(false)
|
||||
/** 待添加清单(勾选的候选+手输自定义项,Set 保序去重)。 */
|
||||
const pending = ref<string[]>([])
|
||||
/** 手输自定义项输入框。 */
|
||||
const customName = ref('')
|
||||
const submitting = ref(false)
|
||||
const errorText = ref('')
|
||||
|
||||
/** 批量上限与服务端 JdGroupShopService.MAX_ADD_SHOPS 同值(文案点名 100)。 */
|
||||
const MAX_ADD_SHOPS = 100
|
||||
|
||||
const canSubmit = computed(() => pending.value.length > 0 && !submitting.value)
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
keyword.value = ''
|
||||
candidates.value = []
|
||||
searched.value = false
|
||||
pending.value = []
|
||||
customName.value = ''
|
||||
errorText.value = ''
|
||||
// 打开即拉一次空关键词候选(让用户不输词也有东西可勾)。
|
||||
void search()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
async function search(): Promise<void> {
|
||||
searching.value = true
|
||||
errorText.value = ''
|
||||
try {
|
||||
candidates.value = await fetchJdAvailableShops(keyword.value, props.categoryId)
|
||||
searched.value = true
|
||||
} catch (error) {
|
||||
errorText.value = requestErrorMessage(error) || '候选店铺加载失败'
|
||||
} finally {
|
||||
searching.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCandidate(name: string): void {
|
||||
const index = pending.value.indexOf(name)
|
||||
if (index >= 0) pending.value = pending.value.filter((item) => item !== name)
|
||||
else pending.value = [...pending.value, name]
|
||||
}
|
||||
|
||||
/** 手输自定义项:空白不收;与待添加清单重复不收(静默忽略——清单里已有就是同一个)。 */
|
||||
function addCustom(): void {
|
||||
const name = customName.value.trim()
|
||||
if (!name) return
|
||||
if (!pending.value.includes(name)) pending.value = [...pending.value, name]
|
||||
customName.value = ''
|
||||
}
|
||||
|
||||
function removePending(name: string): void {
|
||||
pending.value = pending.value.filter((item) => item !== name)
|
||||
}
|
||||
|
||||
async function submit(): Promise<void> {
|
||||
if (!canSubmit.value) return
|
||||
submitting.value = true
|
||||
errorText.value = ''
|
||||
try {
|
||||
const added = await addJdGroupShops(props.categoryId, pending.value)
|
||||
emit('done', added, props.categoryName)
|
||||
emit('close')
|
||||
} catch (error) {
|
||||
errorText.value = requestErrorMessage(error) || '添加店铺失败'
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="modal-mask" @click.self="emit('close')">
|
||||
<div class="shop-picker-modal">
|
||||
<div class="modal-head">
|
||||
<h3>添加店铺<span v-if="categoryName" class="modal-sub">· {{ categoryName }}</span></h3>
|
||||
<button class="modal-close" type="button" aria-label="关闭" @click="emit('close')">×</button>
|
||||
</div>
|
||||
<p class="modal-tip">
|
||||
从已采集商品的店铺里勾选,或手动输入名单里还没有的店铺名;
|
||||
一次最多添加 {{ MAX_ADD_SHOPS }} 个,已有的会自动跳过。
|
||||
</p>
|
||||
<p v-if="errorText" class="group-error">{{ errorText }}</p>
|
||||
|
||||
<!-- 候选搜索:关键词包含匹配(服务端 DISTINCT+like),Enter 或按钮触发。 -->
|
||||
<div class="shop-search">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索店铺名"
|
||||
aria-label="候选店铺关键词"
|
||||
@keyup.enter="search"
|
||||
/>
|
||||
<button type="button" :disabled="searching" @click="search">{{ searching ? '搜索中...' : '搜索' }}</button>
|
||||
</div>
|
||||
|
||||
<ul class="shop-candidate-list">
|
||||
<li v-if="searching" class="shop-list-tip">搜索中...</li>
|
||||
<li v-else-if="!candidates.length && searched" class="shop-list-tip">没有可添加的候选店铺(已采商品的店铺都在名单里了,试试手动输入)</li>
|
||||
<li
|
||||
v-for="name in candidates"
|
||||
:key="name"
|
||||
class="shop-candidate-row"
|
||||
:class="{ active: pending.includes(name) }"
|
||||
:title="name"
|
||||
@click="toggleCandidate(name)"
|
||||
>
|
||||
<span class="shop-check" aria-hidden="true"></span>
|
||||
<span class="shop-name">{{ name }}</span>
|
||||
<span v-if="pending.includes(name)" class="shop-picked-tag">已选</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- 手输自定义项+待添加清单(chips 可移除)。 -->
|
||||
<div class="shop-custom">
|
||||
<input
|
||||
v-model="customName"
|
||||
type="text"
|
||||
placeholder="手动输入店铺名(自定义)"
|
||||
aria-label="自定义店铺名"
|
||||
@keyup.enter="addCustom"
|
||||
/>
|
||||
<button type="button" :disabled="!customName.trim() || pending.length >= MAX_ADD_SHOPS" @click="addCustom">加入</button>
|
||||
</div>
|
||||
<div v-if="pending.length" class="shop-pending">
|
||||
<span v-for="name in pending" :key="name" class="shop-chip">
|
||||
{{ name }}
|
||||
<button type="button" :aria-label="`移除待添加 ${name}`" @click="removePending(name)">×</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="modal-foot">
|
||||
<button class="btn btn-secondary" type="button" @click="emit('close')">取消</button>
|
||||
<button class="btn" type="button" :disabled="!canSubmit" @click="submit">
|
||||
{{ submitting ? '提交中...' : `添加(${pending.length})` }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2800;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 20px;
|
||||
background: rgba(45, 66, 86, 0.36);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.shop-picker-modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(460px, 100%);
|
||||
max-height: 80vh;
|
||||
padding: 18px 20px 20px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
||||
}
|
||||
.modal-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.modal-head h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
}
|
||||
.modal-sub {
|
||||
margin-left: 6px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.modal-close {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
background: none;
|
||||
color: #5b6f83;
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.modal-close:hover {
|
||||
border-color: #cbd9e6;
|
||||
background: #eef4fa;
|
||||
color: #24384d;
|
||||
}
|
||||
.modal-tip {
|
||||
margin: 8px 0 10px;
|
||||
color: #8293a5;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.group-error {
|
||||
margin: 0 0 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #f0c9c2;
|
||||
border-radius: 10px;
|
||||
background: #fdf1ef;
|
||||
color: #a04432;
|
||||
font-size: 13px;
|
||||
}
|
||||
.shop-search {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.shop-search input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 36px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
.shop-search input:focus {
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.shop-search button {
|
||||
padding: 6px 14px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.shop-search button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.shop-candidate-list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
border: 1px solid #e7eef5;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.shop-candidate-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 9px 10px;
|
||||
border-bottom: 1px solid #eef3f8;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.shop-candidate-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.shop-candidate-row:hover {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.shop-candidate-row.active {
|
||||
background: #e8f1fa;
|
||||
box-shadow: inset 3px 0 0 #4f78a5;
|
||||
}
|
||||
.shop-check {
|
||||
flex: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 1.6px solid #9fb7cd;
|
||||
border-radius: 4px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.shop-candidate-row.active .shop-check {
|
||||
border-color: #4f78a5;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
box-shadow: inset 0 0 0 2.4px #ffffff;
|
||||
}
|
||||
.shop-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: #24384d;
|
||||
}
|
||||
.shop-picked-tag {
|
||||
flex: none;
|
||||
padding: 1px 7px;
|
||||
border-radius: 9px;
|
||||
background: #d9ecff;
|
||||
color: #2f5d8b;
|
||||
font-size: 12px;
|
||||
}
|
||||
.shop-list-tip {
|
||||
padding: 22px 12px;
|
||||
color: #8293a5;
|
||||
font-size: 12.5px;
|
||||
text-align: center;
|
||||
}
|
||||
.shop-custom {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.shop-custom input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 36px;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
.shop-custom input:focus {
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.shop-custom button {
|
||||
padding: 6px 14px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.shop-custom button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.shop-pending {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.shop-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 6px 3px 10px;
|
||||
border-radius: 999px;
|
||||
background: #e8f1f9;
|
||||
color: #3d5a77;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.shop-chip button {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: #c9dcea;
|
||||
color: #3d5a77;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.shop-chip button:hover {
|
||||
background: #b3cde4;
|
||||
}
|
||||
.modal-foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 38px;
|
||||
padding: 7px 16px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
</style>
|
||||
@@ -324,6 +324,67 @@ export async function batchAssignJdProductGroup(
|
||||
return groupDataOf<number>(data)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 店铺名单(v1.7 F6,V214)
|
||||
|
||||
/** 名单行形状=纯店名字符串(GET /{id}/shops 返回 shop_name 升序数组)。 */
|
||||
|
||||
/** 某分类的店铺名单(服务端已升序;前端只滤空白不重排)。失败文案原样抛给调用方。 */
|
||||
export async function fetchJdGroupShops(categoryId: number): Promise<string[]> {
|
||||
const { data } = await http.get<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${categoryId}/shops`)
|
||||
const core = groupDataOf<unknown>(data)
|
||||
return Array.isArray(core)
|
||||
? core
|
||||
.filter((shop): shop is string => typeof shop === 'string' && shop.trim() !== '')
|
||||
.map((shop) => shop.trim())
|
||||
: []
|
||||
}
|
||||
|
||||
/** 批量添加店铺到分类名单(弹窗勾选候选+手输自定义项合并下发):服务侧 trim/去空/
|
||||
* 去重/上限 100,INSERT IGNORE 幂等跳过已存在行;返回实际新增行数(全重复=0 不报错)。 */
|
||||
export async function addJdGroupShops(categoryId: number, shopNames: string[]): Promise<number> {
|
||||
const { data } = await http.post<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${categoryId}/shops`, { shopNames })
|
||||
return groupDataOf<number>(data)
|
||||
}
|
||||
|
||||
/** 移除分类名单里的店铺(删 (分类, 店铺名) 那一行);该分类下不存在时后端按业务错误拒绝。 */
|
||||
export async function removeJdGroupShop(categoryId: number, shopName: string): Promise<void> {
|
||||
const { data } = await http.delete<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${categoryId}/shops`, {
|
||||
params: { shop_name: shopName },
|
||||
})
|
||||
groupDataOf<unknown>(data)
|
||||
}
|
||||
|
||||
/** 改名分类名单里的店铺:老名必须在该名单里,新名同分类查重 409;
|
||||
* 名单改名只更新名单表(商品归类不带店铺维,无原型 assignment 同步链)。 */
|
||||
export async function renameJdGroupShop(categoryId: number, oldName: string, newName: string): Promise<void> {
|
||||
const { data } = await http.patch<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${categoryId}/shops/rename`, {
|
||||
oldName,
|
||||
newName,
|
||||
})
|
||||
groupDataOf<unknown>(data)
|
||||
}
|
||||
|
||||
/** 可添加的店铺候选(biz_jd_product.shop_name DISTINCT +关键词包含匹配+排除指定分类
|
||||
* 已有名单;limit ≤ 200 服务侧钳制)。商品是全平台公共的,候选同样全平台去重。 */
|
||||
export async function fetchJdAvailableShops(
|
||||
keyword: string,
|
||||
excludeCategoryId?: number | null,
|
||||
limit?: number,
|
||||
): Promise<string[]> {
|
||||
const params: Record<string, unknown> = {}
|
||||
const trimmed = (keyword || '').trim()
|
||||
if (trimmed) params.keyword = trimmed
|
||||
if (typeof excludeCategoryId === 'number' && excludeCategoryId > 0) {
|
||||
params.exclude_category_id = excludeCategoryId
|
||||
}
|
||||
if (typeof limit === 'number' && limit > 0) params.limit = limit
|
||||
const { data } = await http.get<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/shops/available`, { params })
|
||||
const core = groupDataOf<unknown>(data)
|
||||
return Array.isArray(core)
|
||||
? core.filter((shop): shop is string => typeof shop === 'string' && shop.trim() !== '')
|
||||
: []
|
||||
}
|
||||
|
||||
/** CSV 导出的本地兜底文件名(yyyyMMddHHmm,与后端导出文件名同一格式;秒位不要——
|
||||
* 同一分钟内的两次导出覆盖旧文件是可接受语义,别拿毫秒名刷屏下载目录)。 */
|
||||
function csvFilenameTimestamp(): string {
|
||||
|
||||
Reference in New Issue
Block a user