款号管理列表设置为只读模式

将衣服款号管理界面的表格所有列(款号、类目数量、款式图预览)设置为只读,防止用户直接在表格中编辑内容,保持与原料库列表的一致性。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-28 00:10:43 +08:00
parent 35050407e9
commit 83609aaa20

View File

@@ -142,17 +142,24 @@ class GarmentLibraryDialog(QDialog):
self.garment_table.setRowHeight(i, 140) self.garment_table.setRowHeight(i, 140)
for row_idx, (style_number, image_path) in enumerate(rows): for row_idx, (style_number, image_path) in enumerate(rows):
self.garment_table.setItem(row_idx, 0, QTableWidgetItem(style_number)) # 款号列 - 设置为只读
style_item = QTableWidgetItem(style_number)
style_item.setFlags(style_item.flags() & ~Qt.ItemIsEditable)
self.garment_table.setItem(row_idx, 0, style_item)
# 查询材料数量 # 查询材料数量
with self.get_conn() as conn: with self.get_conn() as conn:
cursor2 = conn.execute("SELECT COUNT(*) FROM garment_materials WHERE style_number = ?", (style_number,)) cursor2 = conn.execute("SELECT COUNT(*) FROM garment_materials WHERE style_number = ?", (style_number,))
count = cursor2.fetchone()[0] count = cursor2.fetchone()[0]
self.garment_table.setItem(row_idx, 1, QTableWidgetItem(str(count))) # 类目数量列 - 设置为只读
count_item = QTableWidgetItem(str(count))
count_item.setFlags(count_item.flags() & ~Qt.ItemIsEditable)
self.garment_table.setItem(row_idx, 1, count_item)
# 显示图片预览 # 显示图片预览
image_item = QTableWidgetItem() image_item = QTableWidgetItem()
image_item.setTextAlignment(Qt.AlignCenter) image_item.setTextAlignment(Qt.AlignCenter)
image_item.setFlags(image_item.flags() & ~Qt.ItemIsEditable)
if image_path and os.path.exists(image_path): if image_path and os.path.exists(image_path):
try: try: