diff --git a/routes/products.py b/routes/products.py index 135ec4c..2e1e28e 100644 --- a/routes/products.py +++ b/routes/products.py @@ -504,6 +504,9 @@ def product_batch_update(): for field, value in fields.items(): if field not in allowed_fields: continue + # 品牌来自表格/剪贴板时可能带有尾部 Tab 或换行;只清理首尾空白,保留名称中的正常空格。 + if field == 'brand' and isinstance(value, str): + value = value.strip() if value == '' or value is None: value = None # 数值字段范围校验 @@ -1105,7 +1108,7 @@ def product_create(): VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) """, ( product_code, product_name, - data.get('brand', ''), data.get('product_type', '成品'), + (data.get('brand') or '').strip(), (data.get('product_type') or '成品').strip(), int(data.get('lead_time', 0)), min(int(data.get('logistics_time', 0)), 999), data.get('supplier_code', ''), data.get('supplier_name', ''), data.get('procurement_follower', ''), data.get('procurement_planner', ''),