feat(京东上架): 选分类=整分类上架+多店勾选不再整单拒(2026-11-26 晚客户口径)
客户口径「商品信息不要显示,选分类上架就行」「去掉一次只能发一家店的约束」: - 后端 JdPublishTaskService:resolveSingleShop→resolveSourceShops(多店不整单判死); applyTargetShop 四档——没带目标店且多店仍拒(老页面/老客户端 fail-closed), 带目标店时异店或多店一律 NEW;多店任务级来源店不钉死(明细行各带来源店快照) - 用户端:商品勾选列表/分页器下线,选中分类自动分页拉全整分类商品纳入上架集 (终止按累计行数对撞 total,不按本页满不满判);multi 档带 target=与 cross 同档 (协议≥4+琥珀人工确认),未检测=先点检测;建单目标店透传 - 台账:catch-silence blocks 338→339(loadProducts 拉取失败有红色出口,非静默) - 判据:JdPublishTaskServiceTest 多店两支(新增不钉来源/老口径仍拒)+ jd-publish-shop 纯函数+jd-publish-tab/mount 对齐
This commit is contained in:
@@ -42,13 +42,14 @@ import { useLiveTaskBoard } from '@/shared/composables/useLiveTaskBoard'
|
||||
import NotificationBell from '@/shared/components/NotificationBell.vue'
|
||||
import BrandApiSecretSettingsButton from '@/pages/brand/components/BrandApiSecretSettingsButton.vue'
|
||||
|
||||
/** 京东「商品上架」(v1.5 蓝图 §4 Phase 4):选分类 → 勾商品 → 改价规则 → 建单 → 右侧任务面板实时行级进度。
|
||||
/** 京东「商品上架」(v1.5 蓝图 §4 Phase 4;2026-11-26 晚客户口径「商品信息不要显示,选分类上架就行」):
|
||||
* 选分类(自动纳入该分类全部商品) → 改价规则 → 建单 → 右侧任务面板实时行级进度。
|
||||
*
|
||||
* 六条边界(照 v1.4/v1.5 已落地的采集契约与外观专利任务面板骨架,不另造流程):
|
||||
* 1. 分类选项唯一来源=jdCollect.groups 既有出口(B113-01,AC-9 源码绊线钉死:本页不得自拼
|
||||
* 分类 URL);分组下的商品列表走 jdPublish.products(2026-11-25 起作用域=本账号可见
|
||||
* 数据权限分组下的分类归属行,与分类下拉/徽标同源——同组同事采集的商品也能上架,
|
||||
* 跨公司/跨组看不到),页内翻页、勾选跨页累计;
|
||||
* 跨公司/跨组看不到),选中分类=分页拉全整分类商品自动纳入上架集,不再逐行勾选;
|
||||
* 2. 改价规则三档(none/percent/fixed,蓝图 §3 死契约),与勾选集一起进建单体;服务端按
|
||||
* 同一规则折算 SKU 价(铁律 27a 改价同源);
|
||||
* 3. 网页原样转交建单响应的 queuePayload;认领只由客户端与后端完成,投递失败仍可由客户端拉取;
|
||||
@@ -100,58 +101,48 @@ const GROUPS_EMPTY_HINT_TEXT =
|
||||
'本分组暂无分类——请联系管理员在后台「京东数据库 → 店铺分类」创建分类并归入你的分组后再上架。'
|
||||
const groupsEmpty = computed(() => !groupsLoading.value && groupOptions.value.length === 0)
|
||||
|
||||
// ---- 选品分页(作用域过滤在服务端:可见分组的分类归属行;勾选跨页累计在本地 Map,翻页不清空)----
|
||||
const PRODUCT_PAGE_SIZE = 12
|
||||
const products = ref<JdPublishProductVo[]>([])
|
||||
// ---- 选品(2026-11-26 晚客户口径「底下的商品信息就不要显示了,选分类上架就行」;
|
||||
// 作用域过滤仍在服务端:可见分组的分类归属行)----
|
||||
// 选中分类后**自动**分页拉全该分类下全部商品(100 条/页),整批纳入上架集:
|
||||
// 不再有商品行勾选、分页器与「全选分类」按钮;界面只显一行计数摘要。
|
||||
// 换分类=清空重拉,在飞循环按 request 令牌作废——迟到的旧分类商品绝不进新分类建单。
|
||||
const PRODUCT_FETCH_PAGE_SIZE = 100
|
||||
const productTotal = ref(0)
|
||||
const productPage = ref(1)
|
||||
const productsLoading = ref(false)
|
||||
const selectedProducts = ref(new Map<number, JdPublishProductVo>())
|
||||
let productRequest = 0
|
||||
|
||||
const selectedProductIds = computed(() => Array.from(selectedProducts.value.keys()))
|
||||
const wholePageSelected = computed(() => products.value.length > 0
|
||||
&& products.value.every((row) => selectedProducts.value.has(row.id)))
|
||||
const partOfPageSelected = computed(() => !wholePageSelected.value
|
||||
&& products.value.some((row) => selectedProducts.value.has(row.id)))
|
||||
|
||||
function togglePage(checked: boolean) {
|
||||
const next = new Map(selectedProducts.value)
|
||||
for (const row of products.value) {
|
||||
if (checked) next.set(row.id, row)
|
||||
else next.delete(row.id)
|
||||
}
|
||||
selectedProducts.value = next
|
||||
}
|
||||
|
||||
function toggleProduct(row: JdPublishProductVo, checked: boolean) {
|
||||
const next = new Map(selectedProducts.value)
|
||||
if (checked) next.set(row.id, row)
|
||||
else next.delete(row.id)
|
||||
selectedProducts.value = next
|
||||
}
|
||||
|
||||
function clearSelection() {
|
||||
selectedProducts.value = new Map()
|
||||
}
|
||||
|
||||
async function loadProducts() {
|
||||
const request = ++productRequest
|
||||
products.value = []
|
||||
selectedProducts.value = new Map()
|
||||
productTotal.value = 0
|
||||
if (selectedGroupId.value == null) {
|
||||
productTotal.value = 0
|
||||
productsLoading.value = false
|
||||
return
|
||||
}
|
||||
productsLoading.value = true
|
||||
try {
|
||||
const vo = await fetchJdPublishProducts(selectedGroupId.value, productPage.value, PRODUCT_PAGE_SIZE)
|
||||
if (request !== productRequest) return
|
||||
products.value = vo.items ?? []
|
||||
productTotal.value = vo.total ?? 0
|
||||
let fetched = 0
|
||||
for (let page = 1; ; page += 1) {
|
||||
const vo = await fetchJdPublishProducts(selectedGroupId.value, page, PRODUCT_FETCH_PAGE_SIZE)
|
||||
if (request !== productRequest) return
|
||||
const rows = vo.items ?? []
|
||||
if (rows.length > 0) {
|
||||
const merged = new Map(selectedProducts.value)
|
||||
for (const row of rows) merged.set(row.id, row)
|
||||
selectedProducts.value = merged
|
||||
}
|
||||
productTotal.value = typeof vo.total === 'number' ? vo.total : 0
|
||||
// 终止按「累计行数对撞 total」判,不按「本页满不满 100」判:服务端若收窄每页条数,
|
||||
// 满页判据会把第 1 页当末页漏掉后面全部商品。
|
||||
fetched += rows.length
|
||||
if (rows.length === 0 || fetched >= productTotal.value) break
|
||||
}
|
||||
} catch (err) {
|
||||
if (request === productRequest) {
|
||||
errorMessage.value = err instanceof Error ? err.message : '商品列表拉取失败,请稍后重试'
|
||||
errorMessage.value = err instanceof Error ? err.message : '分类商品读取失败,请稍后重试'
|
||||
}
|
||||
} finally {
|
||||
if (request === productRequest) productsLoading.value = false
|
||||
@@ -159,14 +150,6 @@ async function loadProducts() {
|
||||
}
|
||||
|
||||
function changeGroup() {
|
||||
productPage.value = 1
|
||||
productTotal.value = 0
|
||||
clearSelection()
|
||||
void loadProducts()
|
||||
}
|
||||
|
||||
function changePage(page: number) {
|
||||
productPage.value = page
|
||||
void loadProducts()
|
||||
}
|
||||
|
||||
@@ -207,8 +190,10 @@ const shopGuard = computed(() => evaluateShopGuard(selectedProductRows.value, cu
|
||||
/** 本机发布协议代次(0=读不到/老客户端;品牌要 ≥3、跨店要 ≥4,见 jd-publish-shop 常量)。 */
|
||||
const localProtocol = ref(0)
|
||||
const crossSupported = computed(() => localProtocol.value >= JD_PUBLISH_CROSS_PROTOCOL)
|
||||
/** 异店=跨店上架:目标店就是京麦当前登录店(服务端据此算 publishMode=NEW)。 */
|
||||
const usesCrossShop = computed(() => shopGuard.value.state === 'cross')
|
||||
/** 异店=跨店上架:目标店就是京麦当前登录店(服务端据此算 publishMode=NEW)。
|
||||
* 多店已检测=同一档(2026-11-26 晚「去掉一次只能发一家店的约束」):整单在京麦登录店新增。 */
|
||||
const usesCrossShop = computed(() => shopGuard.value.state === 'cross'
|
||||
|| (shopGuard.value.state === 'multi' && shopGuard.value.target != null))
|
||||
/** 跨店必须人工确认一次(会在目标店新建商品、要过京东审核),勾选或店铺变化即重置。 */
|
||||
const crossConfirmed = ref(false)
|
||||
watch(shopGuard, () => { crossConfirmed.value = false })
|
||||
@@ -225,7 +210,7 @@ async function readPublishProtocol(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 来源店铺文案:没取到/多家店/单店三档(多店由 shopGuard 直接拦)。 */
|
||||
/** 来源店铺文案:没取到/多家店/单店三档(多店已检测时整单走跨店新增,不再拦)。 */
|
||||
const sourceShopText = computed(() => {
|
||||
const guard = shopGuard.value
|
||||
if (guard.state === 'unknown') return '未取到(旧商品数据没有店铺信息)'
|
||||
@@ -234,9 +219,11 @@ const sourceShopText = computed(() => {
|
||||
})
|
||||
|
||||
/** 跨店档的目标店文案(同店/未检测档为空,模板按它决定是否显示目标店行)。 */
|
||||
const crossTargetText = computed(() => (usesCrossShop.value && shopGuard.value.state === 'cross'
|
||||
? shopLabel(shopGuard.value.target)
|
||||
: ''))
|
||||
const crossTargetText = computed(() => {
|
||||
const guard = shopGuard.value
|
||||
const target = guard.state === 'cross' || guard.state === 'multi' ? guard.target : null
|
||||
return usesCrossShop.value && target ? shopLabel(target) : ''
|
||||
})
|
||||
|
||||
const currentShopText = computed(() => (currentShop.value ? shopLabel(currentShop.value) : '未检测'))
|
||||
|
||||
@@ -761,8 +748,13 @@ async function startPublish() {
|
||||
errorMessage.value = shopIssue
|
||||
return
|
||||
}
|
||||
const targetShop = shopGuard.value.state === 'cross'
|
||||
? { shopId: shopGuard.value.target.shopId, shopName: shopGuard.value.target.shopName }
|
||||
// 跨店与「多店已检测」同档:目标店=京麦当前登录店,服务端据此算 publishMode=NEW。
|
||||
const guardForCreate = shopGuard.value
|
||||
const createTarget = guardForCreate.state === 'cross' || guardForCreate.state === 'multi'
|
||||
? guardForCreate.target
|
||||
: null
|
||||
const targetShop = createTarget
|
||||
? { shopId: createTarget.shopId, shopName: createTarget.shopName }
|
||||
: undefined
|
||||
const vo = targetShop
|
||||
? await createJdPublishTask(categoryId, productIds, priceRule, brand, targetShop)
|
||||
@@ -825,7 +817,7 @@ onUnmounted(() => {
|
||||
<router-link class="tool-head__back" :to="backHref">← 返回京东工具台</router-link>
|
||||
<span class="tool-head__title">商品上架</span>
|
||||
<span class="tool-head__desc">
|
||||
把京东数据库里的商品批量上架到京麦店铺:选分类、勾商品、可选统一改价,本机已登录京麦的客户端逐个发布。
|
||||
把京东数据库里的商品批量上架到京麦店铺:选分类即整分类上架、可选统一改价,本机已登录京麦的客户端逐个发布。
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -851,9 +843,11 @@ onUnmounted(() => {
|
||||
<span class="shop-line__value">{{ crossTargetText }}</span>
|
||||
</p>
|
||||
<p v-if="shopError" class="shop-alert">{{ shopError }}</p>
|
||||
<p v-else-if="shopGuard.state === 'multi'" class="shop-alert">{{ shopGuard.message }}</p>
|
||||
<p v-else-if="shopGuard.state === 'cross' && !crossSupported" class="shop-alert">{{ CROSS_UPGRADE_NOTICE }}</p>
|
||||
<template v-else-if="shopGuard.state === 'cross'">
|
||||
<!-- 多店还没检测:先点检测(没有目标店服务端也会拒)。 -->
|
||||
<p v-else-if="shopGuard.state === 'multi' && !shopGuard.target" class="shop-alert">{{ shopGuard.message }}</p>
|
||||
<!-- 跨店与多店同档:协议不够给升级提示,够则琥珀说明+人工确认。 -->
|
||||
<p v-else-if="(shopGuard.state === 'cross' || shopGuard.state === 'multi') && !crossSupported" class="shop-alert">{{ CROSS_UPGRADE_NOTICE }}</p>
|
||||
<template v-else-if="shopGuard.state === 'cross' || shopGuard.state === 'multi'">
|
||||
<p class="shop-alert shop-alert--cross">{{ shopGuard.message }}</p>
|
||||
<label class="shop-cross-confirm">
|
||||
<input v-model="crossConfirmed" type="checkbox" />
|
||||
@@ -880,42 +874,22 @@ onUnmounted(() => {
|
||||
:label="`${group.name}(${group.productCount ?? 0} 个商品)`" :value="group.id" />
|
||||
</el-select>
|
||||
<p v-if="groupsEmpty" class="category-hint category-hint--warn">{{ GROUPS_EMPTY_HINT_TEXT }}</p>
|
||||
<p v-else class="category-hint">分类由管理员在后台「京东数据库」维护;列表显示你可见分类下的商品(同组同事采集的也能上架)。</p>
|
||||
<p v-else class="category-hint">分类由管理员在后台「京东数据库」维护;选中分类即整分类上架,自动纳入你可见分类下的全部商品(同组同事采集的也能上架)。</p>
|
||||
</div>
|
||||
|
||||
<!-- 选品摘要(客户口径「商品信息不要显示,选分类上架就行」):选中分类=整分类上架。 -->
|
||||
<div class="product-block" v-loading="productsLoading">
|
||||
<div class="product-head">
|
||||
<span class="category-label">选择商品(已选 {{ selectedProducts.size }} 个,跨页累计)</span>
|
||||
<label v-if="products.length" class="category-hint">
|
||||
<input type="checkbox" class="product-select-page" :checked="wholePageSelected"
|
||||
:indeterminate.prop="partOfPageSelected"
|
||||
@change="togglePage(($event.target as HTMLInputElement).checked)" />
|
||||
全选本页
|
||||
</label>
|
||||
<button v-if="selectedProducts.size" class="shop-cat-clear" type="button"
|
||||
@click="clearSelection">清空勾选</button>
|
||||
<span class="category-label">上架商品(本分类全部)</span>
|
||||
</div>
|
||||
<div v-if="!products.length && !productsLoading" class="product-empty">
|
||||
{{ selectedGroupId ? '该分类下暂无商品' : '请先选择分类' }}
|
||||
</div>
|
||||
<label v-for="product in products" :key="product.id" class="product-row">
|
||||
<input type="checkbox" class="product-check"
|
||||
:checked="selectedProducts.has(product.id)"
|
||||
@change="toggleProduct(product, ($event.target as HTMLInputElement).checked)" />
|
||||
<img v-if="product.mainImageUrl" class="product-thumb" :src="product.mainImageUrl" alt="" loading="lazy" />
|
||||
<span v-else class="product-thumb product-thumb--empty">无图</span>
|
||||
<span class="product-info">
|
||||
<span class="product-title">{{ product.title }}</span>
|
||||
<span class="product-meta">
|
||||
<template v-if="product.shopName">店铺 {{ product.shopName }} · </template>
|
||||
¥{{ product.priceMin ?? '-' }}<template v-if="product.priceMax && product.priceMax !== product.priceMin">~{{ product.priceMax }}</template>
|
||||
· 库存 {{ product.stockTotal ?? '-' }}<template v-if="product.skuCount"> · {{ product.skuCount }}个SKU</template>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<el-pagination v-if="productTotal > PRODUCT_PAGE_SIZE" class="product-pager" layout="prev, pager, next"
|
||||
:total="productTotal" :page-size="PRODUCT_PAGE_SIZE" :current-page="productPage"
|
||||
@current-change="changePage" />
|
||||
<div v-if="!selectedGroupId" class="product-empty">请先选择分类</div>
|
||||
<p v-else-if="productsLoading && selectedProducts.size === 0" class="category-hint">
|
||||
正在读取本分类商品…
|
||||
</p>
|
||||
<div v-else-if="selectedProducts.size === 0" class="product-empty">该分类下暂无商品</div>
|
||||
<p v-else class="category-hint">
|
||||
已纳入本分类全部 {{ selectedProducts.size }} 个商品,点下方按钮整批上架(不再逐个勾选)。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="category-block">
|
||||
@@ -940,7 +914,7 @@ onUnmounted(() => {
|
||||
<button class="collect-btn" type="button" :disabled="submitDisabled" @click="startPublish">
|
||||
{{ submitting ? '创建中…' : (usesCrossShop
|
||||
? `跨店上架 ${selectedProducts.size} 个商品到目标店`
|
||||
: `上架已选 ${selectedProducts.size} 个商品`) }}
|
||||
: `上架本分类 ${selectedProducts.size} 个商品`) }}
|
||||
</button>
|
||||
|
||||
<p class="collect-hint">
|
||||
@@ -1037,18 +1011,7 @@ onUnmounted(() => {
|
||||
.product-block { margin-bottom: 16px; }
|
||||
.product-head { display: flex; align-items: center; justify-content: space-between; }
|
||||
.product-head .category-label { margin-bottom: 8px; }
|
||||
.product-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px; border: 1px solid #2c3547; border-radius: 8px; background: #20283a; cursor: pointer; }
|
||||
.product-row:hover { border-color: #3e4a62; }
|
||||
.product-check { flex-shrink: 0; width: 15px; height: 15px; accent-color: #e1251b; cursor: pointer; }
|
||||
.product-thumb { flex-shrink: 0; width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #232b3d; }
|
||||
.product-thumb--empty { display: inline-flex; align-items: center; justify-content: center; color: #5f6c85; font-size: 11px; }
|
||||
.product-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
||||
.product-title { color: #d9e1ef; font-size: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.product-meta { color: #8a97ad; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.product-empty { padding: 18px 0; color: #5f6c85; font-size: 12px; text-align: center; }
|
||||
.product-pager { margin-top: 8px; justify-content: center; }
|
||||
.product-pager :deep(.el-pager li), .product-pager :deep(.btn-prev), .product-pager :deep(.btn-next) { background: transparent; color: #c8d2e2; }
|
||||
.product-pager :deep(.el-pager li.is-active) { color: #6ea8ff; }
|
||||
.target-brand-input { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 1px solid #3e4a62; border-radius: 6px; background: #232b3d; color: #c8d2e2; font: inherit; }
|
||||
.target-brand-input[aria-invalid="true"] { border-color: #fca5a5; }
|
||||
.price-input { width: 100%; margin-top: 8px; }
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
* 是哪一个店铺?」;2026-11-26 客户口径「要跨店」后判据从「必须同店」改成「同店与跨店都行」)。
|
||||
*
|
||||
* 三份身份,各有唯一出处,三层同一标记:
|
||||
* 1. **来源店铺**=所勾商品行的 `shopName/shopId`(京东数据库快照)。服务端建单时按它做
|
||||
* 「一单只能发到一家店」校验(`JdPublishTaskService.resolveSingleShop`),并把它钉进
|
||||
* 任务载荷与明细下发(`JdPublishItemsPageVo.shopId/shopName`);
|
||||
* 1. **来源店铺**=上架集商品行(2026-11-26 晚起=所选分类全部商品行)的 `shopName/shopId`
|
||||
* (京东数据库快照)。服务端建单时按它归一
|
||||
* 发布模式(`JdPublishTaskService.resolveSourceShops`:单店可克隆、异店/多店整单走新增;
|
||||
* 2026-11-26 晚客户口径「去掉一次只能发一家店的约束」后多店不再整单拒绝),
|
||||
* 单店时钉进任务载荷、多店时只有明细行各带来源店(`JdPublishItemsPageVo.shopId/shopName`);
|
||||
* 2. **京麦当前登录店铺**=桥 `get_jd_shop_info` 现拉(客户端起有头浏览器读京麦首屏),
|
||||
* 不是页面缓存、也不是上次「同步分类」的残留;跨店时它就是**目标店**(服务端据此算
|
||||
* `publishMode=NEW`,客户端走京麦「新增商品」路径);
|
||||
@@ -47,8 +49,12 @@ export type JdShopGuard =
|
||||
| { state: 'match'; expected: JdShopRef; actual: JdShopRef }
|
||||
/** 京麦登录的不是来源店 ⇒ 跨店上架(目标店=京麦当前登录店,走新增商品路径) */
|
||||
| { state: 'cross'; expected: JdShopRef; target: JdShopRef; message: string }
|
||||
/** 勾选的商品来自多家店 ⇒ 服务端也会拒(按店分开勾) */
|
||||
| { state: 'multi'; shops: JdShopRef[]; message: string }
|
||||
/**
|
||||
* 勾选的商品来自多家店(2026-11-26 晚客户口径「去掉一次只能发一家店的约束」):
|
||||
* 已检测京麦 ⇒ 整单按跨店新增放行(目标店=京麦登录店,服务端 publishMode=NEW,
|
||||
* 与 cross 档同样要协议 ≥4 与人工确认);未检测 ⇒ 拦(建单没有目标店,服务端也会拒)。
|
||||
*/
|
||||
| { state: 'multi'; shops: JdShopRef[]; target: JdShopRef | null; message: string }
|
||||
|
||||
function text(value: unknown): string {
|
||||
return String(value ?? '').trim()
|
||||
@@ -108,10 +114,19 @@ export function crossShopMessage(source: JdShopRef | null | undefined, target: J
|
||||
+ '否则该商品会按「目标店没有授权类目」逐行失败。')
|
||||
}
|
||||
|
||||
/** 跨店勾选整句(与服务端建单拒绝文案同口径:按店分开勾)。 */
|
||||
export function multiShopMessage(shops: ReadonlyArray<JdShopRef>): string {
|
||||
/** 多店已检测京麦:整单跨店新增的说明句(与服务端 NEW 档口径一致)。 */
|
||||
export function multiShopCrossMessage(shops: ReadonlyArray<JdShopRef>, target: JdShopRef): string {
|
||||
const labels = shops.map((shop) => shopLabel(shop)).join('、')
|
||||
return `本次勾选的商品来自多个店铺(${labels}),一次上架只能发到一家店,请按店铺分开勾选。`
|
||||
return (`本次勾选的商品来自多个店铺(${labels}),将全部在京麦当前登录的「${shopLabel(target)}」`
|
||||
+ '以「新增商品」方式新建上架(与各来源店的商品各自独立,需京东审核通过后才上架);'
|
||||
+ '目标店须已授权各商品的类目,否则按「目标店没有授权类目」逐行失败。')
|
||||
}
|
||||
|
||||
/** 多店还没检测京麦:先检测的指引句(不带目标店建单服务端也会拒)。 */
|
||||
export function multiShopDetectMessage(shops: ReadonlyArray<JdShopRef>): string {
|
||||
const labels = shops.map((shop) => shopLabel(shop)).join('、')
|
||||
return (`本次勾选的商品来自多个店铺(${labels}):多店商品只能整单在京麦当前登录店铺`
|
||||
+ '以新增商品方式上架,请先点「检测京麦店铺」确认登录店后再建单。')
|
||||
}
|
||||
|
||||
/** true/false=能比;null=两边都缺可比字段(只认同一维度:id 对 id、名对名)。 */
|
||||
@@ -127,10 +142,17 @@ export function evaluateShopGuard(
|
||||
detected: JdShopRef | null | undefined,
|
||||
): JdShopGuard {
|
||||
const refs = sourceShopRefs(products)
|
||||
if (refs.length > 1) return { state: 'multi', shops: refs, message: multiShopMessage(refs) }
|
||||
const actual = normalizeShopRef(detected)
|
||||
if (refs.length > 1) {
|
||||
return {
|
||||
state: 'multi',
|
||||
shops: refs,
|
||||
target: actual,
|
||||
message: actual ? multiShopCrossMessage(refs, actual) : multiShopDetectMessage(refs),
|
||||
}
|
||||
}
|
||||
const expected = refs[0]
|
||||
if (!expected) return { state: 'unknown' }
|
||||
const actual = normalizeShopRef(detected)
|
||||
if (!actual) return { state: 'undetected', expected }
|
||||
const same = sameShop(expected, actual)
|
||||
// 比不了(一边只有店名、另一边只有 id)不判不匹配:宁可留给客户端强拦截,也不误拦真实任务。
|
||||
@@ -140,16 +162,20 @@ export function evaluateShopGuard(
|
||||
}
|
||||
|
||||
/**
|
||||
* UI 唯一处断:多店必拦;跨店档默认拦(本机不支持跨店=协议 < 4),
|
||||
* ``crossAllowed`` 为真时放行(客户端会走新增商品路径)。
|
||||
* UI 唯一处断:跨店与「多店已检测」档默认拦(本机不支持跨店=协议 < 4),
|
||||
* ``crossAllowed`` 为真时放行(客户端会走新增商品路径);
|
||||
* 多店还没检测京麦必拦(建单没有目标店,服务端也会拒)。
|
||||
*/
|
||||
export function shopGuardBlocks(guard: JdShopGuard, crossAllowed = false): boolean {
|
||||
if (guard.state === 'cross') return !crossAllowed
|
||||
return guard.state === 'multi'
|
||||
if (guard.state === 'multi') return !guard.target || !crossAllowed
|
||||
return false
|
||||
}
|
||||
|
||||
/** 拦截文案(空串=可建单):跨店档在协议不够时给升级提示,见 ``CROSS_UPGRADE_NOTICE``。 */
|
||||
/** 拦截文案(空串=可建单):协议不够时给升级提示,见 ``CROSS_UPGRADE_NOTICE``。 */
|
||||
export function shopGuardMessage(guard: JdShopGuard, crossAllowed = false): string {
|
||||
if (guard.state === 'cross') return crossAllowed ? '' : CROSS_UPGRADE_NOTICE
|
||||
return guard.state === 'multi' ? guard.message : ''
|
||||
if (guard.state !== 'multi') return ''
|
||||
if (!guard.target) return guard.message
|
||||
return crossAllowed ? '' : CROSS_UPGRADE_NOTICE
|
||||
}
|
||||
@@ -3,7 +3,8 @@
|
||||
*
|
||||
* 一级入口在桌面首页(与「亚马逊 / 视频」并列,见 DesktopHomePage),进来后是这两个菜单:
|
||||
* 1. 获取店铺数据:一键抓已登录京麦后台的店铺商品(列表 + 详情 + 图片),落后台「京东数据库」;
|
||||
* 2. 商品上架(v1.5 Phase 4 转正式):选自定义分类勾商品建单,本机已登录京麦的客户端逐个发布;
|
||||
* 2. 商品上架(v1.5 Phase 4 转正式;2026-11-26 晚客户口径「选分类上架就行」):
|
||||
* 选自定义分类=整分类建单,本机已登录京麦的客户端逐个发布;
|
||||
*
|
||||
* 卡片形状照亚马逊工具台(tool-catalog.ts)的 ToolInfo,样式复用同一套深色卡片墙。
|
||||
*
|
||||
@@ -44,7 +45,7 @@ export const JD_TOOLS: ReadonlyArray<JdToolInfo> = [
|
||||
{
|
||||
id: 'jd-publish',
|
||||
name: '商品上架',
|
||||
desc: '把京东数据库里你自己的商品批量上架到京麦店铺:选分类、勾商品、可选统一改价,本机客户端逐个发布',
|
||||
desc: '把京东数据库里你自己的商品批量上架到京麦店铺:选分类即整分类上架、可选统一改价,本机客户端逐个发布',
|
||||
tag: '核心',
|
||||
href: '/jd-publish',
|
||||
permissionKeys: ['jd-publish'],
|
||||
|
||||
@@ -122,7 +122,10 @@ const BASELINE = {
|
||||
// load(在架清单读取失败 → ElMessage.error 报原文,面板清空不显旧数)与 markDelisted
|
||||
// (标记失败 → ElMessage.error 透出服务端原文,跨团队 403 等;确认框取消走 reject 两臂
|
||||
// 不新增 catch)各一支,都有用户可见出口,silent 一格没涨、perFile 无新增条目,只进 blocks。
|
||||
blocks: 338,
|
||||
// 339 = 338 + 1(2026-11-26 晚「选分类=整分类上架」):JdPublishTab.vue 的 loadProducts 一支
|
||||
// try/catch——分页拉全分类商品失败 → errorMessage 写进页面红色反馈,换分类竞态由 request
|
||||
// 令牌作废、失败不静默半截上架集。非静默:silent 一格没涨、perFile 无新增条目,只进 blocks。
|
||||
blocks: 339,
|
||||
// 2026-10-30(ops Phase 6/可读棘轮):ApiSecretSettingsPanel.vue 1113→775 行,面板里那处
|
||||
// 静默 catch(余额查询失败只 console.warn、界面留空)随 loadBalance 整块搬进
|
||||
// useProxyPlan.ts。不是新增静默:面板 1→0、新文件记 1,silent 总数与 blocks 都一格没动,
|
||||
|
||||
@@ -60,7 +60,7 @@ test('来源店铺按 id 去重、同名单店归一、空值全部丢弃', () =
|
||||
})
|
||||
|
||||
test('同一家店两种形状(只有 id / 只有店名)在来源集里能归一', () => {
|
||||
// id 口径优先:一行有 id 一行只有名字时,页面无法确定同店,按两家报出来让用户分开勾
|
||||
// id 口径优先:一行有 id 一行只有名字时,页面无法确定同店,按两家报出(多店整单走跨店新增)
|
||||
const refs = sourceShopRefs([{ shopId: '1' }, { shopName: '某店' }])
|
||||
assert.equal(refs.length, 2)
|
||||
})
|
||||
@@ -126,14 +126,33 @@ test('只有店名时按店名比对;比不了(一边只有 id)按未检
|
||||
assert.equal(evaluateShopGuard([{ shopId: '1' }], { shopName: '某店' }).state, 'undetected')
|
||||
})
|
||||
|
||||
test('跨店勾选直接拦,文案与服务端建单拒绝同口径(按店分开勾)', () => {
|
||||
// 2026-11-26 晚客户口径「去掉一次只能发一家店的约束」:多店不再整单拦死。
|
||||
test('多店未检测京麦:拦并点名两家店与「先检测」动作(没有目标店服务端也会拒)', () => {
|
||||
const guard = evaluateShopGuard([{ shopId: '1', shopName: '甲店' }, { shopId: '2', shopName: '乙店' }], null)
|
||||
assert.equal(guard.state, 'multi')
|
||||
if (guard.state === 'multi') assert.equal(guard.target, null)
|
||||
assert.ok(shopGuardBlocks(guard))
|
||||
assert.ok(shopGuardMessage(guard).includes('甲店') && shopGuardMessage(guard).includes('乙店'))
|
||||
assert.ok(shopGuardMessage(guard).includes('检测'))
|
||||
assert.ok(!shopGuardMessage(guard).includes('分开勾选'), '旧「按店分开勾选」口径不得复活')
|
||||
})
|
||||
|
||||
test('多店已检测京麦:整单按跨店新增放行(协议 ≥4+人工确认),文案点名各来源店与目标店', () => {
|
||||
const guard = evaluateShopGuard(
|
||||
[{ shopId: '1', shopName: '甲店' }, { shopId: '2', shopName: '乙店' }],
|
||||
{ shopId: '3', shopName: '丙店' },
|
||||
)
|
||||
assert.equal(guard.state, 'multi')
|
||||
if (guard.state === 'multi') {
|
||||
assert.ok(guard.message.includes('甲店') && guard.message.includes('乙店'))
|
||||
assert.ok(guard.message.includes('分开勾选'))
|
||||
assert.deepEqual(guard.target, { shopId: '3', shopName: '丙店' }, '目标店=京麦当前登录店')
|
||||
assert.ok(guard.message.includes('甲店') && guard.message.includes('乙店') && guard.message.includes('丙店'))
|
||||
assert.ok(guard.message.includes('新增'), '必须说清多店是在目标店以新增商品方式上架')
|
||||
assert.ok(guard.message.includes('授权') && guard.message.includes('审核'))
|
||||
}
|
||||
assert.ok(shopGuardBlocks(guard), '协议 < 4 仍拦:老客户端没有新增商品路径')
|
||||
assert.equal(shopGuardMessage(guard), CROSS_UPGRADE_NOTICE)
|
||||
assert.ok(!shopGuardBlocks(guard, true), '协议 ≥4 放行(建单前还要页面二次确认,那是页面层硬闸)')
|
||||
assert.equal(shopGuardMessage(guard, true), '')
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------- 菜单权限判据
|
||||
@@ -161,7 +180,8 @@ test('上架页显形来源店铺与京麦当前店铺,并在建单前核对',
|
||||
assert.ok(tab.includes('get_jd_shop_info'), '页面必须调桥 get_jd_shop_info 现拉京麦当前店铺')
|
||||
assert.ok(tab.includes('ensureShopChecked'), '建单前必须走店铺核对(strong block)')
|
||||
assert.ok(tab.includes('shopGuardBlocks'), '不匹配/跨店必须禁掉上架按钮')
|
||||
assert.ok(tab.includes('product.shopName'), '商品行要显形自己的来源店铺')
|
||||
assert.ok(tab.includes('evaluateShopGuard(selectedProductRows'),
|
||||
'来源店铺判据必须吃本分类全部商品行(2026-11-26 晚选分类=整分类上架,不再只吃被勾选的行)')
|
||||
const createAt = tab.indexOf('createJdPublishTask(')
|
||||
const checkAt = tab.indexOf('await ensureShopChecked()')
|
||||
assert.ok(checkAt > 0 && createAt > checkAt, '核对必须早于建单')
|
||||
|
||||
@@ -95,3 +95,19 @@ test('分类空态文案单出口:判据 computed+两常量定义存在,
|
||||
assert.ok(tab.includes('{{ GROUPS_EMPTY_HINT_TEXT }}') && tab.includes(':empty-text="groupsEmpty ? GROUPS_EMPTY_DROPDOWN_TEXT'),
|
||||
'模板两处都必须引用常量——内联第二份文案就是口径漂移的开始')
|
||||
})
|
||||
|
||||
// -------------------------------------------------- 选分类=整分类上架(2026-11-26 晚客户口径「商品信息不要显示」)
|
||||
|
||||
test('选分类自动拉全:大页码分页+累计行数对撞 total+令牌作废在飞循环,商品明细 UI 不得残留', () => {
|
||||
const tab = read('src/pages/jd/JdPublishTab.vue', '商品上架页')
|
||||
assert.ok(tab.includes('PRODUCT_FETCH_PAGE_SIZE'), '选分类必须自动分页拉全(大页码),不得只拉第 1 页')
|
||||
assert.ok(tab.includes('fetched >= productTotal.value'),
|
||||
'终止按「累计行数对撞 total」判,不按「本页满不满」判——服务端收窄每页条数时满页判据会把第 1 页当末页')
|
||||
assert.ok(tab.includes('request !== productRequest'),
|
||||
'换分类/重拉必须作废在飞循环:迟到的旧分类商品绝不进新分类建单')
|
||||
for (const gone of ['class="product-check"', 'class="product-pager"', 'class="product-select-all"',
|
||||
'全选本页', '清空勾选', '跨页累计']) {
|
||||
assert.ok(!tab.includes(gone), `商品明细 UI 不得残留「${gone}」:客户口径=选分类上架就行`)
|
||||
}
|
||||
assert.ok(tab.includes('该分类下暂无商品'), '分类空态文案必须保留(整分类口径下这是唯一「没货」信号)')
|
||||
})
|
||||
|
||||
@@ -75,8 +75,8 @@ async function mountPage() {
|
||||
}
|
||||
|
||||
async function startPublish(page: VueWrapper, brand = ' 示例品牌 ') {
|
||||
// 2026-11-26 晚客户口径「商品信息不要显示,选分类上架就行」:选中分类即整分类上架,无逐行勾选步骤。
|
||||
await page.get('.target-brand-input').setValue(brand)
|
||||
await page.get<HTMLInputElement>('.product-check').setValue(true)
|
||||
await page.get('.collect-btn').trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
@@ -152,7 +152,7 @@ it.each(['没有入队方法', '队列拒绝', '桥异常', '没有服务端载
|
||||
expect(page.text()).not.toContain('queue rejected')
|
||||
})
|
||||
|
||||
it('切换分类后迟到的旧商品列表不能再参与勾选', async () => {
|
||||
it('切换分类后迟到的旧商品列表不能再参与上架', async () => {
|
||||
api.groups.mockResolvedValue([{ id: 12, name: '原分类' }, { id: 13, name: '新分类' }])
|
||||
let resolveOld!: (data: { items: { id: number, title: string }[], total: number }) => void
|
||||
api.products.mockImplementationOnce(() => new Promise((resolve) => { resolveOld = resolve }))
|
||||
@@ -164,25 +164,30 @@ it('切换分类后迟到的旧商品列表不能再参与勾选', async () => {
|
||||
await flushPromises()
|
||||
resolveOld({ items: [{ id: 23, title: '旧分类商品' }], total: 1 })
|
||||
await flushPromises()
|
||||
expect(page.get('.product-title').text()).toBe('新分类商品')
|
||||
// 摘要只认新分类的 1 件;旧分类迟到结果被 request 令牌作废,绝不并进上架集。
|
||||
expect(page.text()).toContain('已纳入本分类全部 1 个商品')
|
||||
await startPublish(page)
|
||||
expect(api.create).toHaveBeenCalledExactlyOnceWith(13, [24], { mode: 'none' }, '示例品牌')
|
||||
})
|
||||
|
||||
it('全选和取消只影响本页,其他页勾选保留', async () => {
|
||||
api.products.mockResolvedValueOnce({ items: [{ id: 23, title: '第一页商品' }], total: 13 })
|
||||
api.products.mockResolvedValueOnce({ items: [{ id: 24, title: '第二页商品' }], total: 13 })
|
||||
it('选分类=自动分页拉全本分类全部商品并整批建单,商品行/分页器不再渲染(2026-11-26 客户口径「商品信息不要显示」)', async () => {
|
||||
api.products
|
||||
.mockResolvedValueOnce({ items: [{ id: 23, title: '甲' }], total: 3 })
|
||||
.mockResolvedValueOnce({ items: [{ id: 24, title: '乙' }, { id: 25, title: '丙' }], total: 3 })
|
||||
const page = await mountPage()
|
||||
await page.get('.product-select-page').setValue(true)
|
||||
page.getComponent('.product-pager').vm.$emit('current-change', 2)
|
||||
await flushPromises()
|
||||
await page.get('.product-select-page').setValue(true)
|
||||
expect(page.get('.collect-btn').text()).toContain('2 个商品')
|
||||
await page.get('.product-select-page').setValue(false)
|
||||
await flushPromises()
|
||||
expect(api.products).toHaveBeenNthCalledWith(1, 12, 1, 100)
|
||||
expect(api.products).toHaveBeenNthCalledWith(2, 12, 2, 100)
|
||||
expect(page.text()).toContain('已纳入本分类全部 3 个商品')
|
||||
expect(page.find('.product-check').exists()).toBe(false)
|
||||
expect(page.find('.product-pager').exists()).toBe(false)
|
||||
expect(page.find('.product-select-all').exists()).toBe(false)
|
||||
expect(page.get('.collect-btn').text()).toContain('上架本分类 3 个商品')
|
||||
await page.get('.target-brand-input').setValue('示例品牌')
|
||||
await page.get('.collect-btn').trigger('click')
|
||||
await flushPromises()
|
||||
expect(api.create).toHaveBeenCalledExactlyOnceWith(12, [23], { mode: 'none' }, '示例品牌')
|
||||
expect(api.create).toHaveBeenCalledExactlyOnceWith(12, [23, 24, 25], { mode: 'none' }, '示例品牌')
|
||||
})
|
||||
|
||||
it('原位重试只由兜底认领,迟到的旧代终态不能停掉轮询或弹窗', async () => {
|
||||
@@ -385,8 +390,7 @@ it('协议 3 的本机遇跨店只给升级提示,一条都不建单', async (
|
||||
api.protocol.mockResolvedValue(3)
|
||||
const page = await mountPage()
|
||||
await page.get('.target-brand-input').setValue('示例品牌')
|
||||
await page.get<HTMLInputElement>('.product-check').setValue(true)
|
||||
// 勾选后未检测:不拦,点下去才开始核对
|
||||
// 未检测:不拦,点下去才开始核对(选分类即整分类上架,无逐行勾选步骤)
|
||||
expect(page.get<HTMLButtonElement>('.collect-btn').element.disabled).toBe(false)
|
||||
await page.get('.collect-btn').trigger('click')
|
||||
await flushPromises()
|
||||
@@ -403,7 +407,6 @@ it('协议 4 跨店:显形目标店与风险句,确认后才建单并带目
|
||||
api.protocol.mockResolvedValue(4)
|
||||
const page = await mountPage()
|
||||
await page.get('.target-brand-input').setValue('示例品牌')
|
||||
await page.get<HTMLInputElement>('.product-check').setValue(true)
|
||||
await page.get('.shop-detect-btn').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
@@ -443,7 +446,6 @@ it('检测过且一致后不再重复起浏览器', async () => {
|
||||
})
|
||||
withShopBridge({ success: true, shopId: '228346061', shopName: '家居日用数据库店' })
|
||||
const page = await mountPage()
|
||||
await page.get<HTMLInputElement>('.product-check').setValue(true)
|
||||
await page.get('.shop-detect-btn').trigger('click')
|
||||
await flushPromises()
|
||||
expect(api.shop).toHaveBeenCalledOnce()
|
||||
@@ -481,3 +483,4 @@ it('分类非空时不出空态告警(v-if 不成立,原静态说明照旧
|
||||
expect(page.find('.category-hint--warn').exists()).toBe(false)
|
||||
expect(page.text()).toContain('分类由管理员在后台「京东数据库」维护')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user