feat: 更新加载对话框,调整窗口大小,添加用户名和时间显示,优化主窗口标题,修改用户信息获取逻辑
This commit is contained in:
parent
c257150bdd
commit
d530dfccbc
@ -9,7 +9,7 @@ class LoadingDialogUI(QDialog):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setWindowTitle("上料操作")
|
self.setWindowTitle("上料操作")
|
||||||
self.setFixedSize(600, 250)
|
self.setFixedSize(550, 250)
|
||||||
|
|
||||||
# 设置字体
|
# 设置字体
|
||||||
self.normal_font = QFont("微软雅黑", 12)
|
self.normal_font = QFont("微软雅黑", 12)
|
||||||
@ -86,7 +86,35 @@ class LoadingDialogUI(QDialog):
|
|||||||
# 第一行:订单号和产品
|
# 第一行:订单号和产品
|
||||||
row1 = QHBoxLayout()
|
row1 = QHBoxLayout()
|
||||||
row1.setSpacing(0)
|
row1.setSpacing(0)
|
||||||
|
self.order_label = QLabel("订单号")
|
||||||
|
self.order_label.setFont(self.normal_font)
|
||||||
|
self.order_label.setStyleSheet(label_style)
|
||||||
|
self.order_label.setFixedWidth(100)
|
||||||
|
self.order_label.setFixedHeight(45)
|
||||||
|
|
||||||
|
self.order_input = QLineEdit()
|
||||||
|
self.order_input.setFont(self.normal_font)
|
||||||
|
self.order_input.setPlaceholderText("请扫描订单号")
|
||||||
|
self.order_input.setStyleSheet(input_style)
|
||||||
|
self.order_input.setFixedHeight(45)
|
||||||
|
row1.addWidget(self.order_label)
|
||||||
|
row1.addWidget(self.order_input, 1)
|
||||||
|
container_layout.addLayout(row1)
|
||||||
|
|
||||||
|
# 添加水平分隔布局
|
||||||
|
split_layout = QHBoxLayout()
|
||||||
|
split_layout.setSpacing(0)
|
||||||
|
left_split = QLabel()
|
||||||
|
left_split.setFixedWidth(100)
|
||||||
|
left_split.setFixedHeight(1)
|
||||||
|
left_split.setStyleSheet("background-color: #e0e0e0;")
|
||||||
|
right_split = QLabel()
|
||||||
|
right_split.setFixedHeight(1)
|
||||||
|
right_split.setStyleSheet("background-color: #e0e0e0;")
|
||||||
|
split_layout.addWidget(left_split)
|
||||||
|
split_layout.addWidget(right_split, 1)
|
||||||
|
container_layout.addLayout(split_layout)
|
||||||
|
|
||||||
# 第二行:托盘号
|
# 第二行:托盘号
|
||||||
row2 = QHBoxLayout()
|
row2 = QHBoxLayout()
|
||||||
row2.setSpacing(0)
|
row2.setSpacing(0)
|
||||||
@ -107,6 +135,20 @@ class LoadingDialogUI(QDialog):
|
|||||||
row2.addWidget(self.tray_input, 1)
|
row2.addWidget(self.tray_input, 1)
|
||||||
container_layout.addLayout(row2)
|
container_layout.addLayout(row2)
|
||||||
|
|
||||||
|
# 添加水平分隔布局
|
||||||
|
split_layout2 = QHBoxLayout()
|
||||||
|
split_layout2.setSpacing(0)
|
||||||
|
left_split2 = QLabel()
|
||||||
|
left_split2.setFixedWidth(100)
|
||||||
|
left_split2.setFixedHeight(1)
|
||||||
|
left_split2.setStyleSheet("background-color: #e0e0e0;")
|
||||||
|
right_split2 = QLabel()
|
||||||
|
right_split2.setFixedHeight(1)
|
||||||
|
right_split2.setStyleSheet("background-color: #e0e0e0;")
|
||||||
|
split_layout2.addWidget(left_split2)
|
||||||
|
split_layout2.addWidget(right_split2, 1)
|
||||||
|
container_layout.addLayout(split_layout2)
|
||||||
|
|
||||||
# 第三行:轴型和托盘料
|
# 第三行:轴型和托盘料
|
||||||
row3 = QHBoxLayout()
|
row3 = QHBoxLayout()
|
||||||
row3.setSpacing(0)
|
row3.setSpacing(0)
|
||||||
|
|||||||
@ -4,12 +4,13 @@ from PySide6.QtWidgets import (
|
|||||||
QPushButton, QLineEdit, QAbstractItemView, QComboBox
|
QPushButton, QLineEdit, QAbstractItemView, QComboBox
|
||||||
)
|
)
|
||||||
from PySide6.QtGui import QFont, QAction, QBrush, QColor
|
from PySide6.QtGui import QFont, QAction, QBrush, QColor
|
||||||
from PySide6.QtCore import Qt
|
from PySide6.QtCore import Qt, QDateTime, QTimer
|
||||||
|
|
||||||
class MainWindowUI(QMainWindow):
|
class MainWindowUI(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self,username):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setWindowTitle("腾智微丝产线包装系统")
|
self.username = username
|
||||||
|
self.setWindowTitle(f"腾智微丝产线包装系统")
|
||||||
self.resize(1200, 800)
|
self.resize(1200, 800)
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
|
|
||||||
@ -65,12 +66,46 @@ class MainWindowUI(QMainWindow):
|
|||||||
self.system_menu.addAction(self.settings_action)
|
self.system_menu.addAction(self.settings_action)
|
||||||
|
|
||||||
def create_left_panel(self):
|
def create_left_panel(self):
|
||||||
# 标题
|
# 创建标题容器
|
||||||
|
self.title_container = QWidget()
|
||||||
|
self.title_layout = QHBoxLayout(self.title_container)
|
||||||
|
self.title_layout.setContentsMargins(10, 10, 10, 10)
|
||||||
|
self.title_layout.setSpacing(10)
|
||||||
|
|
||||||
|
# 创建用户名标签
|
||||||
|
self.username_label = QLabel(self.username)
|
||||||
|
username_font = QFont("微软雅黑", 12) # 较小的字体
|
||||||
|
self.username_label.setFont(username_font)
|
||||||
|
self.username_label.setStyleSheet("color: #666666;")
|
||||||
|
self.username_label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
|
|
||||||
|
# 创建主标题标签
|
||||||
self.title_label = QLabel("腾智微丝产线包装系统")
|
self.title_label = QLabel("腾智微丝产线包装系统")
|
||||||
self.title_label.setFont(self.title_font)
|
self.title_label.setFont(self.title_font) # 较大的字体
|
||||||
self.title_label.setAlignment(Qt.AlignCenter)
|
self.title_label.setAlignment(Qt.AlignCenter)
|
||||||
self.title_label.setStyleSheet("color: #1a237e; padding: 10px; background-color: #f5f5f5; border-radius: 4px;")
|
self.title_label.setStyleSheet("color: #1a237e;")
|
||||||
self.left_layout.addWidget(self.title_label)
|
|
||||||
|
# 创建时间标签
|
||||||
|
self.time_label = QLabel()
|
||||||
|
time_font = QFont("微软雅黑", 12) # 较小的字体
|
||||||
|
self.time_label.setFont(time_font)
|
||||||
|
self.time_label.setStyleSheet("color: #666666;")
|
||||||
|
self.time_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||||
|
|
||||||
|
# 创建定时器更新时间
|
||||||
|
self.timer = QTimer(self)
|
||||||
|
self.timer.timeout.connect(self.update_time)
|
||||||
|
self.timer.start(1000) # 每秒更新一次
|
||||||
|
self.update_time() # 立即更新一次时间
|
||||||
|
|
||||||
|
# 将标签添加到标题布局中
|
||||||
|
self.title_layout.addWidget(self.username_label, 1)
|
||||||
|
self.title_layout.addWidget(self.title_label, 2) # 中间标题占据更多空间
|
||||||
|
self.title_layout.addWidget(self.time_label, 1)
|
||||||
|
|
||||||
|
# 设置标题容器的样式
|
||||||
|
self.title_container.setStyleSheet("background-color: #f5f5f5; border-radius: 4px;")
|
||||||
|
self.left_layout.addWidget(self.title_container)
|
||||||
|
|
||||||
# 项目信息表格 - 使用QFrame包裹,添加边框
|
# 项目信息表格 - 使用QFrame包裹,添加边框
|
||||||
self.project_frame = QFrame()
|
self.project_frame = QFrame()
|
||||||
@ -665,4 +700,8 @@ class MainWindowUI(QMainWindow):
|
|||||||
packaging_start_col = 2 + self.inspection_columns
|
packaging_start_col = 2 + self.inspection_columns
|
||||||
self.process_table.setColumnWidth(packaging_start_col, 140) # 贴标
|
self.process_table.setColumnWidth(packaging_start_col, 140) # 贴标
|
||||||
self.process_table.setColumnWidth(packaging_start_col + 1, 140) # 毛重
|
self.process_table.setColumnWidth(packaging_start_col + 1, 140) # 毛重
|
||||||
self.process_table.setColumnWidth(packaging_start_col + 2, 140) # 净重
|
self.process_table.setColumnWidth(packaging_start_col + 2, 140) # 净重
|
||||||
|
|
||||||
|
def update_time(self):
|
||||||
|
current_time = QDateTime.currentDateTime().toString('yyyy-MM-dd hh:mm:ss')
|
||||||
|
self.time_label.setText(current_time)
|
||||||
@ -32,7 +32,7 @@ def get_user_info(user_id):
|
|||||||
try:
|
try:
|
||||||
if AppMode.is_api():
|
if AppMode.is_api():
|
||||||
db = SQLUtils(source_name='postgresql')
|
db = SQLUtils(source_name='postgresql')
|
||||||
db.execute_query("select t1.user_id,t2.corp_name,t1.corp_id from x_userinfo t1 left join x_corp t2 on t1.corp_id = t2.corp_id where user_id = %s", (user_id,))
|
db.execute_query("select t1.user_id,t1.user_name,t2.corp_name,t1.corp_id from x_userinfo t1 left join x_corp t2 on t1.corp_id = t2.corp_id where user_id = %s", (user_id,))
|
||||||
result = db.fetchone()
|
result = db.fetchone()
|
||||||
db.close()
|
db.close()
|
||||||
return result
|
return result
|
||||||
@ -83,11 +83,9 @@ class LoginWidget(LoginUI):
|
|||||||
return
|
return
|
||||||
if check_user_login(user_id, password):
|
if check_user_login(user_id, password):
|
||||||
try:
|
try:
|
||||||
user_name, corp_name, corp_id = get_user_info(user_id)
|
user_id, user_name, corp_name, corp_id = get_user_info(user_id)
|
||||||
if not corp_name:
|
if not corp_name:
|
||||||
corp_name = "未知公司"
|
corp_name = "未知公司"
|
||||||
# 移除登录成功的弹框
|
|
||||||
# QMessageBox.information(self, "登录成功", f"欢迎 {user_name}!")
|
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
# 使用异常处理确保主窗口创建失败不会导致整个应用程序崩溃
|
# 使用异常处理确保主窗口创建失败不会导致整个应用程序崩溃
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class MainWindow(MainWindowUI):
|
|||||||
"""主窗口"""
|
"""主窗口"""
|
||||||
|
|
||||||
def __init__(self, user_id=None, user_name=None, corp_name=None, corp_id=None):
|
def __init__(self, user_id=None, user_name=None, corp_name=None, corp_id=None):
|
||||||
super().__init__()
|
super().__init__(user_name)
|
||||||
|
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
self.user_name = user_name
|
self.user_name = user_name
|
||||||
@ -58,7 +58,7 @@ class MainWindow(MainWindowUI):
|
|||||||
|
|
||||||
# 设置窗口标题
|
# 设置窗口标题
|
||||||
if user_name and corp_name:
|
if user_name and corp_name:
|
||||||
self.setWindowTitle(f"腾智微丝产线包装系统 - {user_name} ({corp_name})")
|
self.setWindowTitle(f"腾智微丝产线包装系统 ({corp_name})")
|
||||||
|
|
||||||
# 加载配置文件
|
# 加载配置文件
|
||||||
self.config = self.load_config()
|
self.config = self.load_config()
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
{'note': 'JT2504019', 'type_name': '不锈钢丝', 'code': 'CP02013', 'corp': '江苏佳腾', 'spack': 'JT2504019-0005', 'tqd': '780', 'zx_name': 'DIN-355/ABS无字白轴', 'cdname': '待定', 'bzfs': '托盘上大纸箱', 'bccd': '0.494', 'type': 'ZL00', 'bz_bqd': '700', 'maxsl': 35.45, 'ysl': None, 'khjq': '2025-05-31', 'price': 19.2, 'sl': 4600.0, 'spack_type': '木托', 'ddzl': '外销合同', 'qfqd': None, 'customerexp': 'JW', 'zzyq': '42-44', 'cd': '待定', 'mo': 'JT2504019-1', 'dycz': None, 'tccd': '0.506', 'zx_code': 'ZX0023', 'bqlb': '14', 'khno': 'SCJW25-010Add', 'template_name': '日本-白签', 'size': '0.5', 'bqd': None, 'remarks_hb': 'G01|生产注意产品表面及排线,装箱时做好固定,外箱相连两侧各贴一张标签,每箱27轴|42-44公斤/轴,27轴/箱', 'mxid': 17321, 'ddyq': '42-44公斤/轴,27轴/箱', 'cz': '304', 'luno': 'J2410115', 'yzgg': None, 'je': 88320.0, 'zx_zl': '1.95', 'remarks': '42-44公斤/轴,27轴/箱', 'rq': '2025-04-08', 'bz_tqd': '800', 'customer': 'JTDW00070'}
|
|
||||||
size 线径
|
|
||||||
zx_zl 工字轮重量
|
|
||||||
|
|
||||||
{
|
|
||||||
"data_corp":,
|
|
||||||
"user_id":,
|
|
||||||
"user_name":,
|
|
||||||
"gzl_zl":,
|
|
||||||
"mzl":,
|
|
||||||
"ddmo":,
|
|
||||||
"xpack":,
|
|
||||||
"sc_gch":,
|
|
||||||
"qd":,
|
|
||||||
"spack_type":,
|
|
||||||
"mxzs":,
|
|
||||||
"jt":,
|
|
||||||
"ddnote":,
|
|
||||||
"code": ,
|
|
||||||
"type":,
|
|
||||||
"lable":,
|
|
||||||
"lib":,
|
|
||||||
"gzl":,
|
|
||||||
"maxsl":,
|
|
||||||
"cz":,
|
|
||||||
"size":,
|
|
||||||
"cd":,
|
|
||||||
"luno":,
|
|
||||||
"qfqd":,
|
|
||||||
"pono":,
|
|
||||||
"xj":,
|
|
||||||
"ysl":,
|
|
||||||
"dycz":,
|
|
||||||
"zh":,
|
|
||||||
"edit_id":,
|
|
||||||
"remarks":,
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user