Browse Source

'登录调整'

zsf 1 year ago
parent
commit
8849f5b781

+ 97 - 0
ExpertClient/EXConfig.cpp

@@ -0,0 +1,97 @@
+#include "EXConfig.h"
+
+#include <QSettings>
+
+QSettings *EXConfig::defaultConfig()
+{
+    static QSettings *config = nullptr;
+    if (config == nullptr) {
+        config = new QSettings("config.ini", QSettings::IniFormat);
+        config->setIniCodec("UTF-8");
+    }
+    return config;
+}
+
+const QString EXConfig::username()
+{
+    return defaultConfig()->value("USERCONFIG/UserName", "").toString();
+}
+
+void EXConfig::setUsername(const QString username)
+{
+    defaultConfig()->setValue("USERCONFIG/UserName", username);
+}
+
+const QString EXConfig::password()
+{
+    return defaultConfig()->value("USERCONFIG/Password", "").toString();
+}
+
+void EXConfig::setPassword(const QString password)
+{
+    defaultConfig()->setValue("USERCONFIG/Password", password);
+}
+
+bool EXConfig::rememberPassword()
+{
+    return defaultConfig()->value("USERCONFIG/RememberPassword", false).toBool();
+}
+
+void EXConfig::setRememberPassword(bool rememberPassword)
+{
+    defaultConfig()->setValue("USERCONFIG/RememberPassword", rememberPassword);
+    if (rememberPassword == false) {
+        setUsername("");
+        setPassword("");
+    }
+}
+
+int EXConfig::roleType()
+{
+    return defaultConfig()->value("USERCONFIG/RoleType", "").toInt();
+}
+
+void EXConfig::setRoleType(int roleType)
+{
+    defaultConfig()->setValue("USERCONFIG/RoleType", roleType);
+}
+
+const QString EXConfig::techMessaureConfig()
+{
+    return defaultConfig()->value("USERCONFIG/TechMessaureConfig", "").toString();
+}
+
+void EXConfig::setTechMessaureConfig(const QString techMessaureConfig)
+{
+    defaultConfig()->setValue("USERCONFIG/TechMessaureConfig", techMessaureConfig);
+}
+
+const QString EXConfig::dbPath()
+{
+    return defaultConfig()->value("USERCONFIG/DbPath", "").toString();
+}
+
+void EXConfig::setDbPath(const QString dbPath)
+{
+    defaultConfig()->setValue("USERCONFIG/DbPath", dbPath);
+}
+
+const QString EXConfig::project()
+{
+    return defaultConfig()->value("USERCONFIG/Project", "").toString();
+}
+
+void EXConfig::setProject(const QString project)
+{
+    defaultConfig()->setValue("USERCONFIG/Project", project);
+}
+
+bool EXConfig::passwordModified()
+{
+    return defaultConfig()->value("USERCONFIG/PasswordModified", false).toBool();
+}
+
+void EXConfig::setPasswordModified(bool modified)
+{
+    defaultConfig()->setValue("USERCONFIG/PasswordModified", modified);
+}

+ 43 - 0
ExpertClient/EXConfig.h

@@ -0,0 +1,43 @@
+#ifndef EXCONFIG_H
+#define EXCONFIG_H
+
+#include <QObject>
+
+class QSettings;
+
+class EXConfig : public QObject
+{
+    Q_OBJECT
+public:
+    explicit EXConfig(QObject *parent = nullptr);
+
+    static QSettings *defaultConfig();
+
+    static const QString username();
+    static void setUsername(QString const username);
+
+    static const QString password();
+    static void setPassword(QString const password);
+
+    static bool rememberPassword();
+    static void setRememberPassword(bool rememberPassword);
+
+    static int roleType();
+    static void setRoleType(int roleType);
+
+    static const QString techMessaureConfig();
+    static void setTechMessaureConfig(QString const techMessaureConfig);
+
+    static const QString dbPath();
+    static void setDbPath(QString const dbPath);
+
+    static const QString project();
+    static void setProject(QString const project);
+
+    static bool passwordModified();
+    static void setPasswordModified(bool modified);
+
+signals:
+};
+
+#endif  // EXCONFIG_H

+ 1 - 1
ExpertClient/EXDataTableView.cpp

