编辑款式下拉框修复

This commit is contained in:
2025-12-23 12:35:07 +08:00
parent 033a1acef3
commit 58605b1f92
7 changed files with 399 additions and 228 deletions

13
main.py
View File

@@ -335,12 +335,17 @@ class FabricManager(QMainWindow):
text = f"款号: {style_number}\n生产件数: {qty}\n损耗率: {self.loss_input.value()}%\n\n"
try:
with self.get_conn() as conn:
cursor = conn.execute("SELECT category, fabric_type, usage_per_piece, unit FROM garment_materials WHERE style_number = ? ORDER BY id", (style_number,))
for category, fabric_type, usage, unit in cursor.fetchall():
cursor = conn.execute("SELECT category, fabric_type, model, usage_per_piece, unit FROM garment_materials WHERE style_number = ? ORDER BY id", (style_number,))
for category, fabric_type, model, usage, unit in cursor.fetchall():
if usage:
total = usage * qty * (1 + loss)
# 显示材料名称(如果有类型则显示类目-类型,否则只显示类目
material_name = f"{category}-{fabric_type}" if fabric_type else category
# 显示材料名称:优先显示型号,否则显示类目-类型,最后只显示类目
if model:
material_name = model
elif fabric_type:
material_name = f"{category}-{fabric_type}" if category else fabric_type
else:
material_name = category or "未命名材料"
text += f"{material_name}\n单件: {usage:.3f} {unit}\n总用量: {total:.3f} {unit}\n\n"
except Exception as e:
text += "计算失败: " + str(e)