From 54d83803c4c4b3c6a3b833483b1da0e507f393e8 Mon Sep 17 00:00:00 2001 From: dxc Date: Sat, 28 Feb 2026 15:40:59 +0800 Subject: [PATCH] fix: URL-encode BOM numbers containing slashes Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) --- inventory-web/src/api/bom.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/inventory-web/src/api/bom.ts b/inventory-web/src/api/bom.ts index fa57c43..4650400 100644 --- a/inventory-web/src/api/bom.ts +++ b/inventory-web/src/api/bom.ts @@ -11,11 +11,11 @@ export function getBomList(params?: any) { // 获取BOM详情 export function getBomDetail(bomNo: string) { - // 去除首尾斜杠,并按 '/' 分割,取第一个有效部分 + // 去除首尾斜杠,保留中间斜杠并进行 URL 编码 const trimmed = bomNo.replace(/^\/+|\/+$/g, ''); - const firstPart = trimmed.split('/')[0]; + const encoded = encodeURIComponent(trimmed); return request({ - url: `/v1/bom/detail/${firstPart}`, + url: `/v1/bom/detail/${encoded}`, method: 'get' }) } @@ -31,8 +31,11 @@ export function saveBom(data: any) { // 删除BOM(暂未实现,预留) export function deleteBom(bomNo: string) { + // 去除首尾斜杠,保留中间斜杠并进行 URL 编码 + const trimmed = bomNo.replace(/^\/+|\/+$/g, ''); + const encoded = encodeURIComponent(trimmed); return request({ - url: `/v1/bom/${bomNo}`, + url: `/v1/bom/${encoded}`, method: 'delete' }) }