@@ -51,7 +51,7 @@ EXDataTableView::EXDataTableView(SchemePlanManager::SchemeProcessInfo process, Q
     m_comboDelegate = new EXDataTableComboDelegate(this);
 
     m_user = new QFUser();
-    UserService().QueryUserInfoById(m_user, 62);
+    UserService().QueryUserInfoById(m_user, 63);
 
     m_export = new QXlsx::Document(this);
 }

+ 150 - 0
ExpertClient/EXLoginWidget.cpp

@@ -0,0 +1,150 @@
+#include "EXLoginWidget.h"
+
+#include "EXConfig.h"
+
+#include <dbService/ClassSet.h>
+
+#include <Widgets/LineEdit.h>
+#include <Widgets/CheckBox.h>
+#include <Widgets/Button.h>
+
+#include <QBoxLayout>
+#include <QLabel>
+#include <QPainter>
+
+EXLoginWidget::EXLoginWidget(QWidget *parent) : QWidget(parent)
+{
+    initialize();
+    initLayout();
+    connectSignalsAndSlots();
+    loadAccount();
+
+    resize(500, 500);
+}
+
+void EXLoginWidget::paintEvent(QPaintEvent *event)
+{
+    QWidget::paintEvent(event);
+    QPainter painter(this);
+    QPixmap pixmap(":/resource/background/8.jpg");
+    painter.drawPixmap(0, 0,
+                       pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
+}
+
+void EXLoginWidget::setTitle(const QString title)
+{
+    m_titleLabel->setText(title);
+}
+
+const QString EXLoginWidget::account() const
+{
+    return m_accLineEdit->text();
+}
+
+const QString EXLoginWidget::password() const
+{
+    return m_pwLineEdit->text();
+}
+
+bool EXLoginWidget::rememberPassword() const
+{
+    return m_remCheckBox->isChecked();
+}
+
+void EXLoginWidget::saveAccountConfig() const
+{
+    bool rem = m_remCheckBox->isChecked();
+    EXConfig::setRememberPassword(rem);
+    if (rem) {
+        EXConfig::setUsername(m_accLineEdit->text());
+        EXConfig::setPassword(m_pwLineEdit->text());
+    }
+}
+
+void EXLoginWidget::initialize()
+{
+    m_vBoxLayout = new QVBoxLayout(this);
+
+    m_titleLabel = new QLabel(this);
+    m_titleLabel->setStyleSheet("color:#ffffff;");
+    QFont ft;
+    ft.setPointSize(15);
+    ft.setBold(true);
+    m_titleLabel->setFont(ft);
+
+    m_accLineEdit = new LineEdit(this);
+    m_accLineEdit->setIsClearButtonEnabled(true);
+    m_accLineEdit->setPlaceholderText("请输入账号");
+    m_accLineEdit->setFixedWidth(250);
+
+    m_pwLineEdit = new PasswordLineEdit(this);
+    m_pwLineEdit->setPlaceholderText("请输入密码");
+    m_pwLineEdit->setFixedWidth(250);
+
+    m_remLayout   = new QHBoxLayout();
+    m_remCheckBox = new CheckBox("记住密码", this);
+    m_remCheckBox->setHidden(true);
+
+    const QString &s = m_remCheckBox->styleSheet() + "CheckBox {color:white}";
+    m_remCheckBox->setStyleSheet(s);
+
+    m_buttonLayout = new QHBoxLayout();
+    m_loginButton  = new PushButton("登录", this);
+    m_cancelButton = new PushButton("取消", this);
+
+    m_adminTips = new QLabel(this);
+    m_adminTips->setText("默认管理员账号密码是admin/admin");
+    m_adminTips->setStyleSheet("color:#dddddd");
+}
+
+void EXLoginWidget::initLayout()
+{
+    setLayout(m_vBoxLayout);
+    m_vBoxLayout->setAlignment(Qt::AlignCenter);
+
+    m_vBoxLayout->addWidget(m_titleLabel);
+    m_vBoxLayout->addSpacing(20);
+    m_vBoxLayout->addWidget(m_accLineEdit);
+    m_vBoxLayout->addSpacing(20);
+    m_vBoxLayout->addWidget(m_pwLineEdit);
+    m_vBoxLayout->addSpacing(20);
+
+    m_vBoxLayout->addLayout(m_remLayout);
+    m_remLayout->addWidget(m_remCheckBox);
+    m_remLayout->addSpacing(30);
+
+    m_vBoxLayout->addSpacing(40);
+
+    m_vBoxLayout->addLayout(m_buttonLayout);
+    m_buttonLayout->addWidget(m_loginButton);
+    m_buttonLayout->addSpacing(20);
+    m_buttonLayout->addWidget(m_cancelButton);
+
+    m_vBoxLayout->addSpacing(10);
+    m_vBoxLayout->addWidget(m_adminTips);
+}
+
+void EXLoginWidget::connectSignalsAndSlots()
+{
+    connect(m_loginButton, &PushButton::clicked, this, &EXLoginWidget::signalLogin);
+    connect(m_cancelButton, &PushButton::clicked, this, &EXLoginWidget::signalCancel);
+}
+
+void EXLoginWidget::loadAccount()
+{
+    int roleType = EXConfig::roleType();
+    if (roleType == QFUser::SuperAdmin) {
+        setTitle("管理员登录");
+    } else {
+        setTitle("专家登录");
+    }
+
+    bool rem = EXConfig::rememberPassword();
+    m_remCheckBox->setChecked(rem);
+    if (rem) {
+        m_accLineEdit->setText(EXConfig::username());
+        m_pwLineEdit->setText(EXConfig::password());
+    }
+
+    m_adminTips->setHidden(EXConfig::passwordModified());
+}

+ 59 - 0
ExpertClient/EXLoginWidget.h

@@ -0,0 +1,59 @@
+#ifndef EXLOGINWIDGET_H
+#define EXLOGINWIDGET_H
+
+#include <QWidget>
+
+class LineEdit;
+class PasswordLineEdit;
+class CheckBox;
+class PushButton;
+
+class QVBoxLayout;
+class QLabel;
+class QHBoxLayout;
+
+class EXLoginWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit EXLoginWidget(QWidget *parent = nullptr);
+
+    void paintEvent(QPaintEvent *event) override;
+
+    void setTitle(const QString title);
+
+    const QString account() const;
+    const QString password() const;
+    bool rememberPassword() const;
+
+    void saveAccountConfig() const;
+
+private:
+    void initialize();
+    void initLayout();
+    void connectSignalsAndSlots();
+
+    void loadAccount();
+
+signals:
+    void signalLogin();
+    void signalCancel();
+
+private:
+    QVBoxLayout *m_vBoxLayout = nullptr;
+
+    QLabel *m_titleLabel           = nullptr;
+    LineEdit *m_accLineEdit        = nullptr;
+    PasswordLineEdit *m_pwLineEdit = nullptr;
+
+    QHBoxLayout *m_remLayout = nullptr;
+    CheckBox *m_remCheckBox  = nullptr;
+
+    QHBoxLayout *m_buttonLayout = nullptr;
+    PushButton *m_loginButton   = nullptr;
+    PushButton *m_cancelButton  = nullptr;
+
+    QLabel *m_adminTips = nullptr;
+};
+
+#endif  // EXLOGINWIDGET_H

