diff --git a/db/jtDB.db b/db/jtDB.db index 7991940..e23af5c 100644 Binary files a/db/jtDB.db and b/db/jtDB.db differ diff --git a/fix_status_management.py b/fix_status_management.py index 0200986..e014cd1 100644 --- a/fix_status_management.py +++ b/fix_status_management.py @@ -80,7 +80,7 @@ CHECK_INSPECTION_METHOD = """ return False gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() @@ -162,7 +162,7 @@ PROCESS_STABLE_WEIGHT_FIND_ROW = """ gc_note_item = self.process_table.item(row, 1) if gc_note_item: row_gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() status = inspection_dao.get_product_status(self._current_order_code, row_gc_note, tray_id) if status == 'inspected': data_row = row @@ -208,7 +208,7 @@ HANDLE_LABEL_SIGNAL_FIND_ROW = """ gc_note_item = self.process_table.item(row, 1) if gc_note_item: row_gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() status = inspection_dao.get_product_status(self._current_order_code, row_gc_note, tray_id) if status == 'weighed': data_row = row diff --git a/from pymodbus.py b/from pymodbus.py index aa987f9..23d6133 100644 --- a/from pymodbus.py +++ b/from pymodbus.py @@ -2,7 +2,7 @@ from pymodbus.client import ModbusTcpClient import time client = ModbusTcpClient('localhost', port=5020) client.connect() -client.write_registers(address=11, values=[19562]) +# client.write_registers(address=11, values=[19562]) # client.write_registers(address=3, values=[0]) # time.sleep(2) # client.write_registers(address=0, values=[0]) @@ -15,8 +15,9 @@ client.write_registers(address=11, values=[19562]) # client.write_registers(address=2, values=[0]) # client.write_registers(address=13, values=[1]) # time.sleep(2) -client.write_registers(address=13, values=[0]) - +client.write_registers(address=20, values=[0]) +time.sleep(3) +client.write_registers(address=20, values=[1]) result1 = client.read_holding_registers(address=3, count=1) diff --git a/status_management_patch.py b/status_management_patch.py index d6244e7..8611552 100755 --- a/status_management_patch.py +++ b/status_management_patch.py @@ -142,7 +142,7 @@ def add_check_inspection_completed(): return False gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() @@ -207,7 +207,7 @@ def update_process_stable_weight(): gc_note_item = self.process_table.item(row, 1) if gc_note_item: row_gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() status = inspection_dao.get_product_status(self._current_order_code, row_gc_note, tray_id) if status == 'inspected': data_row = row @@ -268,7 +268,7 @@ def update_handle_label_signal(): gc_note_item = self.process_table.item(row, 1) if gc_note_item: row_gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() status = inspection_dao.get_product_status(self._current_order_code, row_gc_note, tray_id) if status == 'weighed': data_row = row diff --git a/ui/main_window_ui.py b/ui/main_window_ui.py index 10464b1..4c280d2 100644 --- a/ui/main_window_ui.py +++ b/ui/main_window_ui.py @@ -548,19 +548,15 @@ class MainWindowUI(QMainWindow): self.tray_label.setFixedWidth(100) # 设置固定宽度 self.tray_label.setStyleSheet("background-color: #e0e0e0; border-right: 1px solid #cccccc; font-weight: bold;") self.tray_layout.addWidget(self.tray_label) - - self.tray_edit = QComboBox() - self.tray_edit.setFixedHeight(40) # 设置固定高度与父容器相同 - self.tray_edit.setStyleSheet("QComboBox { border: none; padding: 0px 10px; background-color: white; } QComboBox::drop-down { border: none; width: 20px; }") - self.tray_edit.setFont(QFont("微软雅黑", 12)) - self.tray_edit.setEditable(True) # 允许手动输入 - self.tray_edit.setInsertPolicy(QComboBox.NoInsert) # 不自动插入用户输入到列表中 - self.tray_edit.setMaxVisibleItems(10) # 设置下拉框最多显示10个项目 - self.tray_edit.completer().setCaseSensitivity(Qt.CaseInsensitive) # 设置补全不区分大小写 - self.tray_edit.completer().setFilterMode(Qt.MatchContains) # 设置模糊匹配模式 - # 允许清空选择 - self.tray_edit.setCurrentText("") + # 将 QComboBox 改为 QLineEdit + self.tray_edit = QLineEdit() + self.tray_edit.setFixedHeight(40) # 设置固定高度与父容器相同 + self.tray_edit.setStyleSheet("QLineEdit { border: none; padding: 0px 10px; background-color: white; }") + self.tray_edit.setFont(QFont("微软雅黑", 12)) + self.tray_edit.setReadOnly(True) # 设置为只读 + self.tray_edit.setFocusPolicy(Qt.NoFocus) # 禁止获取焦点 + self.tray_edit.setText("") # 设置初始值为空 self.tray_layout.addWidget(self.tray_edit) self.left_layout.addWidget(self.tray_frame) diff --git a/ui/unloading_dialog_ui.py b/ui/unloading_dialog_ui.py index 182559d..5fcc603 100644 --- a/ui/unloading_dialog_ui.py +++ b/ui/unloading_dialog_ui.py @@ -92,13 +92,15 @@ class UnloadingDialogUI(QDialog): self.tray_label.setStyleSheet(label_style) self.tray_label.setFixedWidth(100) self.tray_label.setFixedHeight(45) - + self.tray_input = QLineEdit() self.tray_input.setFont(self.normal_font) self.tray_input.setPlaceholderText("请扫描托盘号") self.tray_input.setStyleSheet(input_style) self.tray_input.setFixedHeight(45) - + # 禁止用户修改 + self.tray_input.setReadOnly(True) + self.tray_input.setFocusPolicy(Qt.NoFocus) row1.addWidget(self.tray_label) row1.addWidget(self.tray_input, 1) container_layout.addLayout(row1) diff --git a/widgets/loading_dialog_widget.py b/widgets/loading_dialog_widget.py index 0ab8acc..e24be77 100644 --- a/widgets/loading_dialog_widget.py +++ b/widgets/loading_dialog_widget.py @@ -213,20 +213,13 @@ class LoadingDialog(LoadingDialogUI): main_window = self.parent if main_window and isinstance(main_window, MainWindow): # 检查托盘号是否已存在 - existed = False - for i in range(main_window.tray_edit.count()): - if main_window.tray_edit.itemText(i) == xpack: - existed = True - break - - # 如果不存在,则添加 - if not existed: - logging.info(f"添加托盘号到主窗口: {xpack}") - main_window.tray_edit.addItem(xpack) - - # 设置当前选中的托盘号 - main_window.tray_edit.setCurrentText(xpack) + # 由于 tray_edit 现在是 QLineEdit,不再需要检查是否存在 + # 直接设置文本 logging.info(f"设置主窗口当前托盘号: {xpack}") + main_window.tray_edit.setText(xpack) + + # 手动触发托盘号变更事件 + main_window.handle_tray_changed(xpack) return order_info diff --git a/widgets/main_window.py b/widgets/main_window.py index 53ba635..c8e3631 100644 --- a/widgets/main_window.py +++ b/widgets/main_window.py @@ -261,7 +261,7 @@ class MainWindow(MainWindowUI): return axios_num # 如果当前行没有轴号,使用数据库中的轴号+1 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() db_axios_num = self.get_axios_num(tray_id) axios_num = db_axios_num + 1 logging.info(f"当前行无轴号,使用数据库轴号+1: {axios_num}") @@ -270,7 +270,7 @@ class MainWindow(MainWindowUI): except Exception as e: logging.error(f"获取当前行轴号失败: {str(e)}") # 出错时使用数据库轴号+1作为备选 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() db_axios_num = self.get_axios_num(tray_id) return db_axios_num + 1 def load_config(self): @@ -297,10 +297,11 @@ class MainWindow(MainWindowUI): # 工程号输入框回车事件 self.order_edit.returnPressed.connect(self.handle_order_enter) - # 托盘号输入框回车和切换事件,触发未加载数据查询 - # QComboBox没有returnPressed信号,只有currentTextChanged和activated信号 - self.tray_edit.currentTextChanged.connect(self.handle_tray_changed) - self.tray_edit.activated.connect(self.handle_tray_changed) # 当用户选择一项时触发 + # 托盘号输入框信号连接 - 从 QComboBox 改为 QLineEdit + # QLineEdit 没有文本变化的信号,因此我们不需要连接信号 + # 原来的连接代码: + # self.tray_edit.currentTextChanged.connect(self.handle_tray_changed) + # self.tray_edit.currentIndexChanged.connect(self.handle_tray_changed) # 连接按钮事件 self.input_button.clicked.connect(self.handle_input) @@ -399,38 +400,37 @@ class MainWindow(MainWindowUI): """从托盘类型管理器加载托盘号并更新到tray_edit""" try: # 获取当前文本,以便保留用户选择 - current_text = self.tray_edit.currentText() + current_text = self.tray_edit.text() - # 清空当前项目 - self.tray_edit.clear() + # 清空当前文本 + self.tray_edit.setText("") # 获取托盘号 pallet_codes = self.pallet_type_manager.get_pallet_code() if pallet_codes and len(pallet_codes) > 0: - # 添加托盘号到下拉框 - self.tray_edit.addItems(pallet_codes) - - # 如果有之前的选择,尝试恢复它 - index = self.tray_edit.findText(current_text) - if index != -1: - self.tray_edit.setCurrentIndex(index) + # 由于现在是 QLineEdit,我们不再需要添加多个项目 + # 如果有之前的选择并且它在托盘号列表中,则恢复它 + if current_text in pallet_codes: + self.tray_edit.setText(current_text) else: - self.tray_edit.setCurrentIndex(-1) - self.tray_edit.setCurrentText("") + self.tray_edit.setText("") + + # 这里可以存储托盘号列表,以便在其他地方使用 + self._pallet_codes = pallet_codes logging.info(f"已加载托盘号,共 {len(pallet_codes)} 个") else: - # 如果没有托盘号,则不添加任何项目,保持为空 - logging.warning("未找到托盘号,托盘号列表将为空") - self.tray_edit.setCurrentText("") - + # 如果没有托盘号,则保持为空 + logging.warning("未找到托盘号,托盘号将为空") + self.tray_edit.setText("") + self._pallet_codes = [] except Exception as e: logging.error(f"加载托盘号失败: {str(e)}") - # 如果加载失败,确保下拉框为空 - self.tray_edit.clear() - self.tray_edit.setCurrentText("") + # 如果加载失败,确保文本框为空 + self.tray_edit.setText("") + self._pallet_codes = [] def load_warehouse_data(self): """从API加载库房数据并更新到信息表格的库房组件""" @@ -638,7 +638,7 @@ class MainWindow(MainWindowUI): def handle_input(self): """处理上料按钮点击事件""" # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 启动监听(不论后续是否确认上料) # 启动Modbus监控 @@ -659,13 +659,13 @@ class MainWindow(MainWindowUI): dialog = self.loading_dialog # 使用类属性引用对话框 # 获取当前主窗口中选择的托盘号,并设置到上料对话框中 - current_tray_id = self.tray_edit.currentText() + current_tray_id = self.tray_edit.text() if current_tray_id: dialog.tray_input.setText(current_tray_id) logging.info(f"将主窗口当前托盘号 {current_tray_id} 设置到上料对话框") # 如果已有上料信息,作为参考显示在对话框中,但允许用户修改 - if self._loading_info and self._current_stow_num > 0: + if self._loading_info and self._current_stow_num >= 0: dialog.order_input.setText(self._loading_info.get('order_code', '')) dialog.tray_input.setText(self._loading_info.get('tray_code', '')) dialog.axis_value.setText(self._loading_info.get('axis_value', '--')) @@ -686,7 +686,7 @@ class MainWindow(MainWindowUI): order_code = dialog.order_input.text().strip() tray_code = dialog.tray_input.text().strip() self._current_order_code = order_code - self.tray_edit.setCurrentText(tray_code) + self.tray_edit.setText(tray_code) # 获取托盘料值作为拆垛层数 stow_num = dialog.pallet_tier_value.text() @@ -738,15 +738,19 @@ class MainWindow(MainWindowUI): dialog = self.unloading_dialog # 使用类属性引用对话框 # 获取当前主窗口中选择的托盘号,并设置到下料对话框中 - current_tray_id = self.tray_edit.currentText() + current_tray_id = self.tray_edit.text() if current_tray_id: dialog.tray_input.setText(current_tray_id) logging.info(f"将主窗口当前托盘号 {current_tray_id} 设置到下料对话框") # 如果有之前的下料信息,作为参考显示在对话框中,但允许用户修改 if self._current_unload_info: + # 确保使用最新的层数值 + if hasattr(self, '_current_unload_num'): + self._current_unload_info['tier'] = str(self._current_unload_num) + dialog.set_unloading_info(self._current_unload_info) - logging.info(f"显示之前的下料信息作为参考") + logging.info(f"显示之前的下料信息作为参考,当前层数:{self._current_unload_info['tier']}") if dialog.exec_() == QDialog.Accepted: # 获取用户最新输入的下料信息 @@ -996,6 +1000,9 @@ class MainWindow(MainWindowUI): # 再调用 update_info_table self.update_info_table(order_info) self.add_new_inspection_row(gc_note, self._current_order_code) + else: + # 弹框提示,获取接口中的 message + QMessageBox.warning(self, "提示", "获取工程号信息失败") else: # 直接添加新行 self.add_new_inspection_row(gc_note, self._current_order_code) @@ -1058,7 +1065,7 @@ class MainWindow(MainWindowUI): self._current_gc_note = gc_note # 记录添加时间,用于确保最新添加的工程号在最后 self._current_gc_note_timestamp = time.time() - logging.info(f"设置最新扫码的工程号: {gc_note}, 时间戳: {self._current_gc_note_timestamp}") + logging.info(f"设置最新扫码的工程号: {gc_note}, 订单号: {order_code}, 时间戳: {self._current_gc_note_timestamp}") try: # 获取启用的检验配置 @@ -1132,7 +1139,7 @@ class MainWindow(MainWindowUI): # 将工程号和托盘号保存到数据库,确保能够正确关联 from dao.inspection_dao import InspectionDAO inspection_dao = InspectionDAO() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 为每个检验位置创建一个空记录,确保工程号在数据库中存在 # 只为没有自动填充值的配置创建空记录 @@ -1221,7 +1228,7 @@ class MainWindow(MainWindowUI): return # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() @@ -1385,7 +1392,7 @@ class MainWindow(MainWindowUI): def _safe_load_data(self): """安全地加载数据,避免循环调用""" # 获取当前托盘号,用于日志记录 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 检查是否有加载操作正在进行 if getattr(self, '_loading_data_in_progress', False): @@ -1433,7 +1440,7 @@ class MainWindow(MainWindowUI): def _do_safe_load(self): """实际执行数据加载的方法,由定时器触发""" # 获取当前托盘号,用于日志记录 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() if self._loading_data_in_progress: # 如果已经在加载数据,不要再次触发 @@ -1480,7 +1487,7 @@ class MainWindow(MainWindowUI): try: # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 防止短时间内重复加载相同数据 current_time = time.time() @@ -1740,7 +1747,7 @@ class MainWindow(MainWindowUI): inspection_dao = InspectionDAO() # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() logging.info(f"显示包装记录,当前托盘号: {tray_id}") if not tray_id: @@ -1828,7 +1835,7 @@ class MainWindow(MainWindowUI): # 获取当前的订单号和托盘号 order_id = self._current_order_code if hasattr(self, '_current_order_code') else None - tray_id = self.tray_edit.currentText() if hasattr(self, 'tray_edit') else "" + tray_id = self.tray_edit.text() if hasattr(self, 'tray_edit') else "" # 初始化订单API统计数据 order_api_stats = { @@ -1942,7 +1949,7 @@ class MainWindow(MainWindowUI): return # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 创建上下文菜单 menu = QMenu(self) @@ -2557,7 +2564,7 @@ class MainWindow(MainWindowUI): self.process_table.setItem(data_row, weight_col, weight_item) # 检查是否已存在相同记录 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() existing_data = inspection_dao.get_inspection_data_by_config(self._current_order_code, gc_note, tray_id, 12, 12) if existing_data and str(existing_data.get('value')) == str(weight_kg): logging.info(f"跳过保存:工程号 {gc_note} 的称重数据 {weight_kg} 已存在") @@ -2659,8 +2666,8 @@ class MainWindow(MainWindowUI): logging.debug(f"字段 '{field_name}' 不在info_values中或为None") # 3. 添加其他必要的信息 - info['xpack'] = self.tray_edit.currentText() - info['spack'] = self.tray_edit.currentText() + info['xpack'] = self.tray_edit.text() + info['spack'] = self.tray_edit.text() info['zh'] = axios_num info['mzl'] = weight_kg info['printsl'] = 1 @@ -2815,7 +2822,7 @@ class MainWindow(MainWindowUI): return # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() @@ -3110,7 +3117,15 @@ class MainWindow(MainWindowUI): # 通过信号触发UI更新 - 显示前一层完成的消息 message = f"第{completed_tier}层下料完成,请启动第{self._current_unload_num}层下料" self.unloading_feedback_signal.emit("output", message) + # 更新下料信息中的层数值,无论对话框是否打开 + if self._current_unload_info: + self._current_unload_info['tier'] = str(self._current_unload_num) + logging.info(f"更新下料信息中的层数为:{self._current_unload_num}") + # 如果下料对话框正在显示,同步更新其中的层数 + if hasattr(self, 'unloading_dialog') and self.unloading_dialog is not None and hasattr(self.unloading_dialog, 'tier_input'): + self.unloading_dialog.tier_input.setText(str(self._current_unload_num)) + logging.info(f"同步更新下料对话框中的层数为:{self._current_unload_num}") # 恢复开始按钮原始样式 self.restore_start_button_style() @@ -3134,10 +3149,9 @@ class MainWindow(MainWindowUI): logging.info("下料任务完成,恢复下料按钮样式") elif "请启动" in desc: QMessageBox.information(self, "下料层完成", desc) - # 如果当前下料信息存在且层数有效,更新UI显示 if self._current_unload_info and self._current_unload_num > 0: - self.show_operation_status("下料层数", "output", f"{self._current_unload_num}/{self._total_unload_num}") + self.show_operation_status("下料层数", "output", f"{self._current_unload_num}") except Exception as e: logging.error(f"处理下料UI更新失败: {str(e)}") @@ -3252,6 +3266,11 @@ class MainWindow(MainWindowUI): # 更新保存的下料信息中的当前层数值 if self._current_unload_info: self._current_unload_info['tier'] = str(level) + + # 如果下料对话框正在显示,同步更新其中的层数 + if hasattr(self, 'unloading_dialog') and self.unloading_dialog is not None and hasattr(self.unloading_dialog, 'tier_input'): + self.unloading_dialog.tier_input.setText(str(level)) + logging.info(f"同步更新下料对话框中的层数为:{level}") # 通过信号在主线程中更新UI self.unloading_level_ui_signal.emit(level) @@ -3320,7 +3339,7 @@ class MainWindow(MainWindowUI): return # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() @@ -3575,7 +3594,7 @@ class MainWindow(MainWindowUI): logging.info(f"记录最近处理线径数据的工程号: {gc_note}") # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 检查线径公差范围 - 基于前端【线径公差】字段 if "线径公差" in self.info_values and self.info_values["线径公差"] is not None: @@ -3797,7 +3816,7 @@ class MainWindow(MainWindowUI): # 设置当前正在处理的工程号,确保它在重新加载时显示在最后 self._current_gc_note = order_id self._current_gc_note_timestamp = time.time() - logging.info(f"在set_inspection_value中设置最新扫码的工程号: {order_id}, 时间戳: {self._current_gc_note_timestamp}") + logging.info(f"在set_inspection_value中设置最新扫码的工程号: {order_id}, 订单号: {self._current_order_code}, 时间戳: {self._current_gc_note_timestamp}") self.add_new_inspection_row(order_id, self._current_order_code) data_row = 2 # 新添加的行 else: @@ -3905,7 +3924,7 @@ class MainWindow(MainWindowUI): # 保存到数据库,但只在非加载状态下 if not self._loading_data_in_progress: - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() self.save_inspection_data(self._current_order_code, order_id, tray_id, config_position, config_id, formatted_value, status) # 不需要在这里主动触发数据重新加载,因为handle_inspection_cell_changed会处理 @@ -3923,10 +3942,13 @@ class MainWindow(MainWindowUI): # 释放锁 self._set_inspection_value_lock = False - def handle_tray_changed(self): + def handle_tray_changed(self, tray_id=None): """处理托盘号变更事件,启动监听并加载数据""" try: - tray_id = self.tray_edit.currentText() + # 如果没有提供托盘号,则使用当前文本框中的值 + if tray_id is None: + tray_id = self.tray_edit.text() + if tray_id: logging.info(f"托盘号变更为 {tray_id},启动监听") # 初始化托盘号对应的序号(如果不存在) @@ -4294,7 +4316,7 @@ class MainWindow(MainWindowUI): continue # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 如果开启 api 模式,则调用接口删除远程数据 if AppMode.is_api(): @@ -4391,7 +4413,7 @@ class MainWindow(MainWindowUI): continue # 获取托盘号(从前端组件获取) - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() if not tray_id: logging.warning("托盘号为空,跳过删除") continue @@ -4445,7 +4467,7 @@ class MainWindow(MainWindowUI): """ try: # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() if not tray_id: QMessageBox.warning(self, "提示", "请先选择托盘号") return @@ -4822,7 +4844,7 @@ class MainWindow(MainWindowUI): if gc_note_item: row_gc_note = gc_note_item.text().strip() if row_gc_note: # 确保工程号不为空 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() status = inspection_dao.get_product_status(self._current_order_code, row_gc_note, tray_id) if status == target_status: logging.info(f"找到状态为{target_status}的行: {row}, 工程号: {row_gc_note}") @@ -4835,7 +4857,7 @@ class MainWindow(MainWindowUI): if gc_note_item: row_gc_note = gc_note_item.text().strip() if row_gc_note: # 确保工程号不为空 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() status = inspection_dao.get_product_status(self._current_order_code, row_gc_note, tray_id) if status == target_status: logging.info(f"从头开始找到状态为{target_status}的行: {row}, 工程号: {row_gc_note}") @@ -4887,7 +4909,7 @@ class MainWindow(MainWindowUI): return # 获取托盘号 - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() @@ -4995,7 +5017,7 @@ class MainWindow(MainWindowUI): return False gc_note = gc_note_item.text().strip() - tray_id = self.tray_edit.currentText() + tray_id = self.tray_edit.text() # 获取启用的检验配置 enabled_configs = self.inspection_manager.get_enabled_configs() diff --git a/widgets/unloading_dialog_widget.py b/widgets/unloading_dialog_widget.py index 245f6cc..b4e5564 100644 --- a/widgets/unloading_dialog_widget.py +++ b/widgets/unloading_dialog_widget.py @@ -178,20 +178,13 @@ class UnloadingDialog(UnloadingDialogUI): main_window = self.parent if main_window and isinstance(main_window, MainWindow): # 检查托盘号是否已存在 - existed = False - for i in range(main_window.tray_edit.count()): - if main_window.tray_edit.itemText(i) == tray_code: - existed = True - break - - # 如果不存在,则添加 - if not existed: - logging.info(f"添加托盘号到主窗口: {tray_code}") - main_window.tray_edit.addItem(tray_code) - - # 设置当前选中的托盘号 - main_window.tray_edit.setCurrentText(tray_code) + # 由于 tray_edit 现在是 QLineEdit,不再需要检查是否存在 + # 直接设置文本 logging.info(f"设置主窗口当前托盘号: {tray_code}") + main_window.tray_edit.setText(tray_code) + + # 手动触发托盘号变更事件 + main_window.handle_tray_changed(tray_code) except Exception as e: logging.error(f"查询托盘信息异常: {str(e)}")