dy-dashboard/vault/知识库/工作指南/训练记录/2026-06-26-修复计划预测下单bom_json未初始化Bug.md
2026-10-28 11:14:17 +08:00

18 lines
518 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 2026-06-26 修复计划预测下单bom_json未初始化Bug
## 背景
计划预测页面点击下单提示"网络错误",实际是后端报错。
## 问题
`routes/purchase.py` 中 `purchase_add_pending` 函数,当请求未携带 `bom_items` 参数时,变量 `bom_json` 没有被初始化,导致第147行 `if not bom_json:` 抛出 `UnboundLocalError`。
## 修复
在 `req_bom_items = data.get('bom_items', '')` 之后添加 `bom_json = None` 初始化变量。
## 涉及文件
- `routes/purchase.py`