图样 1
代码 1:
# -*- coding: utf-8 -*-
import sys
from PySide6.QtCore import (QCoreApplication, QMetaObject, QRect, QDate)
from PySide6.QtGui import QIcon, QPixmap, QColor
from PySide6.QtWidgets import (QApplication, QDialog, QLineEdit, QPushButton, QTabWidget, QWidget, QLabel, QTabBar, QTableWidget, QTableWidgetItem, QComboBox, QRadioButton, QHeaderView, QHBoxLayout, QDateEdit, QCheckBox)
from PySide6.QtCore import Qt
from PySide6.QtWebEngineWidgets import QWebEngineView
from PySide6.QtCore import QUrl
import webbrowser
class Ui_Dialog(object):
def setupUi(self, Dialog):
if not Dialog.objectName():
Dialog.setObjectName(u"智慧米")
Dialog.resize(1200, 800)
Dialog.setWindowTitle("智慧米")
# 顶部工具栏
self.top_bar = QWidget(Dialog)
self.top_bar.setGeometry(QRect(0, 0, 1200, 60))
self.top_bar.setStyleSheet("background-color: #00B4D8;")
# Logo和标题
self.logo_label = QLabel(self.top_bar)
self.logo_label.setGeometry(QRect(20, 10, 40, 40))
self.title_label = QLabel(self.top_bar)
self.title_label.setGeometry(QRect(70, 15, 100, 30))
self.title_label.setText("智慧米")
self.title_label.setStyleSheet("color: white; font-size: 18px;")
# 顶部导航按钮
nav_buttons = ["首页", "报表", "微店", "VIP", "设置"]
nav_icons = ["home.png", "report.png", "store.png", "vip.png", "settings.png"]
self.nav_buttons = {} # 添加这行来存储导航按钮引用
for i, (text, icon) in enumerate(zip(nav_buttons, nav_icons)):
btn = QPushButton(self.top_bar)
btn.setGeometry(QRect(200 + i*100, 10, 80, 40))
btn.setText(text)
btn.setStyleSheet("color: white;")
self.nav_buttons[text] = btn # 保存按钮引用
# 搜索框
self.search_edit = QLineEdit(self.top_bar)
self.search_edit.setGeometry(QRect(800, 15, 200, 30))
self.search_edit.setPlaceholderText("输入货品名称或拼音首字母")
# 主要内容区域的Tab Widget
self.tabWidget = QTabWidget(Dialog)
self.tabWidget.setGeometry(QRect(0, 70, 1200, 700))
self.tabWidget.setStyleSheet("""
QTabWidget::pane {
border: none;
background: white;
}
QTabBar::tab {
background: white;
border: 1px solid #ddd;
padding: 5px 10px;
margin-right: 2px;
}
QTabBar::tab:selected {
background: #00B4D8;
color: white;
}
""")
self.tabWidget.setTabsClosable(True)
self.tabWidget.tabBar().setTabButton(0, QTabBar.RightSide, None)
# 首页标签
self.tab_home = QWidget()
self.tab_home.setObjectName(u"tab_home")
# 在首页中添加功能按钮
button_info = [
("销售单", "sales.png", 50, 50),
("进货单", "purchase.png", 200, 50),
("收款单", "receipt.png", 350, 50),
("付款单", "payment.png", 500, 50),
("货品库存", "inventory.png", 50, 180),
("客户管理", "customer.png", 200, 180),
("供应商管理", "supplier.png", 350, 180),
("大客户报价", "quote.png", 500, 180),
("资金流水", "finance.png", 50, 310),
("智慧门店", "smart_store.png", 200, 310),
("智慧微店", "micro_store.png", 350, 310),
("行业热销", "trending.png", 500, 310),
("更多功能", "more.png", 50, 440)
]
# 保存按钮引用
self.function_buttons = {}
for text, icon, x, y in button_info:
btn = QPushButton(self.tab_home)
btn.setGeometry(QRect(x, y, 120, 100))
btn.setText(text)
btn.setStyleSheet("""
QPushButton {
background-color: white;
border: 1px solid #ddd;
border-radius: 5px;
}
QPushButton:hover {
background-color: #f0f0f0;
}
""")
# 保存按钮引用
self.function_buttons[text] = btn
# 右侧VIP广告区
self.vip_widget = QWidget(self.tab_home)
self.vip_widget.setGeometry(QRect(700, 50, 450, 300))
self.vip_title = QLabel(self.vip_widget)
self.vip_title.setGeometry(QRect(0, 0, 450, 40))
self.vip_title.setText("开通VIP享受更多高级功能")
self.vip_title.setStyleSheet("font-size: 16px; font-weight: bold;")
self.vip_subtitle = QLabel(self.vip_widget)
self.vip_subtitle.setGeometry(QRect(0, 50, 450, 30))
self.vip_subtitle.setText("手机电脑数据云同步")
# VIP按钮
self.try_button = QPushButton("免费试用", self.vip_widget)
self.try_button.setGeometry(QRect(50, 250, 100, 35))
self.buy_button = QPushButton("立即购", self.vip_widget)
self.buy_button.setGeometry(QRect(170, 250, 100, 35))
self.buy_button.setStyleSheet("background-color: #00B4D8; color: white;")
self.tabWidget.addTab(self.tab_home, "首页")
# 设置标签页样式
self.tabWidget.setStyleSheet("""
QTabWidget::pane {
border: 1px solid #ddd;
background: white;
}
QTabWidget::tab-bar {
left: 5px;
}
QTabBar::tab {
background: white;
border: 1px solid #ddd;
padding: 5px 10px;
margin-right: 2px;
}
QTabBar::tab:selected {
background: #00B4D8;
color: white;
}
""")
class MainWindow(QDialog):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_Dialog()
self.ui.setupUi(self)
# 连接导航按钮的点击事件
nav_actions = {
"首页": self.show_home_tab,
"报表": self.open_report_tab,
"微店": self.open_web_store_tab,
"VIP": self.open_vip_tab,
"设置": self.open_settings_tab
}
for button_text, action in nav_actions.items():
if button_text in self.ui.nav_buttons:
self.ui.nav_buttons[button_text].clicked.connect(action)
# 连接所有功能按钮的点击事件
button_actions = {
"销售单": self.open_sales_tab,
"进货单": self.open_purchase_tab,
"收款单": self.open_receipt_tab,
"付款单": self.open_payment_tab,
"货品库存": self.open_inventory_tab,
"客户管理": self.open_customer_tab,
"供应商管理": self.open_supplier_tab,
"大客户报价": self.open_quote_tab,
"资金流水": self.open_finance_tab,
"智慧门店": self.open_smart_store_tab,
"智慧微店": self.open_micro_store_tab,
"行业热销": self.open_trending_tab,
"更多功能": self.open_more_functions_tab
}
for button_text, action in button_actions.items():
if button_text in self.ui.function_buttons:
self.ui.function_buttons[button_text].clicked.connect(action)
# 添加标签页关闭事件处理
self.ui.tabWidget.tabCloseRequested.connect(self.close_tab)
def create_tab(self, title):
"""通用创建标签页的方法"""
# 检查是否已经存在该标签页
for i in range(self.ui.tabWidget.count()):
if self.ui.tabWidget.tabText(i) == title:
self.ui.tabWidget.setCurrentIndex(i)
return None
# 创建新标签页
new_tab = QWidget()
new_tab.setObjectName(f"{title}_tab")
new_tab.setMinimumSize(1200, 700) # 设置最小尺寸
# 添加新标签页
index = self.ui.tabWidget.addTab(new_tab, title)
self.ui.tabWidget.setCurrentIndex(index)
return new_tab
def close_tab(self, index):
# 不允许关闭首页
if index != 0:
self.ui.tabWidget.removeTab(index)
def open_sales_tab(self):
tab = self.create_tab("销售单")
if tab is None: # 如��标签页已存在,直接返回
return
# 创建一个容器widget来包含所有控件
container = QWidget(tab)
container.setGeometry(QRect(0, 0, 1200, 700))
container.setStyleSheet("""
QWidget {
background-color: white;
}
QPushButton {
border: 1px solid #ddd;
padding: 5px 10px;
min-width: 80px;
}
QComboBox {
border: 1px solid #ddd;
padding: 5px;
}
""")
# 顶部标题和单据编号
doc_number = QLabel("单据编号: XSD2024120003.A", container)
doc_number.setGeometry(QRect(20, 20, 300, 30))
doc_number.setStyleSheet("font-size: 14px; color: #333;")
# 销售类型单选按钮
self.radio_sales_out = QRadioButton("销售出货", container)
self.radio_sales_out.setGeometry(QRect(20, 60, 100, 30))
self.radio_sales_out.setChecked(True)
self.radio_sales_return = QRadioButton("销售退货", container)
self.radio_sales_return.setGeometry(QRect(120, 60, 100, 30))
# 客户选择
customer_label = QLabel("客户名称:", container)
customer_label.setGeometry(QRect(230, 60, 70, 30))
self.customer_combo = QComboBox(container)
self.customer_combo.setGeometry(QRect(300, 60, 200, 30))
self.customer_combo.setEditable(True)
self.customer_combo.setPlaceholderText("请输入客户名称或手机号")
# 添加日期选择
date_label = QLabel("单据日期:", container)
date_label.setGeometry(QRect(520, 60, 70, 30))
self.date_edit = QDateEdit(container)
self.date_edit.setGeometry(QRect(590, 60, 120, 30))
self.date_edit.setCalendarPopup(True)
self.date_edit.setDate(QDate.currentDate())
self.date_edit.setDisplayFormat("yyyy-MM-dd")
# 表格
self.sales_table = QTableWidget(container)
self.sales_table.setGeometry(QRect(20, 100, 1160, 300)) # 减小表格高度
self.sales_table.setStyleSheet("""
QTableWidget {
border: 1px solid #ddd;
gridline-color: #ddd;
background-color: white;
}
QHeaderView::section {
background-color: #f0f0f0;
padding: 4px;
border: 1px solid #ddd;
font-weight: bold;
}
""")
# 设置表格列数和列标题
headers = ["行号", "品名规格", "单位", "货品类别", "数量", "单价", "金额", "备注"]
self.sales_table.setColumnCount(len(headers))
self.sales_table.setHorizontalHeaderLabels(headers)
# 设置表格列宽
column_widths = [60, 300, 80, 100, 100, 100, 100, 320]
for i, width in enumerate(column_widths):
self.sales_table.setColumnWidth(i, width)
# 底部控件区域
bottom_y = 420 # 调整底部起始位置
# 说明文本框
note_label = QLabel("说明:", container)
note_label.setGeometry(QRect(20, bottom_y, 40, 30))
self.note_edit = QLineEdit(container)
self.note_edit.setGeometry(QRect(60, bottom_y, 500, 30))
self.note_edit.setPlaceholderText("在此可录入订单号、货运单号及其他相关信息,以便查询")
# 第二行控件
bottom_y2 = bottom_y + 50 # 增加间距
# 折后金额
discount_label = QLabel("折后金额:", container)
discount_label.setGeometry(QRect(20, bottom_y2, 60, 30))
self.discount_amount = QLineEdit(container)
self.discount_amount.setGeometry(QRect(80, bottom_y2, 100, 30))
self.discount_amount.setReadOnly(True)
# 整单折扣率
discount_rate_label = QLabel("整单折扣率:", container)
discount_rate_label.setGeometry(QRect(200, bottom_y2, 70, 30))
self.discount_rate = QLineEdit(container)
self.discount_rate.setGeometry(QRect(270, bottom_y2, 60, 30))
self.discount_rate.setText("100")
percent_label = QLabel("%", container)
percent_label.setGeometry(QRect(335, bottom_y2, 20, 30))
# 运费
shipping_label = QLabel("运费:", container)
shipping_label.setGeometry(QRect(370, bottom_y2, 40, 30))
self.shipping_fee = QLineEdit(container)
self.shipping_fee.setGeometry(QRect(410, bottom_y2, 80, 30))
self.shipping_fee.setText("0")
# 本单应收
receivable_label = QLabel("本单应收:", container)
receivable_label.setGeometry(QRect(510, bottom_y2, 60, 30))
self.receivable_amount = QLineEdit(container)
self.receivable_amount.setGeometry(QRect(570, bottom_y2, 100, 30))
self.receivable_amount.setReadOnly(True)
# 营业员
sales_person_label = QLabel("营业员:", container)
sales_person_label.setGeometry(QRect(690, bottom_y2, 50, 30))
self.sales_person_combo = QComboBox(container)
self.sales_person_combo.setGeometry(QRect(740, bottom_y2, 100, 30))
self.sales_person_combo.setEditable(True)
# 部按钮区
bottom_y3 = bottom_y2 + 50 # 增加间距
# 添加底部按钮
buttons = [
("查看历史单据(L)", 20),
("导入(I)", 120),
("查看收款记录", 220),
("扫码收银", 560),
("保存并新增(S)", 660),
("打印(P)", 760),
("预览", 860),
("清空(C)", 960)
]
for text, x in buttons:
btn = QPushButton(text, container)
btn.setGeometry(QRect(x, bottom_y3, 100, 30))
if text in ["保�������并���增(S)", "���印(P)"]:
btn.setStyleSheet("background-color: #00B4D8; color: white;")
# 显示容器
container.show()
def open_purchase_tab(self):
tab = self.create_tab("进货单")
if tab is None: # 如果标签页已存在,直接返回
return
# 创建一个容器widget来包含所有控件
container = QWidget(tab)
container.setGeometry(QRect(0, 0, 1200, 700))
container.setStyleSheet("""
QWidget {
background-color: white;
}
QPushButton {
border: 1px solid #ddd;
padding: 5px 10px;
min-width: 80px;
}
QComboBox {
border: 1px solid #ddd;
padding: 5px;
}
""")
# 顶部标题和单据编号
doc_number = QLabel("单据编号: JHD202412001.B", container)
doc_number.setGeometry(QRect(1000, 20, 200, 30))
doc_number.setStyleSheet("color: #666;")
# 单据类型选择
self.radio_purchase_in = QRadioButton("采购进货", container)
self.radio_purchase_in.setGeometry(QRect(20, 20, 100, 30))
self.radio_purchase_in.setChecked(True)
self.radio_purchase_return = QRadioButton("采购退货", container)
self.radio_purchase_return.setGeometry(QRect(130, 20, 100, 30))
# 供应商选择
supplier_label = QLabel("供应商名称:", container)
supplier_label.setGeometry(QRect(20, 60, 80, 30))
self.supplier_combo = QComboBox(container)
self.supplier_combo.setGeometry(QRect(100, 60, 200, 30))
self.supplier_combo.setEditable(True)
self.supplier_combo.setPlaceholderText("请选择供应商")
# 单据日期
date_label = QLabel("单据日期:", container)
date_label.setGeometry(QRect(1000, 60, 70, 30))
self.date_edit = QDateEdit(container)
self.date_edit.setGeometry(QRect(1070, 60, 110, 30))
self.date_edit.setCalendarPopup(True)
self.date_edit.setDate(QDate.currentDate())
self.date_edit.setDisplayFormat("yyyy/MM/dd")
# 创建表格
self.purchase_table = QTableWidget(container)
self.purchase_table.setGeometry(QRect(20, 100, 1160, 400))
# 设置表格样式
self.purchase_table.setStyleSheet("""
QTableWidget {
border: 1px solid #ddd;
gridline-color: #ddd;
background-color: white;
}
QHeaderView::section {
background-color: #f0f0f0;
padding: 4px;
border: 1px solid #ddd;
font-weight: bold;
}
""")
# 设置表格列
headers = ["行号", "品名规格", "单位", "货品类别", "数量", "单价", "金额", "备注"]
self.purchase_table.setColumnCount(len(headers))
self.purchase_table.setHorizontalHeaderLabels(headers)
# 设置列宽
column_widths = [60, 300, 80, 120, 100, 100, 100, 300]
for i, width in enumerate(column_widths):
self.purchase_table.setColumnWidth(i, width)
# 添加12行空数据
self.purchase_table.setRowCount(12)
for row in range(12):
self.purchase_table.setItem(row, 0, QTableWidgetItem(str(row + 1)))
# 底部说明文本框
note_label = QLabel("说明:", container)
note_label.setGeometry(QRect(20, 520, 40, 30))
self.note_edit = QLineEdit(container)
self.note_edit.setGeometry(QRect(60, 520, 500, 30))
self.note_edit.setPlaceholderText("在此可录入订单号、货运单号及其他相关信息,以便查询")
# 折扣和金额区域
discount_label = QLabel("折后金额:", container)
discount_label.setGeometry(QRect(20, 570, 60, 30))
self.discount_amount = QLineEdit(container)
self.discount_amount.setGeometry(QRect(80, 570, 100, 30))
self.discount_amount.setReadOnly(True)
# 整单折扣率
discount_rate_label = QLabel("整单折扣率:", container)
discount_rate_label.setGeometry(QRect(200, 570, 70, 30))
self.discount_rate = QLineEdit(container)
self.discount_rate.setGeometry(QRect(270, 570, 60, 30))
self.discount_rate.setText("100")
percent_label = QLabel("%", container)
percent_label.setGeometry(QRect(335, 570, 20, 30))
# 运费
shipping_label = QLabel("运费:", container)
shipping_label.setGeometry(QRect(370, 570, 40, 30))
self.shipping_fee = QLineEdit(container)
self.shipping_fee.setGeometry(QRect(410, 570, 80, 30))
self.shipping_fee.setText("0")
# 本单应付
payable_label = QLabel("本单应付:", container)
payable_label.setGeometry(QRect(510, 570, 60, 30))
self.payable_amount = QLineEdit(container)
self.payable_amount.setGeometry(QRect(570, 570, 100, 30))
self.payable_amount.setReadOnly(True)
# 营业员
operator_label = QLabel("营业员:", container)
operator_label.setGeometry(QRect(690, 570, 50, 30))
self.operator_combo = QComboBox(container)
self.operator_combo.setGeometry(QRect(740, 570, 100, 30))
self.operator_combo.setEditable(True)
self.operator_combo.addItem("xxyy")
# 本次支付和结算账户
self.payment_amount = QLineEdit(container)
self.payment_amount.setGeometry(QRect(860, 570, 120, 30))
self.payment_amount.setPlaceholderText("本次支付")
self.account_combo = QComboBox(container)
self.account_combo.setGeometry(QRect(1000, 570, 120, 30))
self.account_combo.setEditable(True)
self.account_combo.setPlaceholderText("结算账")
# 底部按钮
buttons = [
("查看历史单据(L)", 20, 620),
("导入(I)", 150, 620),
("查看付款记录", 280, 620),
("保存并新增(S)", 700, 620),
("打印(P)", 800, 620),
("预览", 900, 620),
("清空(C)", 1000, 620)
]
for text, x, y in buttons:
btn = QPushButton(text, container)
btn.setGeometry(QRect(x, y, 100, 30))
if text in ["保存并新增(S)", "打印(P)"]:
btn.setStyleSheet("background-color: #00B4D8; color: white;")
# 确保所有控件显示
container.show()
self.purchase_table.show()
tab.update()
def open_receipt_tab(self):
tab = self.create_tab("收款单")
if tab is None: # 如果标签页已存在,直接返回
return
# 创建一个容器widget来包含所有控件
container = QWidget(tab)
container.setGeometry(QRect(0, 0, 1200, 700))
container.setStyleSheet("""
QWidget {
background-color: white;
}
QPushButton {
border: 1px solid #ddd;
padding: 5px 10px;
min-width: 80px;
}
QComboBox {
border: 1px solid #ddd;
padding: 5px;
}
QLineEdit {
border: 1px solid #ddd;
padding: 5px;
}
""")
# 单据编号
doc_number = QLabel("单据编号: SKD202412001.B", container)
doc_number.setGeometry(QRect(1000, 20, 200, 30))
doc_number.setStyleSheet("color: #666;")
doc_number.show()
# 客户选择
customer_label = QLabel("客户名称:", container)
customer_label.setGeometry(QRect(20, 20, 70, 30))
customer_label.show()
self.customer_combo = QComboBox(container)
self.customer_combo.setGeometry(QRect(90, 20, 200, 30))
self.customer_combo.setEditable(True)
self.customer_combo.setPlaceholderText("请选择客户")
self.customer_combo.show()
# 业务日期
date_label = QLabel("业务日期:", container)
date_label.setGeometry(QRect(1000, 60, 70, 30))
date_label.show()
self.date_edit = QDateEdit(container)
self.date_edit.setGeometry(QRect(1070, 60, 110, 30))
self.date_edit.setCalendarPopup(True)
self.date_edit.setDate(QDate.currentDate())
self.date_edit.setDisplayFormat("yyyy/MM/dd")
self.date_edit.show()
# 创建表格
self.receipt_table = QTableWidget(container)
self.receipt_table.setGeometry(QRect(20, 100, 1160, 400))
# 设置表格样式
self.receipt_table.setStyleSheet("""
QTableWidget {
border: 1px solid #ddd;
gridline-color: #ddd;
background-color: white;
}
QHeaderView::section {
background-color: #f0f0f0;
padding: 4px;
border: 1px solid #ddd;
font-weight: bold;
}
""")
# 设置表格列
headers = ["行号", "账户名称", "金额"]
self.receipt_table.setColumnCount(len(headers))
self.receipt_table.setHorizontalHeaderLabels(headers)
# 设置列宽
column_widths = [60, 800, 300]
for i, width in enumerate(column_widths):
self.receipt_table.setColumnWidth(i, width)
# 添加13行空数据
self.receipt_table.setRowCount(13)
for row in range(13):
self.receipt_table.setItem(row, 0, QTableWidgetItem(str(row + 1)))
if row == 12: # 最后一行是合计行
self.receipt_table.setItem(row, 1, QTableWidgetItem("合计"))
self.receipt_table.setItem(row, 2, QTableWidgetItem("0.00"))
# 设置合计行的背景色
for col in range(3):
item = self.receipt_table.item(row, col)
if item:
item.setBackground(QColor("#E6F3FF"))
self.receipt_table.show()
# 底部说明文本框
note_label = QLabel("说明:", container)
note_label.setGeometry(QRect(20, 520, 40, 30))
note_label.show()
self.note_edit = QLineEdit(container)
self.note_edit.setGeometry(QRect(60, 520, 1120, 30))
self.note_edit.setPlaceholderText("在此可录入相关信息,以便查询")
self.note_edit.show()
# 收款金额和营业员
amount_label = QLabel("收款金额:", container)
amount_label.setGeometry(QRect(800, 570, 70, 30))
amount_label.show()
self.amount_edit = QLineEdit(container)
self.amount_edit.setGeometry(QRect(870, 570, 120, 30))
self.amount_edit.setText("0.00")
self.amount_edit.show()
operator_label = QLabel("营业员:", container)
operator_label.setGeometry(QRect(1000, 570, 50, 30))
operator_label.show()
self.operator_combo = QComboBox(container)
self.operator_combo.setGeometry(QRect(1050, 570, 100, 30))
self.operator_combo.setEditable(True)
self.operator_combo.addItem("xxyy")
self.operator_combo.show()
# 底部按钮
buttons = [
("查看历史单据(L)", 20, 620),
("导入(I)", 150, 620),
("保存并新增(S)", 700, 620),
("打印(P)", 800, 620),
("预览", 900, 620),
("打印模板", 1000, 620),
("清空(C)", 1100, 620)
]
for text, x, y in buttons:
btn = QPushButton(text, container)
btn.setGeometry(QRect(x, y, 100, 30))
if text in ["保存并新增(S)", "打印(P)"]:
btn.setStyleSheet("background-color: #00B4D8; color: white;")
btn.show()
# 确保所有控件显示
container.show()
tab.update()
def open_payment_tab(self):
tab = self.create_tab("付款单")
if tab is None: # 如果标签页已存在,直接返回
return
# 创建一个容器widget来包含所有控件
container = QWidget(tab)
container.setGeometry(QRect(0, 0, 1200, 700))
container.setStyleSheet("""
QWidget {
background-color: white;
}
QPushButton {
border: 1px solid #ddd;
padding: 5px 10px;
min-width: 80px;
}
QComboBox {
border: 1px solid #ddd;
padding: 5px;
}
QLineEdit {
border: 1px solid #ddd;
padding: 5px;
}
""")
# 单据编号
doc_number = QLabel("单据编号: FKD202412001.B", container)
doc_number.setGeometry(QRect(1000, 20, 200, 30))
doc_number.setStyleSheet("color: #666;")
doc_number.show()
# 供应商选择
supplier_label = QLabel("供应商名称:", container)
supplier_label.setGeometry(QRect(20, 20, 80, 30))
supplier_label.show()
self.supplier_combo = QComboBox(container)
self.supplier_combo.setGeometry(QRect(100, 20, 200, 30))
self.supplier_combo.setEditable(True)
self.supplier_combo.setPlaceholderText("请直接输入供应商名称")
self.supplier_combo.show()
# 业务日期
date_label = QLabel("业务日期:", container)
date_label.setGeometry(QRect(1000, 60, 70, 30))
date_label.show()
self.date_edit = QDateEdit(container)
self.date_edit.setGeometry(QRect(1070, 60, 110, 30))
self.date_edit.setCalendarPopup(True)
self.date_edit.setDate(QDate.currentDate())
self.date_edit.setDisplayFormat("yyyy/MM/dd")
self.date_edit.show()
# 创建表格
self.payment_table = QTableWidget(container)
self.payment_table.setGeometry(QRect(20, 100, 1160, 200)) # 减小表格高度
# 设置表格样式
self.payment_table.setStyleSheet("""
QTableWidget {
border: 1px solid #ddd;
gridline-color: #ddd;
background-color: white;
}
QHeaderView::section {
background-color: #f0f0f0;
padding: 4px;
border: 1px solid #ddd;
font-weight: bold;
}
""")
# 设置表格列
headers = ["行号", "账户名称", "金额"]
self.payment_table.setColumnCount(len(headers))
self.payment_table.setHorizontalHeaderLabels(headers)
# 设置列宽
column_widths = [60, 800, 300]
for i, width in enumerate(column_widths):
self.payment_table.setColumnWidth(i, width)
# 添加4行空数据和1行合计行
self.payment_table.setRowCount(5)
for row in range(5):
self.payment_table.setItem(row, 0, QTableWidgetItem(str(row + 1)))
if row == 4: # 最后一行是合计行
self.payment_table.setItem(row, 1, QTableWidgetItem("合计"))
self.payment_table.setItem(row, 2, QTableWidgetItem("0.00"))
# 设置合计行的背景色
for col in range(3):
item = self.payment_table.item(row, col)
if item:
item.setBackground(QColor("#E6F3FF"))
self.payment_table.show()
# 未结算单据列表
unsettled_label = QLabel("未结算单据列表", container)
unsettled_label.setGeometry(QRect(20, 320, 100, 30)) # 调整位置
unsettled_label.show()
# 创建未结算单据表格
self.unsettled_table = QTableWidget(container)
self.unsettled_table.setGeometry(QRect(20, 350, 1160, 200)) # 调整位置和高度
# 设置未结算单据表格列
unsettled_headers = ["���号", "选择", "源单单据", "单据日期", "应付金额", "已付金额", "未付款金额", "本次付款金额", "本次抹零", "说明"]
self.unsettled_table.setColumnCount(len(unsettled_headers))
self.unsettled_table.setHorizontalHeaderLabels(unsettled_headers)
# 设置列宽
unsettled_widths = [60, 60, 150, 100, 100, 100, 100, 100, 100, 290]
for i, width in enumerate(unsettled_widths):
self.unsettled_table.setColumnWidth(i, width)
# 添加5行空数据和1行合计行
self.unsettled_table.setRowCount(6)
for row in range(6):
self.unsettled_table.setItem(row, 0, QTableWidgetItem(str(row + 1)))
if row == 5: # 最后一行是合计行
self.unsettled_table.setItem(row, 2, QTableWidgetItem("合计"))
# 设置合计行的背景色
for col in range(len(unsettled_headers)):
item = QTableWidgetItem("")
item.setBackground(QColor("#E6F3FF"))
self.unsettled_table.setItem(row, col, item)
self.unsettled_table.show()
# 说明文本框
note_label = QLabel("说明:", container)
note_label.setGeometry(QRect(20, 570, 40, 30)) # 调整位置
note_label.show()
self.note_edit = QLineEdit(container)
self.note_edit.setGeometry(QRect(60, 570, 1120, 30)) # 调整位置
self.note_edit.setPlaceholderText("在此可录��相关信息,以便查询")
self.note_edit.show()
# 底部按钮
buttons = [
("查看历史单据(L)", 20, 620), # 调整位置
("导入(I)", 150, 620),
("保存并新增(S)", 700, 620),
("打印(P)", 800, 620),
("预览", 900, 620),
("打印模板", 1000, 620),
("清空(C)", 1100, 620)
]
for text, x, y in buttons:
btn = QPushButton(text, container)
btn.setGeometry(QRect(x, y, 100, 30))
if text in ["保存并新增(S)", "打印(P)"]:
btn.setStyleSheet("background-color: #00B4D8; color: white;")
btn.show()
# 确保所有控件显示
container.show()
tab.update()
def open_inventory_tab(self):
tab = self.create_tab("货品库存")
if tab is None: # 如果标签页已存在,直接返回
return
# 设置tab的背景色
tab.setStyleSheet("background-color: white;")
# 顶部按钮工具栏
buttons = [
("新增货品(N)", 10, 10, 100, 30),
("批量操作", 120, 10, 100, 30),
("导入(I)", 230, 10, 80, 30),
("导出(E)", 320, 10, 80, 30),
("打印(P)", 410, 10, 80, 30),
("预览", 500, 10, 80, 30),
("隐藏零库存(H)", 590, 10, 100, 30),
("按拼音生成计算", 700, 10, 120, 30)
]
for text, x, y, w, h in buttons:
btn = QPushButton(text, tab)
btn.setGeometry(QRect(x, y, w, h))
if text in ["新增货(N)", "打印(P)"]:
btn.setStyleSheet("background-color: #00B4D8; color: white;")
btn.show()
# 索区域
search_label = QLabel("货品:", tab)
search_label.setGeometry(QRect(830, 10, 40, 30))
search_label.show()
self.search_combo = QComboBox(tab)
self.search_combo.setGeometry(QRect(870, 10, 200, 30))
self.search_combo.setEditable(True)
self.search_