feat(product-stop): 增加在线SOP和操作录屏入口

This commit is contained in:
apple 2026-11-21 16:52:15 +08:00
parent d1b442bc74
commit 7811c4bbe1
27 changed files with 697 additions and 5 deletions

View File

@ -223,6 +223,7 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# 复制必要的文件
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/private ./private
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nextjs:nodejs /app/src/lib ./src/lib

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

View File

@ -0,0 +1,51 @@
1
00:00:00,000 --> 00:00:05,727
查询、核对、附表分析、期初维护、人工推送与导出
2
00:00:05,877 --> 00:00:16,666
查看生成日期、生成时间和数据总量;异常提示要先判断影响。
3
00:00:16,816 --> 00:00:27,628
支持分类、SPU、SKU、条码;可切换模糊、精确或批量匹配。
4
00:00:27,778 --> 00:00:38,337
查询后先看总条数、筛选条件和小计,避免带着旧条件继续操作。
5
00:00:38,487 --> 00:00:48,630
附表支持平台、店铺和负责人筛选;小计按当前筛选范围重算。
6
00:00:48,780 --> 00:00:57,825
设置列、筛选项和异常预警人员,减少无关字段。
7
00:00:57,975 --> 00:01:09,355
人工值优先;空白字段回退自动同步;历史驳回独立取最近一次。
8
00:01:09,505 --> 00:01:20,095
勾选条码,填写停产原因分类和详细说明,再核对推送结果。
9
00:01:20,245 --> 00:01:30,999
按当前筛选和排序导出,并选择仅主表、店铺明细或运营总监明细。
10
00:01:31,149 --> 00:01:40,067
单独查看是否准入为否的商品,继续查询、分析和人工处置。
11
00:01:40,217 --> 00:01:50,736
维护盘停规则、准入规则、留观天数和判定参数。
12
00:01:50,886 --> 00:02:01,236
维护采购类型与入库、代发类型及标准仓库的对应关系。
13
00:02:01,386 --> 00:02:11,907
确认快照 → 查询核对 → 主表与附表 → 处理异常 → 维护规则 → 推送或导出

View File

@ -0,0 +1,26 @@
import { NextRequest } from 'next/server'
import { handleRequest } from '@/server/core/response'
import {
assertProductStopHelpAccess,
serveProductStopHelpImage,
} from '@/server/services/product-stop-help.service'
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ filename: string }> },
) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return serveProductStopHelpImage((await params).filename)
}, { requireAuth: true })
}
export async function HEAD(
request: NextRequest,
{ params }: { params: Promise<{ filename: string }> },
) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return serveProductStopHelpImage((await params).filename, true)
}, { requireAuth: true })
}

View File

@ -0,0 +1,20 @@
import { NextRequest } from 'next/server'
import { handleRequest } from '@/server/core/response'
import {
assertProductStopHelpAccess,
serveProductStopHelpFile,
} from '@/server/services/product-stop-help.service'
export async function GET(request: NextRequest) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return serveProductStopHelpFile(request, 'sop')
}, { requireAuth: true })
}
export async function HEAD(request: NextRequest) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return serveProductStopHelpFile(request, 'sop', true)
}, { requireAuth: true })
}

View File

@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { handleRequest } from '@/server/core/response'
import {
assertProductStopHelpAccess,
renderProductStopSopHtml,
} from '@/server/services/product-stop-help.service'
export async function GET(request: NextRequest) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return new NextResponse(renderProductStopSopHtml(), {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8',
'Cache-Control': 'no-store',
'X-Frame-Options': 'DENY',
},
})
}, { requireAuth: true })
}

View File

@ -0,0 +1,20 @@
import { NextRequest } from 'next/server'
import { handleRequest } from '@/server/core/response'
import {
assertProductStopHelpAccess,
serveProductStopHelpFile,
} from '@/server/services/product-stop-help.service'
export async function GET(request: NextRequest) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return serveProductStopHelpFile(request, 'video')
}, { requireAuth: true })
}
export async function HEAD(request: NextRequest) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return serveProductStopHelpFile(request, 'video', true)
}, { requireAuth: true })
}

View File