+ 4 - 0
ExpertClient/ExpertClient.pro

@@ -60,11 +60,13 @@ VERSION = "2.1.2.1"
 
 
 SOURCES += \
+    EXConfig.cpp \
     EXDataTableView.cpp \
     EXDataView.cpp \
     EXDataViewDelegate.cpp \
     EXEvalView.cpp \
     EXIndexView.cpp \
+    EXLoginWidget.cpp \
     EXProjectView.cpp \
     MainWindow.cpp \
     ProjectManager.cpp \
@@ -75,11 +77,13 @@ FORMS += \
     MainWindow.ui
 
 HEADERS += \
+    EXConfig.h \
     EXDataTableView.h \
     EXDataView.h \
     EXDataViewDelegate.h \
     EXEvalView.h \
     EXIndexView.h \
+    EXLoginWidget.h \
     EXProjectView.h \
     MainWindow.h \
     ProjectManager.h \

+ 1 - 1
ExpertClient/MainWindow.cpp

@@ -23,7 +23,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
         return;
     }
     ProjectInfo *proj = new ProjectInfo();
-    ret               = ProjectService().QueryProjectById(proj, 110);
+    ret               = ProjectService().QueryProjectById(proj, 121);
     if (!ret) {
         return;
     }

+ 3 - 1
ExpertClient/main.cpp

@@ -7,6 +7,7 @@
 
 #include "../../helper/GenerateMiniDump.h"
 
+#include "EXLoginWidget.h"
 #include "MainWindow.h"
 
 int main(int argc, char *argv[])
