diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/res/image/main/icon_setting.png b/res/image/main/icon_setting.png index 8686833..509d47f 100644 --- a/res/image/main/icon_setting.png +++ b/res/image/main/icon_setting.png Binary files differ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/res/image/main/icon_setting.png b/res/image/main/icon_setting.png index 8686833..509d47f 100644 --- a/res/image/main/icon_setting.png +++ b/res/image/main/icon_setting.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index a6ba788..dcb8ac5 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -32,10 +32,6 @@ image/Index/u7313.svg image/Index/u5089.png image/Index/u138.png - image/Index/btnPageFirst.png - image/Index/btnPageLast.png - image/Index/btnPageNext.png - image/Index/btnPagePre.png image/Index/u2326.svg image/Index/arrowDown.png image/Index/arrowUp.png @@ -104,5 +100,9 @@ image/main/icon_menu_infomation.png image/main/icon_menu_infomation_checked.png image/msgbox/icon_box_close.png + image/infomation/btnPageFirst.png + image/infomation/btnPageLast.png + image/infomation/btnPageNext.png + image/infomation/btnPagePre.png diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/res/image/main/icon_setting.png b/res/image/main/icon_setting.png index 8686833..509d47f 100644 --- a/res/image/main/icon_setting.png +++ b/res/image/main/icon_setting.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index a6ba788..dcb8ac5 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -32,10 +32,6 @@ image/Index/u7313.svg image/Index/u5089.png image/Index/u138.png - image/Index/btnPageFirst.png - image/Index/btnPageLast.png - image/Index/btnPageNext.png - image/Index/btnPagePre.png image/Index/u2326.svg image/Index/arrowDown.png image/Index/arrowUp.png @@ -104,5 +100,9 @@ image/main/icon_menu_infomation.png image/main/icon_menu_infomation_checked.png image/msgbox/icon_box_close.png + image/infomation/btnPageFirst.png + image/infomation/btnPageLast.png + image/infomation/btnPageNext.png + image/infomation/btnPagePre.png diff --git a/res/qss.qrc b/res/qss.qrc index fbb36c0..82ef5e5 100644 --- a/res/qss.qrc +++ b/res/qss.qrc @@ -1,10 +1,9 @@ - qss/preCheck.css qss/loginForm.css qss/mainForm.css - qss/baseInfomation.css qss/messageBox.css qss/infoMain.css + qss/infoTable.css diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/res/image/main/icon_setting.png b/res/image/main/icon_setting.png index 8686833..509d47f 100644 --- a/res/image/main/icon_setting.png +++ b/res/image/main/icon_setting.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index a6ba788..dcb8ac5 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -32,10 +32,6 @@ image/Index/u7313.svg image/Index/u5089.png image/Index/u138.png - image/Index/btnPageFirst.png - image/Index/btnPageLast.png - image/Index/btnPageNext.png - image/Index/btnPagePre.png image/Index/u2326.svg image/Index/arrowDown.png image/Index/arrowUp.png @@ -104,5 +100,9 @@ image/main/icon_menu_infomation.png image/main/icon_menu_infomation_checked.png image/msgbox/icon_box_close.png + image/infomation/btnPageFirst.png + image/infomation/btnPageLast.png + image/infomation/btnPageNext.png + image/infomation/btnPagePre.png diff --git a/res/qss.qrc b/res/qss.qrc index fbb36c0..82ef5e5 100644 --- a/res/qss.qrc +++ b/res/qss.qrc @@ -1,10 +1,9 @@ - qss/preCheck.css qss/loginForm.css qss/mainForm.css - qss/baseInfomation.css qss/messageBox.css qss/infoMain.css + qss/infoTable.css diff --git a/res/qss/infoMain.css b/res/qss/infoMain.css index 2f178c7..039979c 100644 --- a/res/qss/infoMain.css +++ b/res/qss/infoMain.css @@ -1,26 +1,43 @@ QWidget { background-color: #FFFFFF; } -QLabel { + +QListView#listMenu { + border: 0px; + background-image: url(:/image/login/bg_login.png); + background-position: center; font-family: Microsoft YaHei; font-size: 18px; + font-weight: bold; + padding-top: 20px; } -QScrollArea { - border: none; +QListView#listMenu:focus { + outline: 0px; } -QScrollBar::vertical { - width: 5px; - background: #FFFFFF; - border: none; +QListView#listMenu:item { + color: #FFFFFF; + height: 48px; + border: 0px; + padding-left: 20px; + margin-right: 20px; + border-top-right-radius: 10px; + border-bottom-right-radius: 10px; } -QScrollBar::handle::vertical { - width: 5px; +QListView#listMenu:item:selected { + background-color: #69c2f7; + color: #2F6FC6; +} +QListView#listMenu:item:hover { + background: rgba(80, 72, 151, 0.3); + color: #FFFFFF; +} + +QListView#listMenu QScrollBar::vertical { + width: 4px; + background: #69c2f7; + border: 0px; +} +QListView#listMenu QScrollBar::handle::vertical { background: #2F6FC6; - border: none; + border: 0px; } -QScrollBar::add-line::vertical { - border: none; -} -QScrollBar::sub-line::vertical { - border: none; -} \ No newline at end of file diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/res/image/main/icon_setting.png b/res/image/main/icon_setting.png index 8686833..509d47f 100644 --- a/res/image/main/icon_setting.png +++ b/res/image/main/icon_setting.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index a6ba788..dcb8ac5 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -32,10 +32,6 @@ image/Index/u7313.svg image/Index/u5089.png image/Index/u138.png - image/Index/btnPageFirst.png - image/Index/btnPageLast.png - image/Index/btnPageNext.png - image/Index/btnPagePre.png image/Index/u2326.svg image/Index/arrowDown.png image/Index/arrowUp.png @@ -104,5 +100,9 @@ image/main/icon_menu_infomation.png image/main/icon_menu_infomation_checked.png image/msgbox/icon_box_close.png + image/infomation/btnPageFirst.png + image/infomation/btnPageLast.png + image/infomation/btnPageNext.png + image/infomation/btnPagePre.png diff --git a/res/qss.qrc b/res/qss.qrc index fbb36c0..82ef5e5 100644 --- a/res/qss.qrc +++ b/res/qss.qrc @@ -1,10 +1,9 @@ - qss/preCheck.css qss/loginForm.css qss/mainForm.css - qss/baseInfomation.css qss/messageBox.css qss/infoMain.css + qss/infoTable.css diff --git a/res/qss/infoMain.css b/res/qss/infoMain.css index 2f178c7..039979c 100644 --- a/res/qss/infoMain.css +++ b/res/qss/infoMain.css @@ -1,26 +1,43 @@ QWidget { background-color: #FFFFFF; } -QLabel { + +QListView#listMenu { + border: 0px; + background-image: url(:/image/login/bg_login.png); + background-position: center; font-family: Microsoft YaHei; font-size: 18px; + font-weight: bold; + padding-top: 20px; } -QScrollArea { - border: none; +QListView#listMenu:focus { + outline: 0px; } -QScrollBar::vertical { - width: 5px; - background: #FFFFFF; - border: none; +QListView#listMenu:item { + color: #FFFFFF; + height: 48px; + border: 0px; + padding-left: 20px; + margin-right: 20px; + border-top-right-radius: 10px; + border-bottom-right-radius: 10px; } -QScrollBar::handle::vertical { - width: 5px; +QListView#listMenu:item:selected { + background-color: #69c2f7; + color: #2F6FC6; +} +QListView#listMenu:item:hover { + background: rgba(80, 72, 151, 0.3); + color: #FFFFFF; +} + +QListView#listMenu QScrollBar::vertical { + width: 4px; + background: #69c2f7; + border: 0px; +} +QListView#listMenu QScrollBar::handle::vertical { background: #2F6FC6; - border: none; + border: 0px; } -QScrollBar::add-line::vertical { - border: none; -} -QScrollBar::sub-line::vertical { - border: none; -} \ No newline at end of file diff --git a/res/qss/infoTable.css b/res/qss/infoTable.css new file mode 100644 index 0000000..137dd01 --- /dev/null +++ b/res/qss/infoTable.css @@ -0,0 +1,525 @@ +QWidget { + background-color: #FFFFFF; +} +QLabel { + font-family: Microsoft YaHei; + font-size: 16px; +} + +/** 查询条件 **/ +QWidget#wdgtQueryBox QLineEdit[class=queryBox] { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} +QWidget#wdgtQueryBox QDateEdit[class=queryBox] { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} +QWidget#wdgtQueryBox QComboBox[class=queryBox] { + border-radius: 6px; + font-family: Microsoft YaHei; + padding-left: 10px; + color: #333333; + border: 1px solid #E3E3E3; + font-size: 16px; +} + +/** 普通按钮 **/ +QToolButton[class="btnDefault"] { + border-radius: 12px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; +} +/** 查询重置按钮 **/ +QToolButton[class="btnOpposite"] { + border-radius: 12px; + border: 1px solid #2F6FC6; + background-color: #FFFFFF; + color: #2F6FC6; + font-family: "Microsoft YaHei"; + font-size: 18px; +} + +/** 表格顶端的标题栏 **/ +QLabel[class="frameLabel"]{ + background-color: #2F6FC6; + border: 0px; + border-radius: 0px; + border-top-left-radius: 10px; + border-top-right-radius: 10px; + padding: 10px; + font-size: 16px; + color: #FFFFFF; + font-family: "Microsoft YaHei"; +} + +/** 查询条件输入框 **/ +QLineEdit[class="gridInput"] { + border-radius: 10px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; + background-color: #DFEBF2; + padding-left: 10px; +} + +QComboBox[class="defaultSelect"] { + border-radius: 6px; + font-family: "Microsoft YaHei"; + padding-left: 16px; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; +} +QComboBox[class="defaultSelect"]::down-arrow { + image: url(":/image/main/arrow_down.png"); +} +QComboBox[class="defaultSelect"]::down-arrow::on { + image: url(":/image/main/arrow_up.png"); +} +QComboBox[class="defaultSelect"]::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} +QComboBox[class="defaultSelect"] QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + font-family: "Microsoft YaHei"; + font-size: 16px; + outline: 0px; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item{ + height: 40px; + font-family: "Microsoft YaHei"; + color: #333333; + padding-left: 9px; + background-color: #FFFFFF; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:hover{ + color: #FFFFFF; + background-color: #2F6FC6; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:selected{ + color: #FFFFFF; + background-color: #2F6FC6; +} +QComboBox[class="defaultSelect"] QScrollBar::vertical { + width: 5px; + background: #FFFFFF; + border: none; +} +QComboBox[class="defaultSelect"] QScrollBar::handle::vertical { + width: 5px; + background: #2F6FC6; + border: none; +} +QComboBox[class="defaultSelect"] QScrollBar::add-line::vertical { + border: none; +} +QComboBox[class="defaultSelect"] QScrollBar::sub-line::vertical { + border: none; +} + +/** 查询普通按钮 **/ +QWidget#wdgtQueryBox QToolButton { + border-radius: 12px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; +} +/** 查询重置按钮 **/ +QWidget#wdgtQueryBox QToolButton[class="btnResetQuery"] { + border-radius: 12px; + border: 1px solid #2F6FC6; + background-color: #FFFFFF; + color: #2F6FC6; + font-family: "Microsoft YaHei"; + font-size: 18px; +} + +/** 表格部分通用样式 **/ +QTableWidget { + border: 0px; + font-size: 18px; + color: #333333; +} + +QTableWidget QHeaderView::section { + background-color: #2F6FC6; + border: 1px solid #FFFFFF; + color: #FFFFFF; + font-size: 18px; + min-height: 50px; +} + +QTableWidget::item { + padding-left: 10px; + padding-right: 10px; + border: 0px; +} + +QTableWidget::item::selected { + /*background: #FFFFFF; */ + color: #2F6FC6; +} + +QTableWidget QWidget[class="wdgtOper"] { + background: transparent; +} + +QLabel[class="urlText"] { + color: #0000FF; + text-decoration: underline; +} + +QToolTip { + font-family: "Microsoft Yahei"; + font-size: 18px; + padding: 10px; +} + +QPushButton[class="tableBtnDetail"] { + background: transparent; + color: #2F6FC6; + border: 0px; + font-size: 16px; + font-family: "Microsoft YaHei"; + text-decoration: underline; +} +QPushButton[class="tableBtnDelete"] { + background: transparent; + color: #F56C6C; + border: 0px; + font-size: 16px; + font-family: "Microsoft YaHei"; + text-decoration: underline; +} + + +/** 分页组件 **/ +QWidget[class="wdgtPageBtn"] { + background: #2F6FC6; + border-radius: 6px; +} +QWidget[class="wdgtPageBtn"] QToolButton { + background: transparent; +} +QWidget[class="wdgtPage"] QLabel { + color: #333333; + font-size: 16px; + font-family: "Microsoft YaHei"; +} + +/** 对话框弹窗顶端的标题栏 **/ +QWidget[class="dlgTitle"]{ + background-color: #2F6FC6; + border: 0px; + padding: 10px; +} +QWidget[class="dlgTitle"] QLabel{ + background: transparent; + border: 0px; + padding: 10px; + font-size: 20px; + color: #FFFFFF; + font-family: "Microsoft YaHei"; +} + +/** 详情表格 **/ +QWidget[class="detailTable"] QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} +QWidget[class="detailTable"] QLabel[class="urlText"] { + color: #0000FF; + text-decoration: underline; +} +/** 文本输入框 **/ +QWidget[class="detailTable"] QLineEdit{ + border-radius: 10px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; + background-color: #DFEBF2; + padding-left: 10px; +} +/** 日期选择器 **/ +QWidget[class="detailTable"] QDateEdit { + border-radius: 10px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; + padding-left: 10px; +} + +/** 下拉列表框的样式 **/ +QWidget[class="detailTable"] QComboBox { + border-radius: 6px; + font-family: "Microsoft YaHei"; + padding-left: 16px; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; +} +QWidget[class="detailTable"] QComboBox::down-arrow { + image: url(":/image/main/arrow_down.png"); +} +QWidget[class="detailTable"] QComboBox::down-arrow::on { + image: url(":/image/main/arrow_up.png"); +} +QWidget[class="detailTable"] QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + font-family: "Microsoft YaHei"; + font-size: 16px; + outline: 0px; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView::item{ + height: 40px; + font-family: "Microsoft YaHei"; + color: #333333; + padding-left: 9px; + background-color: #FFFFFF; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView::item:hover{ + color: #FFFFFF; + background-color: #2F6FC6; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView::item:selected{ + color: #FFFFFF; + background-color: #2F6FC6; +} + +QCheckBox[class="defaultSolid"] { + color: #333333; + font-family: "Microsoft YaHei"; + font-size: 18px; + /*padding-left: 5px;*/ +} +QCheckBox[class="defaultSolid"]::indicator { + width: 20px; + height: 20px; + border-radius: 5px; + border: 2px solid #2F6FC6; +} +QCheckBox[class="defaultSolid"]::indicator::unchecked { + background: #FFFFFF; + /*border: 2px solid #CCCCC;*/ +} +QCheckBox[class="defaultSolid"]::indicator::checked { + background: #2F6FC6; +} + +/* +QWidget#wdgtQueryBox QLineEdit { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} +QWidget#wdgtQueryBox QLineEdit::read-only { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; + background-color: #F3F3F3; +} + +QWidget#wdgtQueryBox QDateEdit { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} + +QWidget#wdgtQueryBox QComboBox { + border-radius: 6px; + font-family: Microsoft YaHei; + padding-left: 10px; + color: #333333; + border: 1px solid #E3E3E3; + font-size: 16px; +} + +QWidget#wdgtQueryBox QComboBox::down-arrow { + image: url(":/image/Index/arrowDown.png"); +} +QWidget#wdgtQueryBox QComboBox::down-arrow::on { + image: url(":/image/Index/arrowUp.png"); +} + +QWidget#wdgtQueryBox QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} + +QWidget#wdgtQueryBox QComboBox QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + selection-background-color: #2F6FC6; + selection-color: #FFFFFF; + font-family: "Microsoft YaHei"; + outline: 0px; + font-size: 16px; +} + +QWidget#wdgtQueryBox QComboBox QAbstractItemView::item { + height: 30px; + color: #333333; + background-color: #FFFFFF; + font-size: 16px; +} +QWidget#wdgtQueryBox QComboBox QAbstractItemView::item:hover { + color: #FFFFFF; + background-color: #2F6FC6; +} + +QWidget#wdgtQueryBox QComboBox QAbstractItemView::item:selected { + color: #FFFFFF; + background-color: #2F6FC6; +} + + +QWidget#wdgtQueryBox QComboBox QScrollBar::vertical { + width: 10px; + background: #FFFFFF; + border: none; +} + +QWidget#wdgtQueryBox QComboBox QScrollBar::handle::vertical { + width: 10px; + background: #2F6FC6; + border: none; +} + +QWidget#wdgtQueryBox QComboBox QScrollBar::add-line::vertical { + border: none; +} +QWidget#wdgtQueryBox QComboBox QScrollBar::sub-line::vertical { + border: none; +} + + + +QWidget#wdgtFooter QToolButton { + border-radius: 6px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; + font-weight: bold; +} + +QComboBox[class="defaultSelect"] { + border-radius: 6px; + font-family: Microsoft YaHei; + padding-left: 10px; + color: #333333; + border: 1px solid #E3E3E3; + font-size: 16px; +} +QComboBox[class="defaultSelect"]::down-arrow { + image: url(":/image/Index/arrowDown.png"); +} +QComboBox[class="defaultSelect"]::down-arrow::on { + image: url(":/image/Index/arrowUp.png"); +} +QComboBox[class="defaultSelect"]::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} +QComboBox[class="defaultSelect"] QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + selection-background-color: #2F6FC6; + selection-color: #FFFFFF; + font-family: "Microsoft YaHei"; + outline: 0px; + font-size: 16px; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item { + height: 30px; + color: #333333; + background-color: #FFFFFF; + font-size: 16px; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:hover { + color: #FFFFFF; + background-color: #2F6FC6; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:selected { + color: #FFFFFF; + background-color: #2F6FC6; +} + +QPushButton#btnDetailCategory, QPushButton#btnSaveAddr { + border-radius: 6px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; + font-weight: bold; +} +*/ + +/* 页面整体背景设置为灰色 */ +QFrame#wdgtStateMain { + background-color: #E3E3E3; +} +/* 信息块使用白色背景 用于区域分割 */ +QFrame[class="infoBlock"] { + background-color: #FFFFFF; +} +/* 子标题样式 */ +QWidget[class="subTitle"] QLabel { + color: #2F6FC6; + font-weight: bold; + font-size: 20px; + min-height: 40px; +} + +QLabel[class="gridLabel"] { + font-size: 18px; + padding: 10px 20px; +} +/* +QLineEdit[class="gridInput"] { + border-radius: 6px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 18px; +} +*/ diff --git a/QPagedTable/QPagedTable.cpp b/QPagedTable/QPagedTable.cpp index 427416b..b9ee239 100644 --- a/QPagedTable/QPagedTable.cpp +++ b/QPagedTable/QPagedTable.cpp @@ -117,6 +117,11 @@ updateTableList(); } +void QPagedTable::setTableProperty(const char *name, QString value) +{ + ui->table->setProperty(name, value); +} + void QPagedTable::setContextMenuLabels(QStringList menuLabels) { contextMenuLabels = menuLabels; @@ -161,6 +166,30 @@ { page.calcTotalPage(totalCount); } +void QPagedTable::setPageButtonIcons(QStringList iconUrls) +{ + if (iconUrls.size() < 4) { + return ; + } + + ui->btnFirst->setIcon(QIcon(iconUrls.at(0))); + ui->btnPre->setIcon(QIcon(iconUrls.at(1))); + ui->btnNext->setIcon(QIcon(iconUrls.at(2))); + ui->btnLast->setIcon(QIcon(iconUrls.at(3))); +} +void QPagedTable::setPageButtonProperty(const char* name, QString value) +{ + ui->wdgtPageBtn->setProperty(name, value); +} + +void QPagedTable::setHeaderHeight(int height) +{ + headerHeight = height; +} +void QPagedTable::setDataRowHeight(int height) +{ + dataRowHeight = height; +} void QPagedTable::setMultiCheckType(MultiCheckType type) @@ -175,10 +204,10 @@ QWidget * QPagedTable::buildNewCheckWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QCheckBox* check = new QCheckBox(); + QCheckBox* check = new QCheckBox(activeWidget); check->setMinimumSize(25, 25); check->setMaximumSize(25, 25); activelayout->addWidget(check, 0, 0); @@ -191,10 +220,10 @@ } QWidget * QPagedTable::buildNewRadioWidget() { - QWidget* activeWidget = new QWidget(); + QWidget* activeWidget = new QWidget(ui->table); activeWidget->setStyleSheet("QWidget{background: transparent;}"); QHBoxLayout* activelayout = new QHBoxLayout(activeWidget); - QRadioButton* radio = new QRadioButton(); + QRadioButton* radio = new QRadioButton(activeWidget); radio->setMinimumSize(25, 25); radio->setMaximumSize(25, 25); activelayout->addWidget(radio, 0, 0); @@ -203,6 +232,17 @@ return activeWidget; } +QWidget * QPagedTable::buildNewLabelWidget(QString text) +{ + QWidget* wdgt = new QWidget(ui->table); + wdgt->setStyleSheet("QWidget{background: transparent;}"); + QHBoxLayout* lyt = new QHBoxLayout(wdgt); + QLabel* label = new QLabel(wdgt); + label->setText(text); + lyt->addWidget(label, 0, 0); + + return wdgt; +} void QPagedTable::updateTableList() { diff --git a/QPagedTable/QPagedTable.h b/QPagedTable/QPagedTable.h index f1afca6..a4cc823 100644 --- a/QPagedTable/QPagedTable.h +++ b/QPagedTable/QPagedTable.h @@ -43,10 +43,13 @@ void setColumns(QList columnList); void setColumns(QList> colMapList); void setDatas(QList> pagedDataList); + void setTableProperty(const char* name, QString value); void setContextMenuLabels(QStringList menuLabels); void setPage(int pageSize, int currentPage, int totalCount, int totalPage); void setPageSize(int pageSize); void setTotalCount(int totalCount); + void setPageButtonIcons(QStringList iconUrls); + void setPageButtonProperty(const char* name, QString value); void setHeaderHeight(int height); void setDataRowHeight(int height); @@ -94,6 +97,7 @@ void updateTableList(); QWidget * buildNewCheckWidget(); QWidget * buildNewRadioWidget(); + QWidget * buildNewLabelWidget(QString text); private slots: void on_btnFirst_clicked(); diff --git a/QPagedTable/QPagedTable.pri b/QPagedTable/QPagedTable.pri index 9e45387..7efc3d5 100644 --- a/QPagedTable/QPagedTable.pri +++ b/QPagedTable/QPagedTable.pri @@ -3,3 +3,5 @@ HEADERS += $$PWD/QPagedTableColumn.h HEADERS += $$PWD/QPagedTablePage.h + +FORMS += $$PWD/QPagedTable.ui diff --git a/QPagedTable/QPagedTable.ui b/QPagedTable/QPagedTable.ui new file mode 100644 index 0000000..e920d0d --- /dev/null +++ b/QPagedTable/QPagedTable.ui @@ -0,0 +1,198 @@ + + + QPagedTable + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + 10 + + + 20 + + + 10 + + + 20 + + + 20 + + + + + Qt::Horizontal + + + + 1135 + 20 + + + + + + + + 1 + + + + + + + 条记录 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 10 + + + 10 + + + 5 + + + 10 + + + 5 + + + + + + + + + :/images/btnPageFirst.png:/images/btnPageFirst.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPagePre.png:/images/btnPagePre.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageNext.png:/images/btnPageNext.png + + + + 24 + 24 + + + + + + + + + + + + :/images/btnPageLast.png:/images/btnPageLast.png + + + + 24 + 24 + + + + + + + + + + + + + + + diff --git a/dao/TaskDao.cpp b/dao/TaskDao.cpp index f980394..2c1c86e 100644 --- a/dao/TaskDao.cpp +++ b/dao/TaskDao.cpp @@ -37,7 +37,7 @@ query.bindValue(":offset", page.currentPage * page.pageSize); query.bindValue(":limit", page.pageSize); - qDebug() << sql; +// qDebug() << sql; // 分页查询 bool isSuccess = query.exec(); diff --git a/dao/service/SysLocalService.cpp b/dao/service/SysLocalService.cpp index 1a46765..cf5cdec 100644 --- a/dao/service/SysLocalService.cpp +++ b/dao/service/SysLocalService.cpp @@ -10,3 +10,12 @@ SystemLocalDao dao; return dao.getInfomationTableColumns(tableName); } + +QMap SysLocalService::getTaskMeasureStatusDict() +{ + if (ProMemory::getInstance().getMeasureStatusDict().isEmpty()) { + SystemDao systemDao; + systemDao.getTaskMeasureStatusDict(); + } + return ProMemory::getInstance().getMeasureStatusDict(); +} diff --git a/dao/service/SysLocalService.h b/dao/service/SysLocalService.h index 91ef5f0..63a91e0 100644 --- a/dao/service/SysLocalService.h +++ b/dao/service/SysLocalService.h @@ -1,7 +1,9 @@ #ifndef SYSLOCALSERVICE_H #define SYSLOCALSERVICE_H +#include "dao/SystemDao.h" #include "dao/SystemLocalDao.h" +#include "utils/ProMemory.h" class SysLocalService { @@ -9,6 +11,8 @@ SysLocalService(); QList> getInfomationTableColumns(QString tableName); + + QMap getTaskMeasureStatusDict(); }; #endif // SYSLOCALSERVICE_H diff --git a/frame/MainWindowForm.cpp b/frame/MainWindowForm.cpp index ec82cd7..cb98f69 100644 --- a/frame/MainWindowForm.cpp +++ b/frame/MainWindowForm.cpp @@ -1,7 +1,7 @@ #include "MainWindowForm.h" #include "ui_MainWindowForm.h" -#include +#include MainWindowForm::MainWindowForm(QWidget *parent) : FramelessWindow(parent), @@ -49,7 +49,7 @@ // 加载样式表 QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/mainForm.css"); if (qssStyle.isEmpty() == false) { - this->setStyleSheet(qssStyle); // 仅本窗口生效 + ui->wdgtTop->setStyleSheet(qssStyle); // 仅本窗口生效 } // 设置标题 diff --git a/frame/MainWindowForm.ui b/frame/MainWindowForm.ui index f37d171..e503a61 100644 --- a/frame/MainWindowForm.ui +++ b/frame/MainWindowForm.ui @@ -455,8 +455,8 @@ - 40 - 40 + 24 + 24 @@ -468,8 +468,8 @@ - 32 - 32 + 18 + 18 @@ -478,8 +478,8 @@ - 40 - 40 + 24 + 24 @@ -494,8 +494,8 @@ - 32 - 32 + 18 + 18 @@ -504,8 +504,8 @@ - 40 - 40 + 24 + 24 @@ -520,8 +520,8 @@ - 32 - 32 + 18 + 18 @@ -530,8 +530,8 @@ - 40 - 40 + 24 + 24 @@ -546,8 +546,8 @@ - 32 - 32 + 18 + 18 diff --git a/infomation/InfoMainForm.cpp b/infomation/InfoMainForm.cpp index 5d0ffc8..882a5b5 100644 --- a/infomation/InfoMainForm.cpp +++ b/infomation/InfoMainForm.cpp @@ -8,10 +8,11 @@ ui->setupUi(this); initForm(); + initMenuList(); initSubMenuForms(); - initMenuButtons(); - ui->menuDeptTask->click(); + ui->wdgtPage->setCurrentIndex(0); + ui->listMenu->setCurrentIndex(ui->listMenu->model()->index(0, 0)); } InfoMainForm::~InfoMainForm() @@ -22,12 +23,29 @@ void InfoMainForm::initForm() { // 加载样式表 - QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoMain.css"); + QString qssStyle = QssFileUtils::loadQssFileContent(":/qss/infoMain.css"); if (qssStyle.isEmpty() == false) { this->setStyleSheet(qssStyle); // 仅本窗口生效 } +} +void InfoMainForm::initMenuList() +{ + QStandardItemModel * model = new QStandardItemModel(ui->listMenu); + QStringList menuLabelList; + menuLabelList << "实验室任务" << "我的任务" << "新建任务单" + << "标准设备管理" << "被检设备管理" + << "检定数据管理" << "核查数据管理" + << "检定程序管理" << "核查程序管理" + << "体系文件" << "现行测试校准检定方法" << "签名管理" << "数据同步"; + int idxLabel = 0; + for (QString label : menuLabelList) { + QStandardItem * menu = new QStandardItem(label); + menu->setData(idxLabel, Qt::UserRole); + model->appendRow(menu); + idxLabel++; + } - ui->scrollArea->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框 + ui->listMenu->setModel(model); } void InfoMainForm::initSubMenuForms() { @@ -35,29 +53,12 @@ fmDeptTask = new DeptTaskForm(this); fmNewTask = new NewTaskForm(this); - ui->wdgtInfoTable->insertWidget(0, fmDeptTask); - ui->wdgtInfoTable->insertWidget(1, fmMyTask); - ui->wdgtInfoTable->insertWidget(2, fmNewTask); -} -void InfoMainForm::initMenuButtons() -{ - // 查找所有 QPushButton 类型的子控件 - QButtonGroup * funcButtGroup = new QButtonGroup(); // buttonGroup用于checked状态互斥 - QList buttList = ui->wdgtMenu->findChildren(); - for (int i = 0; i < buttList.size(); i++) { - QToolButton * menuButt = buttList.at(i); - menuButt->setProperty("index", i); - menuButt->setCheckable(true); - funcButtGroup->addButton(menuButt); - connect(menuButt, &QToolButton::clicked, this, &InfoMainForm::onMenuButtonsAction); - } + ui->wdgtPage->insertWidget(0, fmDeptTask); + ui->wdgtPage->insertWidget(1, fmMyTask); + ui->wdgtPage->insertWidget(2, fmNewTask); } -void InfoMainForm::onMenuButtonsAction() +void InfoMainForm::on_listMenu_clicked(const QModelIndex &index) { - QToolButton *btn = qobject_cast(sender()); - if(btn) { - btn->setChecked(true); - ui->wdgtInfoTable->setCurrentIndex(btn->property("index").toInt()); - } + ui->wdgtPage->setCurrentIndex(index.data(Qt::UserRole).toInt()); } diff --git a/infomation/InfoMainForm.h b/infomation/InfoMainForm.h index d6060ea..0c4b996 100644 --- a/infomation/InfoMainForm.h +++ b/infomation/InfoMainForm.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "task/MyTaskForm.h" #include "task/DeptTaskForm.h" @@ -28,11 +31,11 @@ NewTaskForm * fmNewTask; void initForm(); + void initMenuList(); void initSubMenuForms(); - void initMenuButtons(); private slots: - void onMenuButtonsAction(); + void on_listMenu_clicked(const QModelIndex &index); }; #endif // INFOMAINFORM_H diff --git a/infomation/InfoMainForm.ui b/infomation/InfoMainForm.ui index d9066dd..9ebd47e 100644 --- a/infomation/InfoMainForm.ui +++ b/infomation/InfoMainForm.ui @@ -30,250 +30,59 @@ 0 - - - - 0 - 0 - - - - - 300 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 300 - 624 - + + + + 0 - - - 0 - 0 - + + 0 - - - 300 - 0 - + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 295 - 48 - - - - 实验室任务 - - - - - - - - 295 - 48 - - - - 我的任务 - - - - - - - - 295 - 48 - - - - 新建任务单 - - - - - - - - 295 - 48 - - - - 标准设备管理 - - - - - - - - 295 - 48 - - - - 被检设备管理 - - - - - - - - 295 - 48 - - - - 检定数据管理 - - - - - - - - 295 - 48 - - - - 核查数据管理 - - - - - - - - 295 - 48 - - - - 检定程序管理 - - - - - - - - 295 - 48 - - - - 核查程序管理 - - - - - - - - 295 - 48 - - - - 体系文件 - - - - - - - - 295 - 48 - - - - 现行测试校准检定方法 - - - - - - - - 295 - 48 - - - - 签名管理 - - - - - - - - 295 - 48 - - - - 数据同步 - - - - - - - Qt::Vertical - - - - 20 - 19 - - - - - - + + 0 + + + 0 + + + + + + 280 + 0 + + + + + - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/infomation/task/DeptTaskForm.cpp b/infomation/task/DeptTaskForm.cpp index cc6bf31..8f956eb 100644 --- a/infomation/task/DeptTaskForm.cpp +++ b/infomation/task/DeptTaskForm.cpp @@ -7,6 +7,7 @@ { ui->setupUi(this); + initForm(); initFormTable(); // 绑定信号与槽 @@ -29,6 +30,43 @@ ui->tableDeptTask->adjustTableWidth(); } +void DeptTaskForm::initForm() +{ + // 加载样式表 + QString qssStyle = QssFileUtils::loadQssFileContent(QApplication::applicationDirPath() + "/qss/infoTable.css"); + if (qssStyle.isEmpty() == false) { + this->setStyleSheet(qssStyle); // 仅本窗口生效 + } + + // 查询条件的样式 + QList children = ui->wdgtQueryBox->findChildren(); + for (QWidget * wdgt : children) { + wdgt->setProperty("class", "queryBox"); + + if (QString(wdgt->metaObject()->className()).contains("QLineEdit")) { + // 绑定输入框回车事件 只在密码输入框执行 + connect((QLineEdit *)wdgt, &QLineEdit::returnPressed, this, [=](){ + emit ui->btnQuery->clicked(); + }); + } + } + + // 查询和重置按钮 + ui->btnQuery->setProperty("class", "btnDefault"); + ui->btnResetQuery->setProperty("class", "btnResetQuery"); + + ui->tableDeptTask->setTableProperty("class", "defaultTable"); + + // 分页组件 + QStringList btnPageGroupUrls; + btnPageGroupUrls << ":/image/infomation/btnPageFirst.png" << ":/image/infomation/btnPagePre.png" + << ":/image/infomation/btnPageNext.png" << ":/image/infomation/btnPageLast.png"; + ui->tableDeptTask->setPageButtonIcons(btnPageGroupUrls); + ui->tableDeptTask->setPageButtonProperty("class", "pageBtnGroup"); + + ui->tableDeptTask->setDataRowHeight(45); +} + void DeptTaskForm::initFormTable() { // 初始化查询条件 @@ -39,26 +77,61 @@ QList> deptTaskColumns = localServ.getInfomationTableColumns("deptTask"); ui->tableDeptTask->setColumns(deptTaskColumns); + initMeasureStatusSelect(); + initUrgentSelect(); + ui->tableDeptTask->initTableWidget(); ui->tableDeptTask->initTableHeader(); } +void DeptTaskForm::initMeasureStatusSelect() +{ + ui->selectStatus->addItem("全部状态", ""); + + SysLocalService localServ; + QMap statusList = localServ.getTaskMeasureStatusDict(); + + for (QString key : statusList.keys()) { + if (key.mid(14, 1) == "1") { + continue; + } + ui->selectStatus->addItem(statusList.value(key), key.mid(14, 1)); + } + ui->selectStatus->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} +void DeptTaskForm::initUrgentSelect() +{ + ui->selectUrgent->addItem("全部", ""); + ui->selectUrgent->addItem("不加急", "0"); + ui->selectUrgent->addItem("加急", "1"); + + ui->selectUrgent->setView(new QListView()); // 使ComboBox下拉选项 的QSS生效的关键代码 +} + void DeptTaskForm::getDeptTaskList(int currPage) { TaskService taskServ; + // 获取所有查询条件 TaskRequest request; request.userId = ProMemory::getInstance().getLoginUser().value("id").toString(); request.sampleName = ui->inputDevName->text(); request.sampleModel = ui->inputDevModel->text(); - request.customerName = ui->selectCustomer->currentData().toString(); + request.customerName = ui->inputCustomer->text(); request.requireStart = ui->inputStartDate->date().toString("yyyy-MM-dd"); request.requireEnd = ui->inputEndDate->date().toString("yyyy-MM-dd"); -// request.measureStatusList << ui->selectStatus->currentData().toString(); - request.isUrgent = ui->btnIsUrgent->isChecked() ? "1" : "0"; + request.isUrgent = ui->selectUrgent->currentData().toString(); + // 选择第一个选项时 条件为空 + if (ui->selectStatus->currentIndex() != 0) { + request.measureStatusList << ui->selectStatus->currentData().toString(); + } else { + request.measureStatusList.clear(); + } + // 查询页 page.currentPage = currPage; + // 查询数据库 QList deptTaskList = taskServ.getDeptTaskListPage(request, page); QList> pageData; for (TaskDTO task : deptTaskList) { @@ -79,8 +152,11 @@ } + // 设置分页表格数据 ui->tableDeptTask->setTotalCount(page.totalCount); ui->tableDeptTask->setDatas(pageData); + +// qDebug() << ui->tableDeptTask->getTableInstance()->cellWidget(3, 9)->metaObject()->className(); } void DeptTaskForm::on_btnQuery_clicked() @@ -90,5 +166,15 @@ void DeptTaskForm::on_btnResetQuery_clicked() { + ui->inputDevName->setText(""); + ui->inputDevModel->setText(""); + ui->inputCustomer->setText(""); + ui->inputStartDate->setDate(QDate::currentDate().addYears(-1)); + ui->inputEndDate->setDate(QDate::currentDate().addMonths(1)); + + ui->selectStatus->setCurrentIndex(0); + ui->selectUrgent->setCurrentIndex(0); + + getDeptTaskList(0); } diff --git a/infomation/task/DeptTaskForm.h b/infomation/task/DeptTaskForm.h index 3c1ad5b..dab8e16 100644 --- a/infomation/task/DeptTaskForm.h +++ b/infomation/task/DeptTaskForm.h @@ -2,6 +2,7 @@ #define DEPTTASKFORM_H #include +#include #include "dao/service/SysLocalService.h" #include "dao/service/TaskService.h" @@ -28,8 +29,12 @@ Ui::DeptTaskForm *ui; Page page; + void initForm(); void initFormTable(); + void initMeasureStatusSelect(); + void initUrgentSelect(); + private slots: void getDeptTaskList(int currPage); void on_btnQuery_clicked(); diff --git a/infomation/task/DeptTaskForm.ui b/infomation/task/DeptTaskForm.ui index 2287fae..4a013d6 100644 --- a/infomation/task/DeptTaskForm.ui +++ b/infomation/task/DeptTaskForm.ui @@ -6,7 +6,7 @@ 0 0 - 1442 + 1531 600 @@ -18,22 +18,22 @@ 0 - 0 + 20 - 0 + 20 - 15 + 20 - 15 + 0 - 15 + 10 10 @@ -89,7 +89,7 @@ - + 0 @@ -102,33 +102,26 @@ 36 - - - 请选择委托方 - - + + 委托方 + - - - - 0 - 0 - + + + Qt::Horizontal - + + QSizePolicy::Fixed + + - 150 - 36 + 20 + 20 - - - 请选择检测状态 - - - + @@ -154,6 +147,13 @@ + + + + + + + @@ -164,15 +164,50 @@ - + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + - 0 + 150 36 - - 加急 + + + + + + + 0 + 0 + + + + + 120 + 36 + diff --git a/res/image/Index/btnPageFirst.png b/res/image/Index/btnPageFirst.png deleted file mode 100644 index 3759e8c..0000000 --- a/res/image/Index/btnPageFirst.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageLast.png b/res/image/Index/btnPageLast.png deleted file mode 100644 index 89eb51d..0000000 --- a/res/image/Index/btnPageLast.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPageNext.png b/res/image/Index/btnPageNext.png deleted file mode 100644 index 4de6904..0000000 --- a/res/image/Index/btnPageNext.png +++ /dev/null Binary files differ diff --git a/res/image/Index/btnPagePre.png b/res/image/Index/btnPagePre.png deleted file mode 100644 index badfa15..0000000 --- a/res/image/Index/btnPagePre.png +++ /dev/null Binary files differ diff --git a/res/image/infomation/btnPageFirst.png b/res/image/infomation/btnPageFirst.png new file mode 100644 index 0000000..3759e8c --- /dev/null +++ b/res/image/infomation/btnPageFirst.png Binary files differ diff --git a/res/image/infomation/btnPageLast.png b/res/image/infomation/btnPageLast.png new file mode 100644 index 0000000..89eb51d --- /dev/null +++ b/res/image/infomation/btnPageLast.png Binary files differ diff --git a/res/image/infomation/btnPageNext.png b/res/image/infomation/btnPageNext.png new file mode 100644 index 0000000..4de6904 --- /dev/null +++ b/res/image/infomation/btnPageNext.png Binary files differ diff --git a/res/image/infomation/btnPagePre.png b/res/image/infomation/btnPagePre.png new file mode 100644 index 0000000..badfa15 --- /dev/null +++ b/res/image/infomation/btnPagePre.png Binary files differ diff --git a/res/image/main/icon_close.png b/res/image/main/icon_close.png index f3aa270..7018f06 100644 --- a/res/image/main/icon_close.png +++ b/res/image/main/icon_close.png Binary files differ diff --git a/res/image/main/icon_max.png b/res/image/main/icon_max.png index 6cbf073..eb453fc 100644 --- a/res/image/main/icon_max.png +++ b/res/image/main/icon_max.png Binary files differ diff --git a/res/image/main/icon_min.png b/res/image/main/icon_min.png index 2f524d9..c0e21ca 100644 --- a/res/image/main/icon_min.png +++ b/res/image/main/icon_min.png Binary files differ diff --git a/res/image/main/icon_setting.png b/res/image/main/icon_setting.png index 8686833..509d47f 100644 --- a/res/image/main/icon_setting.png +++ b/res/image/main/icon_setting.png Binary files differ diff --git a/res/images.qrc b/res/images.qrc index a6ba788..dcb8ac5 100644 --- a/res/images.qrc +++ b/res/images.qrc @@ -32,10 +32,6 @@ image/Index/u7313.svg image/Index/u5089.png image/Index/u138.png - image/Index/btnPageFirst.png - image/Index/btnPageLast.png - image/Index/btnPageNext.png - image/Index/btnPagePre.png image/Index/u2326.svg image/Index/arrowDown.png image/Index/arrowUp.png @@ -104,5 +100,9 @@ image/main/icon_menu_infomation.png image/main/icon_menu_infomation_checked.png image/msgbox/icon_box_close.png + image/infomation/btnPageFirst.png + image/infomation/btnPageLast.png + image/infomation/btnPageNext.png + image/infomation/btnPagePre.png diff --git a/res/qss.qrc b/res/qss.qrc index fbb36c0..82ef5e5 100644 --- a/res/qss.qrc +++ b/res/qss.qrc @@ -1,10 +1,9 @@ - qss/preCheck.css qss/loginForm.css qss/mainForm.css - qss/baseInfomation.css qss/messageBox.css qss/infoMain.css + qss/infoTable.css diff --git a/res/qss/infoMain.css b/res/qss/infoMain.css index 2f178c7..039979c 100644 --- a/res/qss/infoMain.css +++ b/res/qss/infoMain.css @@ -1,26 +1,43 @@ QWidget { background-color: #FFFFFF; } -QLabel { + +QListView#listMenu { + border: 0px; + background-image: url(:/image/login/bg_login.png); + background-position: center; font-family: Microsoft YaHei; font-size: 18px; + font-weight: bold; + padding-top: 20px; } -QScrollArea { - border: none; +QListView#listMenu:focus { + outline: 0px; } -QScrollBar::vertical { - width: 5px; - background: #FFFFFF; - border: none; +QListView#listMenu:item { + color: #FFFFFF; + height: 48px; + border: 0px; + padding-left: 20px; + margin-right: 20px; + border-top-right-radius: 10px; + border-bottom-right-radius: 10px; } -QScrollBar::handle::vertical { - width: 5px; +QListView#listMenu:item:selected { + background-color: #69c2f7; + color: #2F6FC6; +} +QListView#listMenu:item:hover { + background: rgba(80, 72, 151, 0.3); + color: #FFFFFF; +} + +QListView#listMenu QScrollBar::vertical { + width: 4px; + background: #69c2f7; + border: 0px; +} +QListView#listMenu QScrollBar::handle::vertical { background: #2F6FC6; - border: none; + border: 0px; } -QScrollBar::add-line::vertical { - border: none; -} -QScrollBar::sub-line::vertical { - border: none; -} \ No newline at end of file diff --git a/res/qss/infoTable.css b/res/qss/infoTable.css new file mode 100644 index 0000000..137dd01 --- /dev/null +++ b/res/qss/infoTable.css @@ -0,0 +1,525 @@ +QWidget { + background-color: #FFFFFF; +} +QLabel { + font-family: Microsoft YaHei; + font-size: 16px; +} + +/** 查询条件 **/ +QWidget#wdgtQueryBox QLineEdit[class=queryBox] { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} +QWidget#wdgtQueryBox QDateEdit[class=queryBox] { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} +QWidget#wdgtQueryBox QComboBox[class=queryBox] { + border-radius: 6px; + font-family: Microsoft YaHei; + padding-left: 10px; + color: #333333; + border: 1px solid #E3E3E3; + font-size: 16px; +} + +/** 普通按钮 **/ +QToolButton[class="btnDefault"] { + border-radius: 12px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; +} +/** 查询重置按钮 **/ +QToolButton[class="btnOpposite"] { + border-radius: 12px; + border: 1px solid #2F6FC6; + background-color: #FFFFFF; + color: #2F6FC6; + font-family: "Microsoft YaHei"; + font-size: 18px; +} + +/** 表格顶端的标题栏 **/ +QLabel[class="frameLabel"]{ + background-color: #2F6FC6; + border: 0px; + border-radius: 0px; + border-top-left-radius: 10px; + border-top-right-radius: 10px; + padding: 10px; + font-size: 16px; + color: #FFFFFF; + font-family: "Microsoft YaHei"; +} + +/** 查询条件输入框 **/ +QLineEdit[class="gridInput"] { + border-radius: 10px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; + background-color: #DFEBF2; + padding-left: 10px; +} + +QComboBox[class="defaultSelect"] { + border-radius: 6px; + font-family: "Microsoft YaHei"; + padding-left: 16px; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; +} +QComboBox[class="defaultSelect"]::down-arrow { + image: url(":/image/main/arrow_down.png"); +} +QComboBox[class="defaultSelect"]::down-arrow::on { + image: url(":/image/main/arrow_up.png"); +} +QComboBox[class="defaultSelect"]::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} +QComboBox[class="defaultSelect"] QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + font-family: "Microsoft YaHei"; + font-size: 16px; + outline: 0px; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item{ + height: 40px; + font-family: "Microsoft YaHei"; + color: #333333; + padding-left: 9px; + background-color: #FFFFFF; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:hover{ + color: #FFFFFF; + background-color: #2F6FC6; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:selected{ + color: #FFFFFF; + background-color: #2F6FC6; +} +QComboBox[class="defaultSelect"] QScrollBar::vertical { + width: 5px; + background: #FFFFFF; + border: none; +} +QComboBox[class="defaultSelect"] QScrollBar::handle::vertical { + width: 5px; + background: #2F6FC6; + border: none; +} +QComboBox[class="defaultSelect"] QScrollBar::add-line::vertical { + border: none; +} +QComboBox[class="defaultSelect"] QScrollBar::sub-line::vertical { + border: none; +} + +/** 查询普通按钮 **/ +QWidget#wdgtQueryBox QToolButton { + border-radius: 12px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; +} +/** 查询重置按钮 **/ +QWidget#wdgtQueryBox QToolButton[class="btnResetQuery"] { + border-radius: 12px; + border: 1px solid #2F6FC6; + background-color: #FFFFFF; + color: #2F6FC6; + font-family: "Microsoft YaHei"; + font-size: 18px; +} + +/** 表格部分通用样式 **/ +QTableWidget { + border: 0px; + font-size: 18px; + color: #333333; +} + +QTableWidget QHeaderView::section { + background-color: #2F6FC6; + border: 1px solid #FFFFFF; + color: #FFFFFF; + font-size: 18px; + min-height: 50px; +} + +QTableWidget::item { + padding-left: 10px; + padding-right: 10px; + border: 0px; +} + +QTableWidget::item::selected { + /*background: #FFFFFF; */ + color: #2F6FC6; +} + +QTableWidget QWidget[class="wdgtOper"] { + background: transparent; +} + +QLabel[class="urlText"] { + color: #0000FF; + text-decoration: underline; +} + +QToolTip { + font-family: "Microsoft Yahei"; + font-size: 18px; + padding: 10px; +} + +QPushButton[class="tableBtnDetail"] { + background: transparent; + color: #2F6FC6; + border: 0px; + font-size: 16px; + font-family: "Microsoft YaHei"; + text-decoration: underline; +} +QPushButton[class="tableBtnDelete"] { + background: transparent; + color: #F56C6C; + border: 0px; + font-size: 16px; + font-family: "Microsoft YaHei"; + text-decoration: underline; +} + + +/** 分页组件 **/ +QWidget[class="wdgtPageBtn"] { + background: #2F6FC6; + border-radius: 6px; +} +QWidget[class="wdgtPageBtn"] QToolButton { + background: transparent; +} +QWidget[class="wdgtPage"] QLabel { + color: #333333; + font-size: 16px; + font-family: "Microsoft YaHei"; +} + +/** 对话框弹窗顶端的标题栏 **/ +QWidget[class="dlgTitle"]{ + background-color: #2F6FC6; + border: 0px; + padding: 10px; +} +QWidget[class="dlgTitle"] QLabel{ + background: transparent; + border: 0px; + padding: 10px; + font-size: 20px; + color: #FFFFFF; + font-family: "Microsoft YaHei"; +} + +/** 详情表格 **/ +QWidget[class="detailTable"] QLabel{ + font-size: 18px; + color: #333333; + font-family: "Microsoft YaHei"; +} +QWidget[class="detailTable"] QLabel[class="urlText"] { + color: #0000FF; + text-decoration: underline; +} +/** 文本输入框 **/ +QWidget[class="detailTable"] QLineEdit{ + border-radius: 10px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; + background-color: #DFEBF2; + padding-left: 10px; +} +/** 日期选择器 **/ +QWidget[class="detailTable"] QDateEdit { + border-radius: 10px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; + padding-left: 10px; +} + +/** 下拉列表框的样式 **/ +QWidget[class="detailTable"] QComboBox { + border-radius: 6px; + font-family: "Microsoft YaHei"; + padding-left: 16px; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 16px; +} +QWidget[class="detailTable"] QComboBox::down-arrow { + image: url(":/image/main/arrow_down.png"); +} +QWidget[class="detailTable"] QComboBox::down-arrow::on { + image: url(":/image/main/arrow_up.png"); +} +QWidget[class="detailTable"] QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + font-family: "Microsoft YaHei"; + font-size: 16px; + outline: 0px; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView::item{ + height: 40px; + font-family: "Microsoft YaHei"; + color: #333333; + padding-left: 9px; + background-color: #FFFFFF; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView::item:hover{ + color: #FFFFFF; + background-color: #2F6FC6; +} +QWidget[class="detailTable"] QComboBox QAbstractItemView::item:selected{ + color: #FFFFFF; + background-color: #2F6FC6; +} + +QCheckBox[class="defaultSolid"] { + color: #333333; + font-family: "Microsoft YaHei"; + font-size: 18px; + /*padding-left: 5px;*/ +} +QCheckBox[class="defaultSolid"]::indicator { + width: 20px; + height: 20px; + border-radius: 5px; + border: 2px solid #2F6FC6; +} +QCheckBox[class="defaultSolid"]::indicator::unchecked { + background: #FFFFFF; + /*border: 2px solid #CCCCC;*/ +} +QCheckBox[class="defaultSolid"]::indicator::checked { + background: #2F6FC6; +} + +/* +QWidget#wdgtQueryBox QLineEdit { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} +QWidget#wdgtQueryBox QLineEdit::read-only { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; + background-color: #F3F3F3; +} + +QWidget#wdgtQueryBox QDateEdit { + border: 1px solid #E3E3E3; + border-radius: 6px; + padding-left: 10px; + font-family: Microsoft YaHei; + font-size: 16px; +} + +QWidget#wdgtQueryBox QComboBox { + border-radius: 6px; + font-family: Microsoft YaHei; + padding-left: 10px; + color: #333333; + border: 1px solid #E3E3E3; + font-size: 16px; +} + +QWidget#wdgtQueryBox QComboBox::down-arrow { + image: url(":/image/Index/arrowDown.png"); +} +QWidget#wdgtQueryBox QComboBox::down-arrow::on { + image: url(":/image/Index/arrowUp.png"); +} + +QWidget#wdgtQueryBox QComboBox::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} + +QWidget#wdgtQueryBox QComboBox QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + selection-background-color: #2F6FC6; + selection-color: #FFFFFF; + font-family: "Microsoft YaHei"; + outline: 0px; + font-size: 16px; +} + +QWidget#wdgtQueryBox QComboBox QAbstractItemView::item { + height: 30px; + color: #333333; + background-color: #FFFFFF; + font-size: 16px; +} +QWidget#wdgtQueryBox QComboBox QAbstractItemView::item:hover { + color: #FFFFFF; + background-color: #2F6FC6; +} + +QWidget#wdgtQueryBox QComboBox QAbstractItemView::item:selected { + color: #FFFFFF; + background-color: #2F6FC6; +} + + +QWidget#wdgtQueryBox QComboBox QScrollBar::vertical { + width: 10px; + background: #FFFFFF; + border: none; +} + +QWidget#wdgtQueryBox QComboBox QScrollBar::handle::vertical { + width: 10px; + background: #2F6FC6; + border: none; +} + +QWidget#wdgtQueryBox QComboBox QScrollBar::add-line::vertical { + border: none; +} +QWidget#wdgtQueryBox QComboBox QScrollBar::sub-line::vertical { + border: none; +} + + + +QWidget#wdgtFooter QToolButton { + border-radius: 6px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; + font-weight: bold; +} + +QComboBox[class="defaultSelect"] { + border-radius: 6px; + font-family: Microsoft YaHei; + padding-left: 10px; + color: #333333; + border: 1px solid #E3E3E3; + font-size: 16px; +} +QComboBox[class="defaultSelect"]::down-arrow { + image: url(":/image/Index/arrowDown.png"); +} +QComboBox[class="defaultSelect"]::down-arrow::on { + image: url(":/image/Index/arrowUp.png"); +} +QComboBox[class="defaultSelect"]::drop-down { + subcontrol-origin: padding; + subcontrol-position: top right; + width: 20px; + border: 0px; + padding-right: 15px; +} +QComboBox[class="defaultSelect"] QAbstractItemView { + color: #333333; + background-color: #E1E1ED; + selection-background-color: #2F6FC6; + selection-color: #FFFFFF; + font-family: "Microsoft YaHei"; + outline: 0px; + font-size: 16px; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item { + height: 30px; + color: #333333; + background-color: #FFFFFF; + font-size: 16px; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:hover { + color: #FFFFFF; + background-color: #2F6FC6; +} +QComboBox[class="defaultSelect"] QAbstractItemView::item:selected { + color: #FFFFFF; + background-color: #2F6FC6; +} + +QPushButton#btnDetailCategory, QPushButton#btnSaveAddr { + border-radius: 6px; + background-color: #2F6FC6; + color: #FFFFFF; + font-family: "Microsoft YaHei"; + font-size: 18px; + font-weight: bold; +} +*/ + +/* 页面整体背景设置为灰色 */ +QFrame#wdgtStateMain { + background-color: #E3E3E3; +} +/* 信息块使用白色背景 用于区域分割 */ +QFrame[class="infoBlock"] { + background-color: #FFFFFF; +} +/* 子标题样式 */ +QWidget[class="subTitle"] QLabel { + color: #2F6FC6; + font-weight: bold; + font-size: 20px; + min-height: 40px; +} + +QLabel[class="gridLabel"] { + font-size: 18px; + padding: 10px 20px; +} +/* +QLineEdit[class="gridInput"] { + border-radius: 6px; + font-family: "Microsoft YaHei"; + color: #333333; + border: 1px solid #CCCCCC; + font-size: 18px; +} +*/ diff --git a/res/qss/mainForm.css b/res/qss/mainForm.css index cf39f4e..fda097c 100644 --- a/res/qss/mainForm.css +++ b/res/qss/mainForm.css @@ -1,5 +1,5 @@ QWidget { - background: transparent; + /*background: transparent;*/ } QLable { font-size: 16px; @@ -37,7 +37,7 @@ } QWidget#wdgtFunc QToolButton:checked { background: #69C2F7; - color: #FFFFFF; + color: #2F6FC6; } QWidget#wdgtFunc QToolButton:checked:hover { background: #69C2F7;