Files
playwrite/main_ui.py
Misaka_Company 04b99292ad feat: implement user authentication and permission-based data filtering
Add user login system with role-based access control:
- Admin users see all data and can filter by any manager
- Regular users only see records where ManagerName matches their username

New components:
- BIPUsersDAO: user authentication and management
- SessionManager: singleton session state management
- LoginDialog: modal login UI for app startup
- init_users.sql: initial user setup script

Permission enforcement:
- Material validation tab: hide manager filter for non-admin, force filter by current user
- Material type management: hide filter UI for non-admin, filter at database level
- Window title and status bar display current user info

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-09 18:17:31 +08:00

60 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ERP 自动化工具 - GUI 版本
这是一个基于 Tkinter 的图形用户界面应用程序,
用于自动化 ERP 系统(用友 YonBIP的数据提取、校验和查询任务。
运行方式:
python main_ui.py
功能:
- 数据提取:从 ERP 系统提取备料计划数据
- 物料校验:校验物料状态并匹配待删除物料
- 数据查询:查询生产订单号等信息
- 设置管理:管理系统配置
- 用户认证:基于用户权限的数据访问控制
"""
import tkinter as tk
from tkinter import messagebox
from gui.main_window import MainWindow
from gui.login_dialog import LoginDialog
from auth.session_manager import SessionManager
def main():
"""主函数"""
# 创建根窗口
root = tk.Tk()
# 显示登录对话框
login_dialog = LoginDialog(root)
credentials = login_dialog.get_credentials()
if not credentials:
# 用户取消登录或关闭对话框
root.destroy()
return
username, password = credentials
# 认证并初始化会话
session_manager = SessionManager.get_instance()
if not session_manager.login(username, password):
messagebox.showerror("登录失败", "用户名或密码错误")
root.destroy()
return
# 创建主窗口(传入 session_manager
app = MainWindow(root, session_manager)
# 启动主事件循环
root.mainloop()
if __name__ == "__main__":
main()