97 lines
4.2 KiB
C++
97 lines
4.2 KiB
C++
#include "../mainwindow.h"
|
|
|
|
#include <QLabel>
|
|
#include <QVBoxLayout>
|
|
#include <QWidget>
|
|
#include <QFrame>
|
|
#include <QHBoxLayout>
|
|
|
|
#include "core/his_core.h"
|
|
|
|
void MainWindow::setupDashboardTab() {
|
|
dashboardTab_ = new QWidget(this);
|
|
auto* layout = new QVBoxLayout(dashboardTab_);
|
|
layout->setContentsMargins(30, 30, 30, 30);
|
|
layout->setSpacing(20);
|
|
|
|
auto* headerLabel = new QLabel(tr("🏥 医院信息系统总览"), dashboardTab_);
|
|
headerLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: #f9fafb; padding: 10px 0;");
|
|
|
|
auto* statsContainer = new QWidget(dashboardTab_);
|
|
statsContainer->setStyleSheet("background-color: #1f2937; border-radius: 12px; padding: 20px;");
|
|
auto* statsLayout = new QHBoxLayout(statsContainer);
|
|
statsLayout->setSpacing(20);
|
|
|
|
auto createStatCard = [&](const QString& icon, const QString& title, const QString& value, const QString& color) -> QWidget* {
|
|
auto* card = new QWidget(statsContainer);
|
|
card->setStyleSheet(QString("background-color: %1; border-radius: 8px; padding: 15px;").arg(color));
|
|
auto* cardLayout = new QVBoxLayout(card);
|
|
cardLayout->setContentsMargins(10, 10, 10, 10);
|
|
|
|
auto* iconLabel = new QLabel(icon, card);
|
|
iconLabel->setStyleSheet("font-size: 28px;");
|
|
|
|
auto* valueLabel = new QLabel(value, card);
|
|
valueLabel->setStyleSheet("font-size: 32px; font-weight: bold; color: #ffffff;");
|
|
|
|
auto* titleLabel = new QLabel(title, card);
|
|
titleLabel->setStyleSheet("font-size: 14px; color: #d1d5db;");
|
|
|
|
cardLayout->addWidget(iconLabel);
|
|
cardLayout->addWidget(valueLabel);
|
|
cardLayout->addWidget(titleLabel);
|
|
return card;
|
|
};
|
|
|
|
wardStatCard_ = createStatCard("🛏️", tr("病房"), "0", "rgba(59, 130, 246, 0.3)");
|
|
patientStatCard_ = createStatCard("👥", tr("患者"), "0", "rgba(16, 185, 129, 0.3)");
|
|
doctorStatCard_ = createStatCard("👨⚕️", tr("医生"), "0", "rgba(245, 158, 11, 0.3)");
|
|
medicineStatCard_ = createStatCard("💊", tr("药品"), "0", "rgba(139, 92, 246, 0.3)");
|
|
checkStatCard_ = createStatCard("🩺", tr("检查"), "0", "rgba(236, 72, 153, 0.3)");
|
|
|
|
statsLayout->addWidget(wardStatCard_);
|
|
statsLayout->addWidget(patientStatCard_);
|
|
statsLayout->addWidget(doctorStatCard_);
|
|
statsLayout->addWidget(medicineStatCard_);
|
|
statsLayout->addWidget(checkStatCard_);
|
|
|
|
summaryLabel_ = new QLabel(tr("正在加载数据..."), dashboardTab_);
|
|
summaryLabel_->setWordWrap(true);
|
|
summaryLabel_->setStyleSheet("font-size: 14px; color: #9ca3af; padding: 15px; background-color: #1f2937; border-radius: 8px;");
|
|
|
|
layout->addWidget(headerLabel);
|
|
layout->addWidget(statsContainer);
|
|
layout->addWidget(summaryLabel_);
|
|
layout->addStretch(1);
|
|
}
|
|
|
|
void MainWindow::refreshDashboard() {
|
|
const auto wardCount = core_.wardService.wardCount();
|
|
const auto patientCount = core_.patientService.patientCount();
|
|
const auto doctorCount = core_.doctorService.doctorCount();
|
|
const auto medicineCount = core_.medicineService.medicineCount();
|
|
const auto checkCount = core_.checkService.checkCount();
|
|
|
|
// Find all stat cards and update their values
|
|
QList<QWidget*> statCards = {wardStatCard_, patientStatCard_, doctorStatCard_, medicineStatCard_, checkStatCard_};
|
|
QList<int> counts = {(int)wardCount, (int)patientCount, (int)doctorCount, (int)medicineCount, (int)checkCount};
|
|
|
|
for (int i = 0; i < statCards.size() && i < 5; ++i) {
|
|
QLayout* layout = statCards[i]->layout();
|
|
if (layout && layout->count() > 1) {
|
|
QLabel* valueLabel = qobject_cast<QLabel*>(layout->itemAt(1)->widget());
|
|
if (valueLabel) {
|
|
valueLabel->setText(QString::number(counts[i]));
|
|
}
|
|
}
|
|
}
|
|
|
|
const QString text = tr("📊 数据统计\n\n") +
|
|
tr("• 病房数量: %1\n").arg((int)wardCount) +
|
|
tr("• 病人数量: %1\n").arg((int)patientCount) +
|
|
tr("• 医生数量: %1\n").arg((int)doctorCount) +
|
|
tr("• 药品种类: %1\n").arg((int)medicineCount) +
|
|
tr("• 检查项目: %1").arg((int)checkCount);
|
|
summaryLabel_->setText(text);
|
|
}
|