diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 46926ed..1b883ac 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,46 +4,50 @@
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+
{
- "associatedIndex": 0
+ "associatedIndex": 7
}
-
+
- {
- "keyToString": {
- "ModuleVcsDetector.initialDetectionPerformed": "true",
- "RunOnceActivity.GoLinterPluginOnboardingV2": "true",
- "RunOnceActivity.GoLinterPluginStorageMigration": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
- "RunOnceActivity.git.unshallow": "true",
- "RunOnceActivity.go.formatter.settings.were.checked": "true",
- "RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
- "RunOnceActivity.typescript.service.memoryLimit.init": "true",
- "git-widget-placeholder": "master",
- "go.sdk.automatically.set": "true",
- "last_opened_file_path": "E:/QTCode/ssp/ssp",
- "nodejs_package_manager_path": "npm"
+
+}]]>
@@ -54,53 +58,15 @@
-
- 1787017192111
+
+ 1794298786565
- 1787017192111
+ 1794298786565
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/layout/Layout.png b/layout/Layout.png
new file mode 100644
index 0000000..e5b2be9
Binary files /dev/null and b/layout/Layout.png differ
diff --git a/layout/layout.qrc b/layout/layout.qrc
new file mode 100644
index 0000000..5a98905
--- /dev/null
+++ b/layout/layout.qrc
@@ -0,0 +1,5 @@
+
+
+ Layout.png
+
+
diff --git a/pages/dashboardpage.cpp b/pages/dashboardpage.cpp
index 877d4a9..744f064 100644
--- a/pages/dashboardpage.cpp
+++ b/pages/dashboardpage.cpp
@@ -16,8 +16,8 @@
#include
#include
#include
+#include
#include
-#include
#include
#include
#include
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -125,6 +126,13 @@ QString displayOrderStatus(const QString &status)
return status.isEmpty() ? "未采集" : status;
}
+QString displayInspectionMode(const QString &mode)
+{
+ if (mode == "BEFORE_PLATING") return "镀金前";
+ if (mode == "AFTER_PLATING") return "镀金后";
+ return mode.isEmpty() ? "未设置" : mode;
+}
+
void updateStatusCell(QLabel *cell, const QString &text, const QString &color,
bool highlighted = false)
{
@@ -132,10 +140,16 @@ void updateStatusCell(QLabel *cell, const QString &text, const QString &color,
return;
}
cell->setText(text);
- cell->setStyleSheet(QString("QLabel { background: %1; border: %2; "
- "border-radius: 3px; color: white; font-size: 11px; }")
- .arg(color)
- .arg(highlighted ? "3px solid #ffb300" : "1px solid #ffffff"));
+ const QString border = highlighted
+ ? "3px solid #ffb300"
+ : QString("1px solid %1").arg(color);
+ const bool compact = cell->property("compactStatus").toBool();
+ cell->setStyleSheet(QString("QLabel { background: rgba(18, 31, 38, 190); "
+ "border: %1; border-radius: 3px; color: white; "
+ "font-size: %2px; padding: %3; }")
+ .arg(border)
+ .arg(compact ? 9 : 11)
+ .arg(compact ? "2px" : "4px 6px"));
}
QString boolStatus(bool valid, bool value, const QString &yes, const QString &no)
@@ -148,6 +162,8 @@ QString boolStatus(bool valid, bool value, const QString &yes, const QString &no
DashboardPage::DashboardPage(QWidget *parent)
: QWidget(parent)
, ui(new Ui::DashboardPage)
+ , layoutCanvas(nullptr)
+ , layoutBackground(nullptr)
, rackBox(nullptr)
, deviceStatusLabel(new QLabel("PLC:未采集 | 机器人:未采集 | 安全回路:未采集", this))
, inspectionMachineCell(nullptr)
@@ -156,7 +172,6 @@ DashboardPage::DashboardPage(QWidget *parent)
, mainControlCabinetCell(nullptr)
, safetyDoor1Cell(nullptr)
, safetyDoor2Cell(nullptr)
- , safetyDoor3Cell(nullptr)
, alarmCell(nullptr)
, markNgButton(new QPushButton("标记 NG", this))
, stopButton(new QPushButton("终止", this))
@@ -212,6 +227,7 @@ DashboardPage::DashboardPage(QWidget *parent)
QVBoxLayout *processLayout = new QVBoxLayout(processBox);
processLayout->addLayout(processSummaryLayout);
+ processBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
processTable->setColumnCount(4);
processTable->setHorizontalHeaderLabels(
QStringList() << "工序" << "状态" << "次数" << "耗时");
@@ -221,8 +237,18 @@ DashboardPage::DashboardPage(QWidget *parent)
processTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
processTable->setAlternatingRowColors(true);
processTable->setMinimumHeight(150);
- processLayout->addWidget(processTable);
- ui->taskLayout->insertWidget(6, processBox);
+ processTable->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ processLayout->addWidget(processTable, 1);
+ ui->taskSpacer->changeSize(0, 0, QSizePolicy::Minimum, QSizePolicy::Fixed);
+ ui->taskLayout->insertWidget(6, processBox, 1);
+
+ ui->layoutGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ ui->taskGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ ui->middleLayout->setStretch(0, 1);
+ ui->middleLayout->setStretch(1, 1);
+ ui->mainLayout->setStretch(0, 0);
+ ui->mainLayout->setStretch(1, 4);
+ ui->mainLayout->setStretch(2, 1);
ui->recentLogTable->setColumnCount(5);
ui->recentLogTable->setHorizontalHeaderLabels(QStringList() << "时间" << "类型" << "模块" << "内容" << "状态");
@@ -233,51 +259,66 @@ DashboardPage::DashboardPage(QWidget *parent)
ui->recentLogTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->recentLogTable->setAlternatingRowColors(true);
- ui->deviceLayout->setSpacing(10);
- ui->deviceLayout->setColumnStretch(0, 1);
- ui->deviceLayout->setColumnStretch(1, 1);
- ui->deviceLayout->setColumnStretch(2, 2);
- ui->deviceLayout->setColumnStretch(3, 2);
- ui->deviceLayout->setColumnStretch(4, 2);
- ui->deviceLayout->setColumnStretch(5, 1);
- ui->deviceLayout->setRowStretch(0, 1);
- ui->deviceLayout->setRowStretch(1, 1);
- ui->deviceLayout->setRowStretch(2, 1);
- ui->deviceLayout->setRowStretch(3, 1);
- ui->deviceLayout->setRowStretch(4, 1);
- ui->deviceLayout->setRowStretch(5, 1);
- inspectionMachineCell = UiHelpers::makeStatusCell("检测机\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(inspectionMachineCell, 0, 0, 2, 2);
- ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("总控电脑", "#43a047"), 0, 3);
- safetyDoor1Cell = UiHelpers::makeStatusCell("安全门 1\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(safetyDoor1Cell, 0, 4);
- robotCell = UiHelpers::makeStatusCell("机器人\n未采集", "#607d8b");
- robotCell->setFixedSize(82, 58);
- ui->deviceLayout->addWidget(robotCell, 2, 3, 2, 2, Qt::AlignCenter);
- robotControlCabinetCell = UiHelpers::makeStatusCell("机器人控制柜\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(robotControlCabinetCell, 3, 0);
- mainControlCabinetCell = UiHelpers::makeStatusCell("总控柜\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(mainControlCabinetCell, 4, 0);
- safetyDoor2Cell = UiHelpers::makeStatusCell("安全门 2\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(safetyDoor2Cell, 2, 5);
- safetyDoor3Cell = UiHelpers::makeStatusCell("安全门 3\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(safetyDoor3Cell, 5, 0);
- alarmCell = UiHelpers::makeStatusCell("PLC 报警\n未采集", "#607d8b");
- ui->deviceLayout->addWidget(alarmCell, 5, 5);
+ ui->deviceLayout->setContentsMargins(8, 8, 8, 8);
+ ui->deviceLayout->setSpacing(0);
+ ui->layoutGroup->setMinimumSize(480, 500);
+ ui->layoutGroup->installEventFilter(this);
- rackBox = new QGroupBox("料架 2x3");
- rackBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- QGridLayout *rackLayout = new QGridLayout(rackBox);
- rackLayout->setContentsMargins(8, 18, 8, 8);
- rackLayout->setSpacing(4);
+ layoutCanvas = new QWidget(ui->layoutGroup);
+ layoutCanvas->setObjectName("deviceLayoutCanvas");
+ layoutCanvas->setMinimumSize(440, 441);
+ layoutCanvas->setStyleSheet(
+ "QWidget#deviceLayoutCanvas { background: #dfe4e8; }");
+ ui->deviceLayout->addWidget(layoutCanvas, 0, 0, Qt::AlignCenter);
+
+ layoutBackground = new QLabel(layoutCanvas);
+ layoutBackground->setAlignment(Qt::AlignCenter);
+ layoutBackground->setStyleSheet("background: #dfe4e8;");
+
+ inspectionMachineCell = UiHelpers::makeStatusCell("检测机\n未采集", "#607d8b");
+ inspectionMachineCell->setParent(layoutCanvas);
+ safetyDoor1Cell = UiHelpers::makeStatusCell("安全门 1\n未采集", "#607d8b");
+ safetyDoor1Cell->setParent(layoutCanvas);
+ robotCell = UiHelpers::makeStatusCell("机器人\n未采集", "#607d8b");
+ robotCell->setParent(layoutCanvas);
+ robotControlCabinetCell = UiHelpers::makeStatusCell("机器人控制柜\n未采集", "#607d8b");
+ robotControlCabinetCell->setParent(layoutCanvas);
+ mainControlCabinetCell = UiHelpers::makeStatusCell("总控柜\n未采集", "#607d8b");
+ mainControlCabinetCell->setParent(layoutCanvas);
+ safetyDoor2Cell = UiHelpers::makeStatusCell("安全门 2\n未采集", "#607d8b");
+ safetyDoor2Cell->setParent(layoutCanvas);
+ alarmCell = UiHelpers::makeStatusCell("PLC 报警\n未采集", "#607d8b");
+ alarmCell->setParent(layoutCanvas);
+
+ rackBox = new QGroupBox("料架 2x3", layoutCanvas);
+ rackBox->setObjectName("deviceRack");
+ rackBox->setStyleSheet(
+ "QGroupBox#deviceRack { border: 0; background: transparent; color: white; "
+ "font-size: 11px; font-weight: bold; }"
+ "QGroupBox#deviceRack::title { subcontrol-origin: margin; "
+ "background: rgba(18, 31, 38, 190); border: 1px solid #2e7d32; "
+ "border-radius: 3px; padding: 3px 8px; }");
for (int i = 0; i < 6; ++i) {
QLabel *trayCell = UiHelpers::makeSquareStatusCell(
QString("托盘 %1\n未采集").arg(i + 1), "#607d8b");
+ trayCell->setParent(rackBox);
+ trayCell->setMinimumSize(0, 0);
+ trayCell->setProperty("compactStatus", true);
rackTrayCells.append(trayCell);
- rackLayout->addWidget(trayCell, i / 3, i % 3, Qt::AlignCenter);
}
- ui->deviceLayout->addWidget(rackBox, 4, 2, 2, 3);
- updateRackSize();
+
+ updateStatusCell(inspectionMachineCell, "检测机\n未采集", "#607d8b");
+ updateStatusCell(robotCell, "机器人\n未采集", "#607d8b");
+ updateStatusCell(robotControlCabinetCell, "机器人控制柜\n未采集", "#607d8b");
+ updateStatusCell(mainControlCabinetCell, "总控柜\n未采集", "#607d8b");
+ updateStatusCell(safetyDoor1Cell, "安全门 1\n未采集", "#607d8b");
+ updateStatusCell(safetyDoor2Cell, "安全门 2\n未采集", "#607d8b");
+ updateStatusCell(alarmCell, "PLC 报警\n未采集", "#607d8b");
+ for (int i = 0; i < rackTrayCells.size(); ++i) {
+ updateStatusCell(rackTrayCells.at(i),
+ QString("托盘 %1\n未采集").arg(i + 1), "#607d8b");
+ }
+ QTimer::singleShot(0, this, [this]() { updateDeviceLayout(); });
connect(ui->startButton, &QPushButton::clicked,
this, &DashboardPage::startProduction);
@@ -404,34 +445,102 @@ void DashboardPage::addLog(const QString &type, const QString &module, const QSt
}
}
+bool DashboardPage::eventFilter(QObject *watched, QEvent *event)
+{
+ if (watched == ui->layoutGroup
+ && (event->type() == QEvent::Resize
+ || event->type() == QEvent::Show
+ || event->type() == QEvent::LayoutRequest)) {
+ QTimer::singleShot(0, this, [this]() { updateDeviceLayout(); });
+ }
+ return QWidget::eventFilter(watched, event);
+}
+
void DashboardPage::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
- updateRackSize();
+ QTimer::singleShot(0, this, [this]() { updateDeviceLayout(); });
}
-void DashboardPage::updateRackSize()
+void DashboardPage::updateDeviceLayout()
{
- if (!rackBox || rackTrayCells.isEmpty()) {
+ if (!layoutCanvas || !layoutBackground || !rackBox
+ || rackTrayCells.size() != 6) {
return;
}
- const int spacing = 4;
- const int leftMargin = 8;
- const int rightMargin = 8;
- const int topMargin = 18;
- const int bottomMargin = 8;
- const int maxRackHeight = qMax(150, ui->layoutGroup->height() / 3);
- const int maxCellByHeight = (maxRackHeight - topMargin - bottomMargin - spacing) / 2;
- const int maxCellByWidth = (ui->layoutGroup->width() - leftMargin - rightMargin - spacing * 2) / 3;
- const int cellSide = qMax(52, qMin(maxCellByHeight, maxCellByWidth));
- const int rackWidth = leftMargin + rightMargin + cellSide * 3 + spacing * 2;
- const int rackHeight = topMargin + bottomMargin + cellSide * 2 + spacing;
-
- for (QLabel *cell : rackTrayCells) {
- cell->setFixedSize(cellSide, cellSide);
+ static const QPixmap sourcePixmap(":/layout/Layout.png");
+ if (sourcePixmap.isNull()) {
+ return;
+ }
+
+ const QSize available = ui->deviceLayout->contentsRect().size();
+ if (available.width() <= 0 || available.height() <= 0) {
+ return;
+ }
+
+ const qreal imageRatio = qreal(sourcePixmap.width()) / sourcePixmap.height();
+ int canvasWidth = available.width();
+ int canvasHeight = qRound(canvasWidth / imageRatio);
+ if (canvasHeight > available.height()) {
+ canvasHeight = available.height();
+ canvasWidth = qRound(canvasHeight * imageRatio);
+ }
+ const QSize canvasSize(qMax(1, canvasWidth), qMax(1, canvasHeight));
+ if (layoutCanvas->size() != canvasSize) {
+ layoutCanvas->setFixedSize(canvasSize);
+ }
+
+ layoutBackground->setGeometry(layoutCanvas->rect());
+ layoutBackground->setPixmap(sourcePixmap.scaled(
+ canvasSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+ layoutBackground->lower();
+
+ const int width = canvasSize.width();
+ const int height = canvasSize.height();
+ const auto place = [width, height](QWidget *widget, qreal x, qreal y,
+ qreal relativeWidth, int minimumWidth) {
+ if (!widget) {
+ return;
+ }
+ const int widgetWidth = qMin(width,
+ qMax(minimumWidth, qRound(width * relativeWidth)));
+ const int widgetHeight = qMin(height,
+ qMax(30, widget->sizeHint().height()));
+ const int left = qBound(0, qRound(width * x), width - widgetWidth);
+ const int top = qBound(0, qRound(height * y), height - widgetHeight);
+ widget->setGeometry(left, top, widgetWidth, widgetHeight);
+ widget->raise();
+ };
+
+ place(inspectionMachineCell, 0.09, 0.09, 0.27, 100);
+ place(safetyDoor1Cell, 0.435, 0.025, 0.13, 72);
+ place(robotCell, 0.67, 0.29, 0.21, 86);
+ place(robotControlCabinetCell, 0.07, 0.57, 0.17, 84);
+ place(mainControlCabinetCell, 0.07, 0.77, 0.15, 76);
+ place(safetyDoor2Cell, 0.38, 0.93, 0.12, 72);
+ place(alarmCell, 0.86, 0.93, 0.125, 82);
+
+ const int rackX = qRound(width * 0.53);
+ const int rackY = qRound(height * 0.615);
+ const int rackWidth = qMin(width - rackX, qRound(width * 0.36));
+ const int rackHeight = qMin(height - rackY, qRound(height * 0.30));
+ rackBox->setGeometry(rackX, rackY, rackWidth, rackHeight);
+ rackBox->raise();
+
+ const int trayWidth = qMin(rackWidth, qMax(1, qRound(rackWidth * 0.30)));
+ const int trayHeight = qMin(rackHeight,
+ qMax(30, qRound(rackHeight * 0.22)));
+ const qreal trayX[] = {0.03, 0.35, 0.67};
+ const qreal trayY[] = {0.28, 0.70};
+ for (int i = 0; i < rackTrayCells.size(); ++i) {
+ const int left = qBound(0, qRound(rackWidth * trayX[i % 3]),
+ rackWidth - trayWidth);
+ const int top = qBound(0, qRound(rackHeight * trayY[i / 3]),
+ rackHeight - trayHeight);
+ rackTrayCells.at(i)->setGeometry(left, top, trayWidth, trayHeight);
+ rackTrayCells.at(i)->raise();
}
- rackBox->setFixedSize(rackWidth, rackHeight);
}
void DashboardPage::startProduction()
@@ -1186,17 +1295,13 @@ void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
: status.robotRunning || status.robotIdle
? "#2e7d32" : "#d32f2f");
updateStatusCell(robotControlCabinetCell,
- QString("机器人控制柜\n%1").arg(boolStatus(
- status.statusValid, status.robotControlCabinetReady,
- "正常", "未就绪")),
- !status.statusValid ? "#607d8b"
- : status.robotControlCabinetReady ? "#2e7d32" : "#d32f2f");
+ QString("机器人控制柜\n%1").arg(
+ offline ? "离线" : "就绪"),
+ offline ? "#607d8b" : "#2e7d32");
updateStatusCell(mainControlCabinetCell,
- QString("总控柜\n%1").arg(boolStatus(
- status.statusValid, status.mainControlCabinetReady,
- "正常", "未就绪")),
- !status.statusValid ? "#607d8b"
- : status.mainControlCabinetReady ? "#2e7d32" : "#d32f2f");
+ QString("总控柜\n%1").arg(
+ offline ? "离线" : "就绪"),
+ offline ? "#607d8b" : "#2e7d32");
updateStatusCell(safetyDoor1Cell,
QString("安全门 1\n%1").arg(boolStatus(
status.statusValid, status.safetyDoor1Closed,
@@ -1209,12 +1314,6 @@ void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
"关闭", "打开")),
!status.statusValid ? "#607d8b"
: status.safetyDoor2Closed ? "#2e7d32" : "#d32f2f");
- updateStatusCell(safetyDoor3Cell,
- QString("安全门 3\n%1").arg(boolStatus(
- status.statusValid, status.safetyDoor3Closed,
- "关闭", "打开")),
- !status.statusValid ? "#607d8b"
- : status.safetyDoor3Closed ? "#2e7d32" : "#d32f2f");
updateStatusCell(alarmCell,
QString("PLC 报警\n%1").arg(boolStatus(
status.statusValid, status.activeAlarm,
@@ -1331,9 +1430,10 @@ void DashboardPage::loadCurrentOrder()
&& !workpieces.isEmpty();
}
- ui->orderLabel->setText(QString("当前订单:%1(%2)")
+ ui->orderLabel->setText(QString("当前订单:%1(%2,%3)")
.arg(order.no)
- .arg(displayOrderStatus(order.status)));
+ .arg(displayOrderStatus(order.status))
+ .arg(displayInspectionMode(order.inspectionMode)));
emit currentOrderChanged(order.no);
updateProductionStats();
updateRackSummary();
diff --git a/pages/dashboardpage.h b/pages/dashboardpage.h
index e6ec20a..7539bd1 100644
--- a/pages/dashboardpage.h
+++ b/pages/dashboardpage.h
@@ -10,6 +10,7 @@
class QTableWidget;
class QGroupBox;
class QResizeEvent;
+class QEvent;
class QLabel;
class QPushButton;
class QTimer;
@@ -70,13 +71,14 @@ private slots:
void markWorkpieceNg();
protected:
+ bool eventFilter(QObject *watched, QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
void loadCurrentOrder();
void updateProductionStats();
void updateRackSummary();
- void updateRackSize();
+ void updateDeviceLayout();
void updateRecoveryButtons();
QString controlOperationContext(QString *identity) const;
bool confirmControlOperation(const QString &title, const QString &effect);
@@ -85,6 +87,8 @@ private:
static QString formatDuration(int elapsedMs);
Ui::DashboardPage *ui;
+ QWidget *layoutCanvas;
+ QLabel *layoutBackground;
QGroupBox *rackBox;
QVector rackTrayCells;
QLabel *deviceStatusLabel;
@@ -94,7 +98,6 @@ private:
QLabel *mainControlCabinetCell;
QLabel *safetyDoor1Cell;
QLabel *safetyDoor2Cell;
- QLabel *safetyDoor3Cell;
QLabel *alarmCell;
QPushButton *markNgButton;
QPushButton *stopButton;
diff --git a/pages/logpage.cpp b/pages/logpage.cpp
index 9d5880a..451d619 100644
--- a/pages/logpage.cpp
+++ b/pages/logpage.cpp
@@ -37,6 +37,11 @@ LogPage::~LogPage()
delete ui;
}
+void LogPage::refresh()
+{
+ loadLogs();
+}
+
void LogPage::addLog(const QString &type, const QString &module, const QString &action,
const QString &content, const QString &status)
{
diff --git a/pages/logpage.h b/pages/logpage.h
index ae08c97..132c02b 100644
--- a/pages/logpage.h
+++ b/pages/logpage.h
@@ -17,6 +17,9 @@ public:
void addLog(const QString &type, const QString &module, const QString &action,
const QString &content, const QString &status);
+public slots:
+ void refresh();
+
private:
void loadLogs();
void addLogRow(const QString &time, const QString &type, const QString &module,
diff --git a/pages/qualitypage.cpp b/pages/qualitypage.cpp
index 2cade89..92d4d2f 100644
--- a/pages/qualitypage.cpp
+++ b/pages/qualitypage.cpp
@@ -266,6 +266,15 @@ QualityPage::~QualityPage()
{
}
+void QualityPage::refresh()
+{
+ loadInspectionRecords();
+ loadStatistics();
+ if (!traceBarcodeEdit->text().trimmed().isEmpty()) {
+ loadTrace();
+ }
+}
+
void QualityPage::setupInspectionTab()
{
inspectionOrderEdit = new QLineEdit;
@@ -357,10 +366,10 @@ void QualityPage::setupTraceTab()
void QualityPage::loadInspectionRecords()
{
+ const QString slotText = inspectionSlotEdit->text().trimmed();
bool slotOk = true;
- const int trayPos = inspectionSlotEdit->text().trimmed().isEmpty()
- ? 0 : inspectionSlotEdit->text().trimmed().toInt(&slotOk);
- if (!slotOk || trayPos < 1 || trayPos > 49) {
+ const int trayPos = slotText.isEmpty() ? 0 : slotText.toInt(&slotOk);
+ if (!slotText.isEmpty() && (!slotOk || trayPos < 1 || trayPos > 49)) {
setMessage(inspectionMessageLabel, "位置号必须是 1 到 49", true);
return;
}
diff --git a/pages/qualitypage.h b/pages/qualitypage.h
index 856bc44..0b40126 100644
--- a/pages/qualitypage.h
+++ b/pages/qualitypage.h
@@ -13,6 +13,7 @@ class QualityPage : public QWidget
public:
explicit QualityPage(QWidget *parent = nullptr);
~QualityPage();
+ void refresh();
private:
void setupInspectionTab();
diff --git a/repositories/productionrepository.cpp b/repositories/productionrepository.cpp
index ad6ab99..d1e62fc 100644
--- a/repositories/productionrepository.cpp
+++ b/repositories/productionrepository.cpp
@@ -543,7 +543,7 @@ QList ProductionRepository::listProcessRecords(
"result_state, duration_ms, started_at, completed_at "
"from workpiece_process_records "
"where workpiece_id = :workpiece_id "
- "order by started_at, id");
+ "order by started_at desc, id desc");
query.bindValue(":workpiece_id", workpieceId);
if (!query.exec()) {
setError(query, error);
diff --git a/ssp.pro b/ssp.pro
index 846d4e5..7945e91 100644
--- a/ssp.pro
+++ b/ssp.pro
@@ -97,6 +97,9 @@ FORMS += \
pages/rackpage.ui \
widget.ui
+RESOURCES += \
+ layout/layout.qrc
+
DISTFILES += \
config.ini
diff --git a/ssp.pro.user b/ssp.pro.user
index aa0ec29..67adf68 100644
--- a/ssp.pro.user
+++ b/ssp.pro.user
@@ -1,6 +1,6 @@
-
+
EnvironmentId
diff --git a/widget.cpp b/widget.cpp
index 4982d02..6c7cf9e 100644
--- a/widget.cpp
+++ b/widget.cpp
@@ -161,6 +161,25 @@ void Widget::setupMainArea(QVBoxLayout *rootLayout)
rootLayout->addLayout(bodyLayout, 1);
connect(navList, &QListWidget::currentRowChanged, pageStack, &QStackedWidget::setCurrentIndex);
+ connect(pageStack, &QStackedWidget::currentChanged,
+ this, [this, orderPage, rackPage](int index) {
+ switch (index) {
+ case 1:
+ orderPage->refresh();
+ break;
+ case 2:
+ rackPage->refresh();
+ break;
+ case 4:
+ logPage->refresh();
+ break;
+ case 5:
+ qualityPage->refresh();
+ break;
+ default:
+ break;
+ }
+ });
connect(dashboardPage, &DashboardPage::systemStateChanged, this, [this](const QString &state) {
systemStateLabel->setText("系统:" + state);
});