feat(jd额度): 上架额度改按在架商品数计+管理员向员工分配额度闸+在架商品面板
客户口径(2026-11-25):「上限=同时在架商品数,下架 10 个就能再上架 10 个换着卖」+
「管理员下的普通员工总和也不能超过这个上限」。
后端
- 计数正本从 biz_jd_product 占有行数迁到 biz_jd_publish_item:发布成功(SUCCESS)
且未标记下架(delisted_at IS NULL)的去重商品数(DISTINCT product_id,同商品跨任务
重复发布只占一位)。旧 JdProductMapper#countByUserIds 整条删除——口径源只能一份。
- V216 给发布明细加 delisted_at(NULL=在架);V217 把普通账号存量默认 5000 清 0
(0=未分配,分配闸上线的前置清账)。
- JdPublishQuotaService:quotaOf 读数换正本;assertWithinQuota 改收勾选商品集,
批内已在架的不双计(重复上架不重复占位)。
- 新增 JdPublishOnShelfService+/api/jd-publish/on-shelf(团队在架分页+余量,读数与
建单闸同一正本)与 /api/jd-publish/items/{itemId}/delisted(标记/撤销按商品整组回写,
跨团队 403;京麦下架执行链自动回流记欠账)。
- AdminUserService 新增分配闸:Σ(直接下属非零额度,被编辑账号取新值) ≤ 锚点额度;
站超管/锚点 0=不限放行;旧 400「只能为管理员设置额度」废止。新增
/api/admin/user/{uid}/jd-quota 只读快照(编辑弹窗展示「当前在架 X/上限 Y」)。
后管
- 编辑弹窗额度项改为「京东侧+操作者写权」即出(普通账号也可分配),带当前在架读数
(读不到只显一句失败话,不挡保存);列表「上架上限」列 0 按档显「不限」/「未分配」;
普通账号回填缺省 0(避免「打开就保存」凭空分配额度)。展示规则单出口 user-edit-model。
用户端
- 新增在架商品面板(JdOnShelfPanel):余量读数、空态、满额提醒、标记已下架确认与回执
文案单出口 jd-on-shelf.ts;endpoints 快照同步 onShelf/markDelisted。
判据
- 后端:JdPublishQuotaServiceTest 11、JdPublishOnShelfServiceTest 8、
JdPublishOnShelfSqlTest 3(三条 SQL 谓词逐字钉:SUCCESS+delisted_at IS NULL+DISTINCT)、
AdminUserServiceCompanySuperAdminTest +5(Σ 闸四态)、JdSchemaContractTest 钉 V216/V217、
两条 SQL 台账(XML_SELECT_TOTAL 109→111、XML_STATEMENT_TOTAL 156→158)逐条点名。
- 后管:jd-publish-quota-edit.test.ts 3(含 0 语义分档与「绝不拼/0」)、
platform-account-pages 源码钉子改钉新形状、source-pin 台账 cases 1867→1868 逐条点名。
- 用户端:jd-on-shelf.test.ts 纯函数+mount 面板判据;catch-silence 台账 blocks 336→338 点名。
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
fetchJdOnShelf,
|
||||
markJdItemDelisted,
|
||||
type JdOnShelfItemVo,
|
||||
type JdOnShelfPageVo,
|
||||
} from '@/shared/api/types/modules/jd-publish'
|
||||
import {
|
||||
clampPageSize,
|
||||
markButtonLabel,
|
||||
markDelistedNotice,
|
||||
onShelfEmptyText,
|
||||
quotaNearLimit,
|
||||
quotaReadoutText,
|
||||
} from './jd-on-shelf'
|
||||
import { formatDateTime } from '@/shared/utils/datetime'
|
||||
|
||||
/**
|
||||
* 在架商品面板(2026-11-25 客户口径「上限=同时在架商品数,下架 10 个就能再上 10 个」)。
|
||||
*
|
||||
* 京麦人工下架系统感知不到,本面板是「标记已下架腾额度」的唯一界面出口;
|
||||
* 余量读数 used/limit 与建单配额闸同一正本(服务端 JdPublishQuotaService),
|
||||
* 这里看到的和建单被拦的是同一个数。文案单出口在 jd-on-shelf.ts(判据同读)。
|
||||
* 团队口径:管理员=本人+名下员工(管理员可替员工标记),员工=所属管理员团队。
|
||||
*/
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
const open = ref(false)
|
||||
const loading = ref(false)
|
||||
const page = ref(1)
|
||||
const vo = ref<JdOnShelfPageVo | null>(null)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
vo.value = await fetchJdOnShelf(page.value, clampPageSize(PAGE_SIZE))
|
||||
} catch (error) {
|
||||
vo.value = null
|
||||
ElMessage.error(error instanceof Error ? error.message : '在架商品读取失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function togglePanel() {
|
||||
open.value = !open.value
|
||||
if (open.value && !vo.value) void load()
|
||||
}
|
||||
|
||||
async function changePage(next: number) {
|
||||
page.value = next
|
||||
await load()
|
||||
}
|
||||
|
||||
async function markDelisted(item: JdOnShelfItemVo) {
|
||||
// 确认框取消走 reject 两臂(与中断任务同口径,不新增 catch 块)
|
||||
const confirmed = await ElMessageBox.confirm(
|
||||
`确认把「${item.title || item.productCode || item.productId}」标记为已下架?`
|
||||
+ '标记后该商品不再占用上架额度;请确认它确已在京麦下架。',
|
||||
'标记已下架',
|
||||
{ type: 'warning', confirmButtonText: '标记已下架', cancelButtonText: '先不标记' },
|
||||
).then(
|
||||
() => true,
|
||||
() => false,
|
||||
)
|
||||
if (!confirmed) return
|
||||
try {
|
||||
await markJdItemDelisted(item.itemId, true)
|
||||
ElMessage.success(markDelistedNotice(item.productCode))
|
||||
await load()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '标记失败,请稍后重试')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="on-shelf" v-loading="loading">
|
||||
<div class="on-shelf-head">
|
||||
<button class="on-shelf-toggle" type="button" :aria-expanded="open" @click="togglePanel">
|
||||
{{ open ? '收起在架商品' : '展开在架商品' }}
|
||||
</button>
|
||||
<span class="on-shelf-quota">{{ vo ? quotaReadoutText(vo.used, vo.limit, vo.unlimited) : '余量读取中…' }}</span>
|
||||
<button class="on-shelf-refresh" type="button" :disabled="loading" @click="load()">刷新</button>
|
||||
</div>
|
||||
<p v-if="vo && quotaNearLimit(vo.used, vo.limit, vo.unlimited)" class="on-shelf-warn">
|
||||
额度已满:请先在京麦下架商品,并到本列表「标记已下架」腾出额度后再建单。
|
||||
</p>
|
||||
<div v-if="open" class="on-shelf-body">
|
||||
<div v-if="vo && !vo.items.length" class="on-shelf-empty">{{ onShelfEmptyText(vo.unlimited, vo.used) }}</div>
|
||||
<div v-for="item in vo?.items ?? []" :key="item.itemId" class="on-shelf-row">
|
||||
<img v-if="item.imageUrl" class="on-shelf-thumb" :src="item.imageUrl" alt="" loading="lazy" />
|
||||
<span v-else class="on-shelf-thumb on-shelf-thumb--empty">无图</span>
|
||||
<span class="on-shelf-info">
|
||||
<span class="on-shelf-title">{{ item.title || '(无标题快照)' }}</span>
|
||||
<span class="on-shelf-meta">
|
||||
<template v-if="item.productCode">编码 {{ item.productCode }} · </template>
|
||||
<template v-if="item.shopName">来源 {{ item.shopName }} · </template>
|
||||
上架 {{ item.listedAt ? formatDateTime(item.listedAt) : '-' }}
|
||||
</span>
|
||||
</span>
|
||||
<button class="on-shelf-mark" type="button" @click="markDelisted(item)">{{ markButtonLabel() }}</button>
|
||||
</div>
|
||||
<el-pagination v-if="vo && vo.total > PAGE_SIZE" class="on-shelf-pager" layout="prev, pager, next"
|
||||
:total="vo.total" :page-size="PAGE_SIZE" :current-page="page" @current-change="changePage" />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.on-shelf { flex-shrink: 0; margin: 0 0 12px; padding: 10px 14px; border: 1px solid #2c3547; border-radius: 8px; background: #20283a; }
|
||||
.on-shelf-head { display: flex; align-items: center; gap: 12px; }
|
||||
.on-shelf-toggle, .on-shelf-refresh { padding: 4px 12px; border: 1px solid #3e4a62; border-radius: 6px; background: transparent; color: #c8d2e2; font-size: 12px; cursor: pointer; }
|
||||
.on-shelf-quota { color: #e6edf7; font-size: 13px; }
|
||||
.on-shelf-warn { margin: 8px 0 0; color: #e6a23c; font-size: 12px; }
|
||||
.on-shelf-body { margin-top: 10px; }
|
||||
.on-shelf-empty { padding: 12px; color: #8b98af; font-size: 12px; text-align: center; }
|
||||
.on-shelf-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px; border: 1px solid #2c3547; border-radius: 8px; background: #1a2130; }
|
||||
.on-shelf-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
|
||||
.on-shelf-thumb--empty { display: inline-flex; align-items: center; justify-content: center; color: #5f6c85; font-size: 11px; background: #232c3e; }
|
||||
.on-shelf-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
||||
.on-shelf-title { color: #e6edf7; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.on-shelf-meta { color: #8b98af; font-size: 11px; }
|
||||
.on-shelf-mark { padding: 4px 12px; border: 1px solid #b45454; border-radius: 6px; background: transparent; color: #e08a8a; font-size: 12px; cursor: pointer; flex-shrink: 0; }
|
||||
.on-shelf-pager { justify-content: center; margin-top: 8px; }
|
||||
</style>
|
||||
@@ -2,6 +2,7 @@
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||
import JdOnShelfPanel from '@/pages/jd/JdOnShelfPanel.vue'
|
||||
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
||||
import jdLogo from '@/pages/home/assets/jd-logo.png'
|
||||
import {
|
||||
@@ -899,6 +900,7 @@ onUnmounted(() => {
|
||||
</aside>
|
||||
|
||||
<section class="right-panel">
|
||||
<JdOnShelfPanel />
|
||||
<TaskCenterPanel
|
||||
:on-batch-delete="batchDeleteHistory"
|
||||
:on-refresh="refreshBoard"
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 在架商品面板的纯函数层(2026-11-25 客户口径「上限=同时在架商品数,下架腾额度」)。
|
||||
*
|
||||
* 文案单出口纪律:余量读数、空态、标记按钮文案只在这里拼——面板与判据读同一份,
|
||||
* 回退(比如把「不限」拼成「0」)当场红。服务端 used/limit 与建单配额闸同一正本,
|
||||
* 本层只做展示换算,不做任何二次判定。
|
||||
*/
|
||||
|
||||
/** 余量读数:limit≤0(0=不限)显「不限」,绝不显「/0」这种像坏数的数字。 */
|
||||
export function quotaReadoutText(used: number, limit: number, unlimited: boolean): string {
|
||||
const safeUsed = Number.isFinite(used) && used > 0 ? Math.floor(used) : 0;
|
||||
if (unlimited || !Number.isFinite(limit) || limit <= 0) {
|
||||
return `当前在架 ${safeUsed}/不限`;
|
||||
}
|
||||
return `当前在架 ${safeUsed}/${Math.floor(limit)}`;
|
||||
}
|
||||
|
||||
/** 余量是否已到顶(到顶给琥珀提醒句,不硬拦——硬闸在服务端建单口)。 */
|
||||
export function quotaNearLimit(used: number, limit: number, unlimited: boolean): boolean {
|
||||
if (unlimited || !Number.isFinite(limit) || limit <= 0) return false;
|
||||
return used >= limit;
|
||||
}
|
||||
|
||||
/** 面板空态:额度未用满与用满两种口径分开说,别让人以为面板坏了。 */
|
||||
export function onShelfEmptyText(unlimited: boolean, used: number): string {
|
||||
if (used > 0) return '本页暂无更多在架商品,可翻页查看';
|
||||
return unlimited
|
||||
? '当前没有已上架商品;上架成功后的商品会出现在这里,并计入额度'
|
||||
: '当前没有已上架商品;额度只在商品上架成功后占用,采集入库不占';
|
||||
}
|
||||
|
||||
/** 标记按钮文案:delisted 态在面板里恒为「未下架」(已下架的行不进在架列表),撤销口用此文案。 */
|
||||
export function markButtonLabel(): string {
|
||||
return '标记已下架';
|
||||
}
|
||||
|
||||
/** 分页大小钳制:与后端 MAX_PAGE_SIZE=100 同口径,超了按 100 请求。 */
|
||||
export function clampPageSize(pageSize: number): number {
|
||||
if (!Number.isFinite(pageSize) || pageSize <= 0) return 20;
|
||||
return Math.min(Math.floor(pageSize), 100);
|
||||
}
|
||||
|
||||
/** 标记成功后的回执文案(点名动作与后果,不写「操作成功」这种没有信息量的话)。
|
||||
* ⚠ 本窗不承诺「撤销标记」入口——已下架行不进在架列表,误标撤销口记 BACKLOG 欠账。 */
|
||||
export function markDelistedNotice(productCode?: string): string {
|
||||
const who = productCode ? `商品 ${productCode} ` : '';
|
||||
return `已标记${who}下架,额度已腾出;请确认该商品确已在京麦下架`;
|
||||
}
|
||||
Reference in New Issue
Block a user