feat: 新增线材类型参数获取功能及界面支持
This commit is contained in:
parent
a626aafbf3
commit
c40698c58b
@ -233,3 +233,25 @@ class GcApi:
|
||||
"data": [],
|
||||
"message": f"获取参数信息失败: {str(e)}"
|
||||
}
|
||||
|
||||
def get_wire_type_params(self, corp_id):
|
||||
"""
|
||||
获取线材类型参数信息
|
||||
|
||||
Args:
|
||||
corp_id: 公司ID
|
||||
|
||||
Returns:
|
||||
dict: 线材类型信息列表
|
||||
"""
|
||||
try:
|
||||
# 使用get_params方法,传入线材类型参数
|
||||
return self.get_params("线材类型", "", corp_id)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"获取线材类型参数失败: {str(e)}")
|
||||
return {
|
||||
"status": False,
|
||||
"data": [],
|
||||
"message": f"获取线材类型参数失败: {str(e)}"
|
||||
}
|
||||
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -24,6 +24,7 @@ class MainWindowUI(QMainWindow):
|
||||
"强度": "qd",
|
||||
"延伸要求": "ysl",
|
||||
"线材类型": "jz",
|
||||
"包装方式": "bzfs",
|
||||
"轴重要求": "zzyq",
|
||||
"线径公差": "xj",
|
||||
"备注": "remarks_hb"
|
||||
@ -366,6 +367,24 @@ class MainWindowUI(QMainWindow):
|
||||
value.addItem("不合格库(线材)")
|
||||
value.addItem("废丝库")
|
||||
value.setCurrentIndex(0) # 默认选择第一个
|
||||
elif field_name == "线材类型":
|
||||
# 线材类型字段使用QComboBox,与库房组件配置相同
|
||||
value = QComboBox()
|
||||
value.setFixedHeight(35)
|
||||
value.setStyleSheet("QComboBox { border: 1px solid #cccccc; padding: 3px; background-color: white; } QComboBox::drop-down { border: none; width: 20px; }")
|
||||
value.setFont(QFont("微软雅黑", 12))
|
||||
value.setEditable(False) # 设置为不可编辑,确保是纯下拉选择
|
||||
value.setInsertPolicy(QComboBox.NoInsert) # 不自动插入用户输入到列表中
|
||||
value.setMaxVisibleItems(10) # 设置下拉框最多显示10个项目
|
||||
# 添加默认选项(后续会从API动态加载)
|
||||
value.addItem("请选择")
|
||||
value.setCurrentIndex(0) # 默认选择第一个
|
||||
elif field_name == "包装方式":
|
||||
# 包装方式字段使用QLineEdit,与其他字段保持一致
|
||||
value = QLineEdit("")
|
||||
value.setFont(self.normal_font)
|
||||
value.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
||||
value.setStyleSheet("background-color: white; padding: 5px; border: 1px solid #cccccc;")
|
||||
else:
|
||||
# 其他字段使用QLineEdit
|
||||
value = QLineEdit("")
|
||||
|
||||
@ -228,6 +228,10 @@ class MainWindow(MainWindowUI):
|
||||
# 更新订单数量和产量统计数据
|
||||
self.update_order_statistics()
|
||||
|
||||
# 加载库房和线材类型数据
|
||||
self.load_warehouse_data()
|
||||
self.load_wire_type_data()
|
||||
|
||||
logging.info("主窗口初始化时已启动Modbus监控系统")
|
||||
|
||||
def get_axios_num(self,tray_id):
|
||||
@ -342,6 +346,9 @@ class MainWindow(MainWindowUI):
|
||||
# 加载库房数据
|
||||
self.load_warehouse_data()
|
||||
|
||||
# 加载线材类型数据
|
||||
self.load_wire_type_data()
|
||||
|
||||
logging.info("显示主页面")
|
||||
|
||||
def load_pallet_codes(self):
|
||||
@ -453,6 +460,102 @@ class MainWindow(MainWindowUI):
|
||||
warehouse_combo.addItem("废丝库")
|
||||
warehouse_combo.setCurrentIndex(0)
|
||||
|
||||
def load_wire_type_data(self):
|
||||
"""从API加载线材类型数据并更新到信息表格的线材类型组件"""
|
||||
try:
|
||||
logging.info("开始加载线材类型数据...")
|
||||
# 获取信息表格中的线材类型组件
|
||||
wire_type_combo = self.info_values.get("线材类型")
|
||||
if not wire_type_combo:
|
||||
logging.warning("未找到线材类型组件")
|
||||
logging.info(f"info_values中的键: {list(self.info_values.keys())}")
|
||||
return
|
||||
|
||||
# 获取当前选中的线材类型,以便保留用户选择
|
||||
current_wire_type = wire_type_combo.currentText()
|
||||
|
||||
# 清空当前项目
|
||||
wire_type_combo.clear()
|
||||
|
||||
# 调用API获取线材类型数据
|
||||
from apis.gc_api import GcApi
|
||||
gc_api = GcApi()
|
||||
|
||||
logging.info(f"调用线材类型API,corp_id: {self.corp_id}")
|
||||
# 调用get_wire_type_params接口获取线材类型信息
|
||||
response = gc_api.get_wire_type_params(self.corp_id)
|
||||
logging.info(f"线材类型API响应: {response}")
|
||||
|
||||
if response.get("status", False):
|
||||
wire_type_data = response.get("data", [])
|
||||
|
||||
if wire_type_data and len(wire_type_data) > 0:
|
||||
# 添加线材类型到下拉框
|
||||
for wire_type in wire_type_data:
|
||||
wire_type_name = wire_type.get("combtext", "")
|
||||
if wire_type_name:
|
||||
wire_type_combo.addItem(wire_type_name)
|
||||
|
||||
# 默认选择第一个
|
||||
if wire_type_combo.count() > 0:
|
||||
wire_type_combo.setCurrentIndex(0)
|
||||
|
||||
# 如果有之前的选择,尝试恢复它
|
||||
if current_wire_type and current_wire_type != "请选择":
|
||||
index = wire_type_combo.findText(current_wire_type)
|
||||
if index != -1:
|
||||
wire_type_combo.setCurrentIndex(index)
|
||||
|
||||
logging.info(f"已加载线材类型数据,共 {len(wire_type_data)} 个")
|
||||
else:
|
||||
logging.warning("未找到线材类型数据,线材类型列表将为空")
|
||||
else:
|
||||
# 如果API返回的不是status格式,直接尝试解析数据
|
||||
if isinstance(response, list):
|
||||
wire_type_data = response
|
||||
logging.info(f"直接解析列表数据,共 {len(wire_type_data)} 个")
|
||||
|
||||
if wire_type_data and len(wire_type_data) > 0:
|
||||
# 添加线材类型到下拉框
|
||||
for wire_type in wire_type_data:
|
||||
wire_type_name = wire_type.get("combtext", "")
|
||||
if wire_type_name:
|
||||
wire_type_combo.addItem(wire_type_name)
|
||||
|
||||
# 默认选择第一个
|
||||
if wire_type_combo.count() > 0:
|
||||
wire_type_combo.setCurrentIndex(0)
|
||||
|
||||
# 如果有之前的选择,尝试恢复它
|
||||
if current_wire_type and current_wire_type != "请选择":
|
||||
index = wire_type_combo.findText(current_wire_type)
|
||||
if index != -1:
|
||||
wire_type_combo.setCurrentIndex(index)
|
||||
|
||||
logging.info(f"已加载线材类型数据,共 {len(wire_type_data)} 个")
|
||||
else:
|
||||
logging.warning("未找到线材类型数据,线材类型列表将为空")
|
||||
else:
|
||||
logging.error(f"获取线材类型数据失败: {response}")
|
||||
# 如果API调用失败,添加默认选项
|
||||
wire_type_combo.addItem("经线")
|
||||
wire_type_combo.addItem("纬线")
|
||||
wire_type_combo.addItem("径线-H")
|
||||
wire_type_combo.addItem("径线-J")
|
||||
wire_type_combo.setCurrentIndex(0)
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"加载线材类型数据失败: {str(e)}")
|
||||
# 如果加载失败,添加默认选项
|
||||
wire_type_combo = self.info_values.get("线材类型")
|
||||
if wire_type_combo:
|
||||
wire_type_combo.clear()
|
||||
wire_type_combo.addItem("经线")
|
||||
wire_type_combo.addItem("纬线")
|
||||
wire_type_combo.addItem("径线-H")
|
||||
wire_type_combo.addItem("径线-J")
|
||||
wire_type_combo.setCurrentIndex(0)
|
||||
|
||||
def show_settings_page(self):
|
||||
"""显示设置页面"""
|
||||
# 创建设置窗口
|
||||
|
||||
Loading…
Reference in New Issue
Block a user