@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { handleRequest } from '@/server/core/response'
import {
assertProductStopHelpAccess,
renderProductStopVideoHtml,
} from '@/server/services/product-stop-help.service'
export async function GET(request: NextRequest) {
return handleRequest(request, async (ctx) => {
await assertProductStopHelpAccess(ctx.user)
return new NextResponse(renderProductStopVideoHtml(), {
status: 200,
headers: {
'Content-Type': 'text/html; charset=utf-8',
'Cache-Control': 'no-store',
'X-Frame-Options': 'DENY',
},
})
}, { requireAuth: true })
}

View File

@ -12,6 +12,7 @@ import {
import {
AlertCircle,
AlertTriangle,
BookOpen,
ChevronDown,
ChevronLeft,
ChevronRight,
@ -26,6 +27,7 @@ import {
Loader2,
Move,
Pencil,
PlayCircle,
RefreshCw,
Search,
Send,
@ -901,6 +903,28 @@ export function ProductStopDetailView({
<RefreshCw size={15} className={loading ? workbench.spin : undefined} />
</button>
) : null}
{permissions.main.view ? (
<span className={styles.helpEntryGroup} aria-label="商品盘停操作帮助">
<a
className={styles.helpEntry}
href={`${API_BASE}/help/sop`}
target="_blank"
rel="noreferrer"
>
<BookOpen size={14} />
操作SOP
</a>
<a
className={styles.helpEntry}
href={`${API_BASE}/help/video`}
target="_blank"
rel="noreferrer"
>
<PlayCircle size={14} />
操作录屏
</a>
</span>
) : null}
</div>
<div className={workbench.summary}>
<Filter size={13} />

View File

@ -1,5 +1,6 @@
import { redirect } from 'next/navigation'
import { requireSession } from '@/lib/server-session'
import { canViewProductInventoryStop } from '@/lib/supply-chain-product-stop-permissions'
import { supplyChainPermissionSettingsService } from '@/server/services/supply-chain-permission-settings.service'
export async function requireProductInventoryStopAccess() {
@ -16,10 +17,6 @@ export async function requireProductInventoryStopPermissions() {
const { authUser } = await requireSession('/login')
const permissions = await supplyChainPermissionSettingsService
.getProductInventoryStopPermissions(authUser)
const visible = permissions.detail.main.view
|| permissions.unadmitted.main.view
|| permissions.logicConfig.view
|| permissions.warehouseMapping.view
if (!visible) redirect('/supply-chain')
if (!canViewProductInventoryStop(permissions)) redirect('/supply-chain')
return { authUser, permissions }
}

View File

@ -244,6 +244,44 @@
padding-top: 0;
}
.helpEntryGroup {
display: inline-flex;
flex: 0 0 auto;
overflow: hidden;
border: 1px solid #d4d4d8;
border-radius: 7px;
background: #fff;
}
.helpEntry {
display: inline-flex;
min-height: 32px;
align-items: center;
gap: 6px;
padding: 0 12px;
color: #3f3f46;
font-size: 12px;
font-weight: 600;
text-decoration: none;
white-space: nowrap;
}
.helpEntry + .helpEntry {
border-left: 1px solid #e4e4e7;
}
.helpEntry:hover {
background: #f4f4f5;
color: #18181b;
}
.helpEntry:focus-visible {
position: relative;
z-index: 1;
outline: 2px solid #60a5fa;
outline-offset: -2px;
}
.tableWrap {
min-width: 0;
min-height: 96px;

View File

@ -0,0 +1,36 @@
import {
canViewProductInventoryStop,
emptyProductInventoryStopPermissions,
type ProductInventoryStopPermissions,
} from './supply-chain-product-stop-permissions'
function permissionWith(
apply: (permissions: ProductInventoryStopPermissions) => void,
) {
const permissions = emptyProductInventoryStopPermissions()
apply(permissions)
return permissions
}
describe('商品盘停整体查看权限', () => {
it('没有任何模块查看权限时不能查看操作帮助', () => {
expect(canViewProductInventoryStop(emptyProductInventoryStopPermissions())).toBe(false)
})
it.each([
['盘停明细', (permissions: ProductInventoryStopPermissions) => {
permissions.detail.main.view = true
}],
['未准入盘停明细', (permissions: ProductInventoryStopPermissions) => {
permissions.unadmitted.main.view = true
}],
['盘停逻辑配置', (permissions: ProductInventoryStopPermissions) => {
permissions.logicConfig.view = true
}],
['仓库映射关系', (permissions: ProductInventoryStopPermissions) => {
permissions.warehouseMapping.view = true
}],
])('%s有查看权限时即可查看操作帮助', (_label, apply) => {
expect(canViewProductInventoryStop(permissionWith(apply))).toBe(true)
})
})

View File

@ -65,6 +65,15 @@ export type ProductInventoryStopPermissions = {
warehouseMapping: ProductStopTablePermissions
}
export function canViewProductInventoryStop(
permissions: ProductInventoryStopPermissions,
) {
return permissions.detail.main.view
|| permissions.unadmitted.main.view
|| permissions.logicConfig.view
|| permissions.warehouseMapping.view
}
export const PRODUCT_STOP_PERMISSION_GROUPS: ProductStopPermissionGroup[] = [
{
key: 'detailMain',

View File

@ -0,0 +1,62 @@
import type { NextRequest } from 'next/server'
import {
renderProductStopSopHtml,
renderProductStopVideoHtml,
serveProductStopHelpFile,
serveProductStopHelpImage,
} from './product-stop-help.service'
describe('商品盘停操作帮助页面', () => {
it('在线 SOP 提供录屏入口和 Word 下载', () => {
const html = renderProductStopSopHtml()
expect(html).toContain('商品盘停明细业务快速掌握')
expect(html).toContain('观看操作录屏')
expect(html).toContain('下载 Word 版')
expect(html).toContain('/help/sop-file')
expect(html).toContain('/help/image/01-overview.png')
})
it('录屏页面使用受权限保护的视频流和下载接口', () => {
const html = renderProductStopVideoHtml()
expect(html).toContain('<video controls')
expect(html).toContain('/help/video-file')
expect(html).toContain('下载录屏')
expect(html).toContain('查看在线 SOP')
})
it('视频文件支持分段读取以便在线播放和拖动', async () => {
const request = {
headers: {
get: (name: string) => name.toLowerCase() === 'range' ? 'bytes=0-99' : null,
},
nextUrl: new URL('http://localhost/api/supply-chain/management/product-inventory-stop/help/video-file'),
} as unknown as NextRequest
const response = await serveProductStopHelpFile(request, 'video', true)
expect(response.status).toBe(206)
expect(response.headers.get('Content-Type')).toBe('video/mp4')
expect(response.headers.get('Content-Range')).toMatch(/^bytes 0-99\/\d+$/)
expect(response.headers.get('Content-Length')).toBe('100')
})
it('Word 文件使用下载响应', async () => {
const request = {
headers: { get: () => null },
nextUrl: new URL('http://localhost/api/supply-chain/management/product-inventory-stop/help/sop-file'),
} as unknown as NextRequest
const response = await serveProductStopHelpFile(request, 'sop', true)
expect(response.status).toBe(200)
expect(response.headers.get('Content-Type')).toContain(
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
)
expect(response.headers.get('Content-Disposition')).toContain('attachment')
})
it('在线 SOP 截图通过受权限保护的图片接口读取', async () => {
const response = await serveProductStopHelpImage('01-overview.png', true)
expect(response.status).toBe(200)
expect(response.headers.get('Content-Type')).toBe('image/png')
expect(Number(response.headers.get('Content-Length'))).toBeGreaterThan(0)
await expect(serveProductStopHelpImage('../product-stop-detail-sop.docx'))
.rejects.toThrow('图片不存在')
})
})

View File

@ -0,0 +1,368 @@
import { createReadStream } from 'node:fs'
import { stat } from 'node:fs/promises'
import { join } from 'node:path'
import { Readable } from 'node:stream'
import type { NextRequest } from 'next/server'
import { NextResponse } from 'next/server'
import { canViewProductInventoryStop } from '@/lib/supply-chain-product-stop-permissions'
import type { AuthUser } from '@/server/core/types'
import { AppError, ErrorCode } from '@/server/core/errors'
import { supplyChainPermissionSettingsService } from '@/server/services/supply-chain-permission-settings.service'
const HELP_ROOT = join(process.cwd(), 'private', 'product-stop-help')
const SOP_FILE = join(HELP_ROOT, 'product-stop-detail-sop.docx')
const VIDEO_FILE = join(HELP_ROOT, 'product-stop-detail-demo.mp4')
const BACK_URL = '/supply-chain/management/product-inventory-stop'
const SOP_URL = '/api/supply-chain/management/product-inventory-stop/help/sop'
const VIDEO_URL = '/api/supply-chain/management/product-inventory-stop/help/video'
const SOP_DOWNLOAD_URL = '/api/supply-chain/management/product-inventory-stop/help/sop-file'
const VIDEO_FILE_URL = '/api/supply-chain/management/product-inventory-stop/help/video-file'
const IMAGE_URL = '/api/supply-chain/management/product-inventory-stop/help/image'
const HELP_IMAGE_NAMES = new Set([
'01-overview.png',
'02-filtered-result.png',
'03-main-row-selected.png',
'04-shop-metrics.png',
'05-settings.png',
'06-demand-state-maintenance.png',
'07-manual-push.png',
'08-export.png',
'09-unadmitted.png',
'10-logic-config.png',
'11-warehouse-mapping.png',
])
const HELP_STYLES = `
:root { color-scheme: light; --ink:#172033; --muted:#667085; --line:#dce3ec; --blue:#1d4ed8; --navy:#123d36; --soft:#f4f7f9; --warn:#fff7e6; }
* { box-sizing:border-box; }
html,body { margin:0; min-height:100%; background:#f0f3f6; color:var(--ink); font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif; }
a { color:inherit; text-decoration:none; }
.hero { background:linear-gradient(135deg,#123d36 0%,#1a5a50 70%,#206b5e 100%); color:#fff; padding:24px clamp(24px,5vw,76px); box-shadow:0 8px 22px rgba(18,61,54,.2); }
.hero-row { display:flex; align-items:center; justify-content:space-between; gap:24px; max-width:1480px; margin:0 auto; }
.hero h1 { margin:0; font-size:clamp(24px,2.4vw,38px); font-weight:750; letter-spacing:.01em; }
.hero p { margin:9px 0 0; color:#d7e7e3; font-size:14px; }
.actions { display:flex; align-items:center; flex-wrap:wrap; justify-content:flex-end; gap:9px; }
.button { display:inline-flex; align-items:center; justify-content:center; min-height:42px; border:1px solid rgba(255,255,255,.28); border-radius:8px; padding:0 17px; background:rgba(255,255,255,.06); color:#fff; font-size:14px; font-weight:650; transition:.18s ease; white-space:nowrap; }
.button:hover { background:rgba(255,255,255,.14); transform:translateY(-1px); }
.button-primary { background:#fff; color:#123d36; border-color:#fff; }
.page { max-width:1480px; margin:0 auto; padding:28px clamp(18px,4vw,56px) 60px; }
.notice { border-left:4px solid #4f7866; background:#eef5f1; padding:18px 22px; color:#314b43; line-height:1.7; border-radius:0 8px 8px 0; margin-bottom:22px; }
.content { background:#fff; border:1px solid #e2e8f0; border-radius:16px; padding:clamp(24px,3.4vw,48px); box-shadow:0 12px 40px rgba(28,45,67,.07); }
.eyebrow { font-size:13px; font-weight:700; color:#507267; letter-spacing:.08em; text-transform:uppercase; }
h2 { font-size:clamp(28px,3vw,43px); line-height:1.2; margin:8px 0 8px; }
.lead { font-size:16px; color:#475467; line-height:1.8; margin:0 0 26px; }
.meta { display:flex; flex-wrap:wrap; gap:12px 28px; padding:16px 0 22px; border-bottom:1px solid #eef1f5; color:#475467; font-size:14px; }
.meta strong { color:var(--ink); }
.principle { border:1px solid #cfd8e3; background:#fbfcfd; padding:20px 22px; margin:24px 0 34px; font-size:16px; line-height:1.7; font-weight:650; }
section { margin:34px 0 44px; }
section h3 { font-size:22px; margin:0 0 15px; padding-bottom:9px; border-bottom:1px solid #e5eaf0; }
section h4 { font-size:16px; margin:22px 0 8px; }
p,li { font-size:14.5px; line-height:1.78; color:#475467; }
ul,ol { padding-left:23px; margin:10px 0 16px; }
.flow { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:18px 0 22px; }
.flow-card { border:1px solid #dfe6ee; border-radius:10px; padding:16px; background:#fafbfc; }
.flow-card b { display:block; color:#24483e; margin-bottom:6px; }
.field-table { width:100%; border-collapse:collapse; margin:12px 0 22px; font-size:14px; }
.field-table th,.field-table td { border:1px solid #dfe5ec; padding:11px 12px; text-align:left; vertical-align:top; line-height:1.6; }
.field-table th { background:#edf3f0; color:#284c42; }
.shot { margin:18px 0 30px; border:1px solid #dce3eb; border-radius:12px; overflow:hidden; background:#f8fafc; }
.shot img { display:block; width:100%; height:auto; }
.caption { padding:10px 14px; color:#667085; font-size:12.5px; border-top:1px solid #e2e8ef; }
.callout { margin:18px 0; padding:16px 18px; border-radius:9px; background:#eef5f1; color:#31584d; line-height:1.7; }
.callout.warn { background:var(--warn); color:#8a4b08; }
.callout.danger { background:#fff0f0; color:#942626; }
.footer-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top:36px; padding-top:24px; border-top:1px solid #e5eaf0; }
.footer-actions a { border:1px solid #cfd8e4; border-radius:8px; padding:11px 16px; color:#24364f; font-weight:650; background:#fff; }
.video-shell { background:#08141f; border-radius:16px; padding:14px; box-shadow:0 16px 42px rgba(8,20,31,.25); }
video { display:block; width:100%; max-height:calc(100vh - 260px); border-radius:10px; background:#000; }
@media (max-width:900px) { .hero-row { align-items:flex-start; flex-direction:column; } .actions { justify-content:flex-start; } .flow { grid-template-columns:1fr; } .content { padding:22px; } }
`
function shell(title: string, subtitle: string, actions: string, body: string) {
return `<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="robots" content="noindex,nofollow" />
<title>${title} · 供应链中心</title>
<style>${HELP_STYLES}</style>
</head>
<body>
<header class="hero">
<div class="hero-row">
<div><h1>${title}</h1><p>${subtitle}</p></div>
<nav class="actions">${actions}</nav>
</div>
</header>
<main class="page">${body}</main>
</body>
</html>`
}
function shot(path: string, caption: string) {
return `<figure class="shot"><img src="${IMAGE_URL}/${encodeURIComponent(path)}" alt="${caption}" loading="lazy" /><figcaption class="caption">${caption}</figcaption></figure>`
}
export function renderProductStopSopHtml() {
const body = `
<div class="notice">网页版用于快速查阅;如需留档或内部转发,可使用顶部“下载 Word 版”。</div>
<article class="content">
<div class="eyebrow">供应链中心 · 操作规范</div>
<h2>商品盘停明细业务快速掌握</h2>
<p class="lead">目标是让业务人员快速掌握盘停查询、主附表分析、期初维护、人工推送、导出和配置检查。</p>
<div class="meta"><span>适用范围:<strong>盘停明细、未准入盘停明细、盘停逻辑配置、仓库映射关系</strong></span><span>版本日期:<strong>2026-11-21</strong></span><span>版本:<strong>V1.0</strong></span></div>
<div class="principle">核心原则:先确认快照 → 再缩小查询范围 → 核对条码与关键指标 → 最后维护、推送或导出</div>
<section>
<h3>00 一页掌握:每天按这个顺序操作</h3>
<div class="flow">
<div class="flow-card"><b>1. 确认快照</b>查看生成日期、生成时间和总行数;有取数提示时先判断影响。</div>
<div class="flow-card"><b>2. 查询目标</b>输入分类、SPU、SKU 或条码,可使用模糊、精确或批量搜索。</div>
<div class="flow-card"><b>3. 核对主表</b>查看盘停建议、是否建议盘停、是否准入和停产需求状态。</div>
<div class="flow-card"><b>4. 查看附表</b>单击商品行,分析运营总监和店铺指标差异。</div>
<div class="flow-card"><b>5. 处理状态</b>确需人工覆盖时,维护期初状态、驳回信息和推送时间。</div>
<div class="flow-card"><b>6. 推送或导出</b>确认条码和原因后执行人工推送,或按筛选条件导出。</div>
</div>
${shot('01-overview.png', '商品盘停明细总览')}
</section>
<section>
<h3>01 标准查询与筛选</h3>
<ol>
<li>在搜索框输入分类、SPU、SKU 或商品条码。</li>
<li>点击“模”切换模糊匹配;切换为“精”后按精确值查询。</li>
<li>多个条码可使用“批”批量输入,一行一个或使用逗号、空格分隔。</li>
<li>快速筛选支持是否建议盘停、是否准入和入库/代发;列头漏斗用于字段级筛选。</li>
<li>查询后先看总条数、分页和小计,再进入商品明细。</li>
</ol>
${shot('02-filtered-result.png', '按条码查询后的主表结果')}
<div class="callout warn">执行人工推送、导出或批量操作前,必须确认筛选条数、筛选标签和勾选条码都属于本次业务范围。</div>
</section>
<section>
<h3>02 如何阅读主表与附表</h3>
<table class="field-table">
<thead><tr><th>字段</th><th>业务含义</th><th>使用建议</th></tr></thead>
<tbody>
<tr><td>盘停建议</td><td>系统根据规则给出的文字结论和原因。</td><td>先看冒号后的具体原因,再找对应指标。</td></tr>
<tr><td>是否建议盘停 / 是否准入</td><td>最终建议及准入范围。</td><td>两者不一致时检查规则和准入条件。</td></tr>
<tr><td>停产需求状态</td><td>最新一条停产需求的当前状态。</td><td>不等同于最近一次驳回状态。</td></tr>
<tr><td>驳回分类 / 驳回原因</td><td>当前需求提交前最近一次真实驳回。</td><td>人工期初非空时优先。</td></tr>
<tr><td>推送时间 / 下次推送时间</td><td>实际推送时间和允许再次推送时间。</td><td>未到下次推送时间时避免重复推送。</td></tr>
<tr><td>经营指标</td><td>销售、真实业绩、毛利、费比、售后和利润等。</td><td>结合产品生命周期和附表差异判断。</td></tr>
</tbody>
</table>
<ol>
<li>单击主表商品行,下方自动加载运营总监和店铺指标。</li>
<li>默认看运营总监维度,切换店铺维度可继续定位到平台、店铺和负责人。</li>
<li>附表小计按当前筛选后的店铺明细重算;与主表不一致时查看差异提示。</li>
<li>拖动主表与附表之间的分隔条,可调整两部分展示高度。</li>
</ol>
${shot('03-main-row-selected.png', '点击商品行后的附表联动')}
${shot('04-shop-metrics.png', '店铺指标筛选与小计')}
</section>
<section>
<h3>03 设置、期初维护与人工推送</h3>
<h4>设置</h4>
<p>通过“设置”配置显示列、筛选字段和异常预警人员。不同岗位只保留实际使用的信息。</p>
${shot('05-settings.png', '设置入口')}
<h4>期初维护</h4>
<p>人工值优先于自动同步;空白字段继续回退自动同步;删除人工记录后恢复全自动。停产需求状态取最新需求当前状态,驳回信息独立取最近一次真实驳回。</p>
${shot('06-demand-state-maintenance.png', '停产需求状态期初维护')}
<h4>人工推送</h4>
<ol><li>勾选一个或多个目标条码。</li><li>填写停产原因分类和可追溯的详细说明。</li><li>确认后查看成功、跳过和失败条码。</li></ol>
${shot('07-manual-push.png', '人工推送停产需求')}
<div class="callout danger">批量推送前必须排除非销售、已在停产流程中、已有有效需求或不在准入范围的商品。</div>
</section>
<section>
<h3>04 导出与数据交付</h3>
<p>导出按当前筛选和排序生成文件,默认覆盖全部匹配结果,不受当前页限制。</p>
<ul><li>可选择全字段、当前显示字段或业务模板。</li><li>明细范围支持仅主表、店铺明细和运营总监明细。</li><li>导出前确认总条数,大范围导出时不要重复点击。</li></ul>
${shot('08-export.png', '导出字段与明细范围')}
</section>
<section>
<h3>05 其他业务页面</h3>
<h4>未准入盘停明细</h4><p>只展示是否准入为否的商品,用于单独跟踪和人工处置。</p>
${shot('09-unadmitted.png', '未准入盘停明细')}
<h4>盘停逻辑配置</h4><p>维护判定字段、阈值、规则组、准入规则和留观天数。修改后重新生成并抽查结果。</p>
${shot('10-logic-config.png', '盘停逻辑配置')}
<h4>仓库映射关系</h4><p>维护采购类型、入库/代发属性和标准仓库。空白或错误映射需及时修正。</p>
${shot('11-warehouse-mapping.png', '仓库映射关系')}
</section>
<section>
<h3>06 常见问题与检查清单</h3>
<table class="field-table">
<thead><tr><th>现象</th><th>优先检查</th><th>处理</th></tr></thead>
<tbody>
<tr><td>页面没有数据</td><td>快照、筛选条件、准入范围</td><td>清空筛选后刷新;仍无数据则检查生成记录。</td></tr>
<tr><td>建议盘停但没有自动推送</td><td>是否准入、下次推送时间、有效需求、销售状态、PLM流程、数据新鲜度</td><td>处理阻断条件后等待自动重跑;确需业务动作时走人工推送。</td></tr>
<tr><td>附表小计和主表不一致</td><td>筛选、店铺归集、残差提示</td><td>清空筛选核对;仍差异时检查店铺账号和店铺销售源数据。</td></tr>
<tr><td>人工推送跳过</td><td>非销售、已在流程中、已有有效需求</td><td>按跳过原因处理原单,不重复创建。</td></tr>
<tr><td>导出很慢或文件很大</td><td>总条数、字段数、是否含明细</td><td>缩小筛选,优先使用业务模板,避免重复导出。</td></tr>
</tbody>
</table>
<h4>每日检查</h4>
<ol><li>快照日期为当天、生成成功、总行数无明显异常。</li><li>销售数据无自动推送暂停提示。</li><li>重点条码的盘停建议、准入、驳回和下次推送时间已核对。</li><li>推送结果中的成功、跳过和失败明细已处理。</li></ol>
</section>
<div class="footer-actions">
<a href="${VIDEO_URL}" target="_blank" rel="noreferrer">观看操作录屏</a>
<a href="${SOP_DOWNLOAD_URL}">下载 Word 版</a>
<a href="${BACK_URL}">返回商品盘停管理</a>
</div>
</article>`
return shell(
'商品盘停明细 · 操作 SOP',
'供应链中心 · 2026-11-21 · 可直接在线查看',
`<a class="button button-primary" href="${VIDEO_URL}" target="_blank" rel="noreferrer">观看操作录屏</a>
<a class="button" href="${SOP_DOWNLOAD_URL}">下载 Word 版</a>
<a class="button" href="${BACK_URL}">返回商品盘停管理</a>`,
body,
)
}
export function renderProductStopVideoHtml() {
const body = `
<div class="notice">操作录屏用于快速培训。视频包含中文旁白、步骤字幕和实际页面演示。</div>
<article class="content">
<div class="eyebrow">供应链中心 · 操作演示</div>
<h2>商品盘停明细业务快速掌握</h2>
<p class="lead">时长约 2 分 12 秒,覆盖快照、查询、主附表分析、设置、期初维护、人工推送、导出及配置页面。</p>
<div class="video-shell">
<video controls playsinline preload="metadata" poster="${IMAGE_URL}/${encodeURIComponent('01-overview.png')}">
<source src="${VIDEO_FILE_URL}" type="video/mp4" />
当前浏览器不支持在线播放,请下载录屏查看。
</video>
</div>
<div class="callout">建议首次完整观看;日常遇到不熟悉的按钮时,可直接拖动视频进度回看。</div>
<div class="footer-actions">
<a href="${SOP_URL}" target="_blank" rel="noreferrer">查看在线 SOP</a>
<a href="${SOP_DOWNLOAD_URL}">下载 Word 版 SOP</a>
<a href="${VIDEO_FILE_URL}?download=1">下载录屏</a>
<a href="${BACK_URL}">返回商品盘停管理</a>
</div>
</article>`
return shell(
'商品盘停明细 · 操作录屏',
'供应链中心 · 实际页面演示 · 中文旁白',
`<a class="button button-primary" href="${SOP_URL}" target="_blank" rel="noreferrer">查看在线 SOP</a>
<a class="button" href="${SOP_DOWNLOAD_URL}">下载 Word 版</a>
<a class="button" href="${BACK_URL}">返回商品盘停管理</a>`,
body,
)
}
export async function assertProductStopHelpAccess(user: AuthUser) {
const permissions = await supplyChainPermissionSettingsService
.getProductInventoryStopPermissions(user)
if (!canViewProductInventoryStop(permissions)) {
throw new AppError(ErrorCode.AUTH_PERMISSION_DENIED, '没有商品盘停管理查看权限')
}
}
export async function serveProductStopHelpFile(
request: NextRequest,
kind: 'sop' | 'video',
headOnly = false,
) {
const path = kind === 'sop' ? SOP_FILE : VIDEO_FILE
const info = await stat(path)
const contentType = kind === 'sop'
? 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
: 'video/mp4'
const fileName = kind === 'sop'
? '商品盘停明细业务快速掌握_操作SOP.docx'
: '商品盘停明细业务快速掌握_操作录屏.mp4'
const download = kind === 'sop' || request.nextUrl.searchParams.get('download') === '1'
const disposition = download ? 'attachment' : 'inline'
const baseHeaders = {
'Content-Type': contentType,
'Content-Disposition': `${disposition}; filename*=UTF-8''${encodeURIComponent(fileName)}`,
'Cache-Control': 'private, max-age=3600',
'Accept-Ranges': 'bytes',
'X-Content-Type-Options': 'nosniff',
}
const range = request.headers.get('range')
if (range) {
const matched = /^bytes=(\d*)-(\d*)$/.exec(range.trim())
if (!matched) {
return new NextResponse(null, {
status: 416,
headers: { ...baseHeaders, 'Content-Range': `bytes */${info.size}` },
})
}
const [, startText, endText] = matched
let start = startText ? Number(startText) : 0
let end = endText ? Number(endText) : info.size - 1
if (!startText && endText) {
const suffixLength = Number(endText)
start = Math.max(0, info.size - suffixLength)
end = info.size - 1
}
if (
!Number.isFinite(start)
|| !Number.isFinite(end)
|| start < 0
|| end < start
|| start >= info.size
) {
return new NextResponse(null, {
status: 416,
headers: { ...baseHeaders, 'Content-Range': `bytes */${info.size}` },
})
}
end = Math.min(end, info.size - 1)
const stream = createReadStream(path, { start, end })
return new NextResponse(
headOnly ? null : Readable.toWeb(stream) as ReadableStream<Uint8Array>,
{
status: 206,
headers: {
...baseHeaders,
'Content-Range': `bytes ${start}-${end}/${info.size}`,
'Content-Length': String(end - start + 1),
},
},
)
}
const stream = createReadStream(path)
return new NextResponse(
headOnly ? null : Readable.toWeb(stream) as ReadableStream<Uint8Array>,
{
status: 200,
headers: {
...baseHeaders,
'Content-Length': String(info.size),
},
},
)
}
export async function serveProductStopHelpImage(
filename: string,
headOnly = false,
) {
if (!HELP_IMAGE_NAMES.has(filename)) {
throw new AppError(ErrorCode.VALIDATION_INVALID_FORMAT, '操作帮助图片不存在')
}
const path = join(HELP_ROOT, 'images', filename)
const info = await stat(path)
const stream = createReadStream(path)
return new NextResponse(
headOnly ? null : Readable.toWeb(stream) as ReadableStream<Uint8Array>,
{
status: 200,
headers: {
'Content-Type': 'image/png',
'Content-Length': String(info.size),
'Cache-Control': 'private, max-age=3600',
'X-Content-Type-Options': 'nosniff',
},
},
)
}