feat(jd-database): v1.7 侧栏店铺名单——分类下挂店铺、点店铺过滤、行内改名/移除、添加店铺弹窗
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user