fix:优化数据
This commit is contained in:
@@ -44,7 +44,12 @@ async def generate_quote_excel(
|
||||
# Assume the first worksheet is used for the quote.
|
||||
ws = wb.active
|
||||
|
||||
modules: List[Dict[str, Any]] = project_data.get("modules", [])
|
||||
raw_modules: List[Any] = project_data.get("modules", [])
|
||||
# Normalize: only dicts have .get(); coerce others to a minimal dict
|
||||
modules: List[Dict[str, Any]] = [
|
||||
m if isinstance(m, dict) else {"name": str(m) or f"模块 {i}"}
|
||||
for i, m in enumerate(raw_modules, start=1)
|
||||
]
|
||||
total_amount = project_data.get("total_amount")
|
||||
total_hours = project_data.get("total_estimated_hours")
|
||||
notes = project_data.get("notes")
|
||||
@@ -157,7 +162,11 @@ async def generate_quote_pdf_from_data(
|
||||
|
||||
c.setFont("Helvetica", 10)
|
||||
|
||||
modules: List[Dict[str, Any]] = project_data.get("modules", [])
|
||||
raw_modules: List[Any] = project_data.get("modules", [])
|
||||
modules = [
|
||||
m if isinstance(m, dict) else {"name": str(m) or f"模块 {i}"}
|
||||
for i, m in enumerate(raw_modules, start=1)
|
||||
]
|
||||
for idx, module in enumerate(modules, start=1):
|
||||
name = module.get("name", "")
|
||||
hours = module.get("estimated_hours", "")
|
||||
|
||||
Reference in New Issue
Block a user