@@ -43,7 +44,8 @@ int main(int argc, char *argv[])
     QIcon icon = QIcon(":/resource/logo.png");
     a.setWindowIcon(icon);
 
-    MainWindow w;
+    EXLoginWidget w;
+
     // 居中显示窗体
     w.move((QApplication::primaryScreen()->availableGeometry().width() - w.width()) / 2,
            (QApplication::primaryScreen()->availableGeometry().height() - w.height()) / 2);

+ 2 - 2
QFD/widgets/ConfigMeasureDataWidget.cpp

@@ -32,8 +32,8 @@ void ConfigMeasureDataWidget::initWidget()
     m_tipsLabel = new QLabel("已导入的数据将会显示在这里", this);
     m_tipsLabel->setObjectName("tipsLabel");
     m_tipsLabel->setHidden(true);
-    m_addButton = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", this);
-    m_addButton->setToolTip("导入数据");
+    m_addButton = new QPushButton(NEWFLICON(FluentIcon, ADD)->icon(), "", this);
+    m_addButton->setToolTip("添加数据");
     m_listWidget = new QListWidget(this);
 
     setStyleSheet("#titleLabel {color:#333333; font-size:16px}"

+ 1 - 1
QFD/widgets/ConfigSchemeDataWidget.cpp

@@ -32,7 +32,7 @@ void ConfigSchemeDataWidget::initWidget()
     m_tipsLabel = new QLabel("已导入的数据将会显示在这里", this);
     m_tipsLabel->setObjectName("tipsLabel");
     m_tipsLabel->setHidden(true);
-    m_addButton = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", this);
+    m_addButton = new QPushButton(NEWFLICON(FluentIcon, ADD)->icon(), "", this);
     m_addButton->setToolTip("添加方案");
     m_listWidget = new QListWidget(this);
 

+ 9 - 11
QFD/widgets/DataCollectionWidget.cpp

@@ -120,15 +120,13 @@ void DataCollectionWidget::setupTabWidget()
 
                 DataTableWidget *table = new DataTableWidget(importEffiEvalDataProcess, this);
                 table->mind1()->setNodeList(nodeListMap[i]);
-                table->setupModels();
+                //                table->setupModels();
                 m_tab->addTab(table, indexName + " - " + "收集效能评估数据");
             }
 
             // 导入效能评估的权重分析数据
             // 导入其他评估的权重分析数据和评估数据
 
-            qDebug() << __FUNCTION__ << __LINE__ << process.indexType << process.type << process.dSource << endl;
-
             if (process.dSource >= 0) {
                 if (process.type == SchemePlanManager::ImportEvalData
                     && process.indexType == ProjectManager::EfficiencyIndex) {
@@ -141,7 +139,7 @@ void DataCollectionWidget::setupTabWidget()
                 if (i == ProjectManager::TechIndex) {
                     table->mind2()->setNodeList(nodeListMap[ProjectManager::AbilityIndex]);
                 }
-                table->setupModels();
+                //                table->setupModels();
 
                 QString processName = SchemePlanManager::processName(process);
                 m_tab->addTab(table, indexName + " - " + processName);
@@ -322,14 +320,14 @@ void DataCollectionWidget::slotConfigSelected(UserConfig *config)
     DataTableWidget *table = (DataTableWidget *)m_tab->currentWidget();
     QString indexName      = ProjectManager::nameOfIndexType((ProjectManager::IndexType)table->process().indexType);
 
-    MindEvaluation *eval =
-            new MindEvaluation(table->mind1(), MindEvaluation::NoMerge, indexName, table->process().dSource);
-    eval->updateSeqNodes();
-    eval->computeWeights();
+    //    MindEvaluation *eval =
+    //            new MindEvaluation(table->mind1(), MindEvaluation::NoMerge, indexName, table->process().dSource);
+    //    eval->updateSeqNodes();
+    //    eval->computeWeights();
 
-    for (MindNodeItem item : eval->mindNodeWeights) {
-        qDebug() << __FUNCTION__ << __LINE__ << item.name << item.value << item.score << endl;
-    }
+    //    for (MindNodeItem item : eval->mindNodeWeights) {
+    //        qDebug() << __FUNCTION__ << __LINE__ << item.name << item.value << item.score << endl;
+    //    }
 
     QList<NodeMatrixInfo *> data;
     NodeMatrixService().QueryNodeMatrixListByExpertIdAndEngineerId(&data, config->userId, config->engineerId,