From 65b01af819cd4e3947f60c62eed550860ff86472 Mon Sep 17 00:00:00 2001 From: 27942 <1313123@342> Date: Thu, 5 Feb 2026 00:35:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AD=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui_app.py | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/gui_app.py b/gui_app.py index 2db690f..75d902d 100644 --- a/gui_app.py +++ b/gui_app.py @@ -861,6 +861,20 @@ class MainWindow(QMainWindow): layout.addWidget(checkbox) self.config_table.setCellWidget(row, 0, wrapper) + + def _sync_checked_from_table(self): + """从表格当前页的勾选框同步勾选状态到 configs(仅非 model_view 且当前页)""" + if self.use_model_view or not self.page_row_indices: + return + for table_row, config_index in enumerate(self.page_row_indices): + if config_index >= len(self.configs): + continue + w = self.config_table.cellWidget(table_row, 0) + if not w: + continue + checkbox = w.findChild(QCheckBox) if hasattr(w, 'findChild') else None + if checkbox is not None: + self.configs[config_index]['勾选'] = checkbox.isChecked() def _on_checkbox_changed(self, config_index, state): """勾选框状态改变回调""" @@ -3226,17 +3240,21 @@ class MainWindow(QMainWindow): try: # 检查是否有Excel导入的配置 if self.configs: - # 如果存在失败项,自动只勾选失败项 - failed_indices = [] - for idx, cfg in enumerate(self.configs): - status = cfg.get('情况', '') - if "失败" in status or "错误" in status or "过期" in status or "跳过" in status: - failed_indices.append(idx) - if failed_indices: + # 检查用户是否已经勾选了任何项 + has_user_selection = any(cfg.get('勾选', False) for cfg in self.configs) + + # 只有当用户没有勾选任何项时,才自动勾选失败项 + if not has_user_selection: + failed_indices = [] for idx, cfg in enumerate(self.configs): - cfg['勾选'] = idx in failed_indices - self.update_table() - self._show_infobar("info", "提示", f"检测到 {len(failed_indices)} 条失败记录,已自动仅选择失败项") + status = cfg.get('情况', '') + if "失败" in status or "错误" in status or "过期" in status or "跳过" in status: + failed_indices.append(idx) + if failed_indices: + for idx, cfg in enumerate(self.configs): + cfg['勾选'] = idx in failed_indices + self.update_table() + self._show_infobar("info", "提示", f"检测到 {len(failed_indices)} 条失败记录,已自动仅选择失败项") # 如果有Excel配置,批量处理 self.execute_batch_from_excel() return # 批量处理完成后直接返回 @@ -3262,7 +3280,9 @@ class MainWindow(QMainWindow): # 执行前强制同步当前页数据,确保手动修改的内容被包含 if not self.use_model_view: self._sync_configs_from_table() - + # 从表格当前页勾选框同步勾选状态到 configs,确保执行的是用户当前勾选的行 + self._sync_checked_from_table() + # 开始新任务时,从当前数据中统计已有的成功/失败/待执行数量(累计历史数据) existing_success = 0 existing_failed = 0