From aa9322bcbc573f705424794662f5396e8595000a Mon Sep 17 00:00:00 2001 From: yueli Date: Wed, 9 Sep 2026 10:53:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(borrow):=20=E5=80=9F=E5=BA=93=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=90=8E=E7=AB=AF=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E2=80=94=E2=80=94=E7=94=B3=E8=AF=B7=E5=8E=9F=E5=9B=A0=E3=80=81?= =?UTF-8?q?=E9=A2=84=E8=AE=A1=E5=BD=92=E8=BF=98=E6=97=A5=E6=9C=9F(?= =?UTF-8?q?=E9=95=BF=E6=9C=9F=E5=80=9F=E7=94=A8=E9=99=A4=E5=A4=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - submit_approval 校验:申请原因非空;未勾长期借用时必须有 expected_return_time,否则 ValueError 拦截 --- inventory-backend/app/services/borrow_service.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inventory-backend/app/services/borrow_service.py b/inventory-backend/app/services/borrow_service.py index 9f77335..1541720 100644 --- a/inventory-backend/app/services/borrow_service.py +++ b/inventory-backend/app/services/borrow_service.py @@ -88,6 +88,14 @@ class BorrowApprovalService: if not items: raise ValueError("借库物品列表不能为空") + # ★ 借库申请必填:申请原因;预计归还日期(除非勾选长期借用/不限归还) + if not str(remark or '').strip(): + raise ValueError("借库申请原因不能为空") + _has_indefinite = any(bool(item.get('is_indefinite')) for item in items) + _has_date = any(str(item.get('expected_return_time') or '').strip() for item in items) + if not _has_indefinite and not _has_date: + raise ValueError("请填写预计归还日期,或勾选长期借用(不限归还)") + required_fields = ['name', 'spec_model', 'quantity'] for idx, item in enumerate(items): missing_fields = [f for f in required_fields if f not in item or str(item.get(f) or '').strip() == '']