浏览代码

Merge branch 'master' of ssh://101.43.129.26:10022/chengxr/QFD2

codeClown 1 年之前
父节点
当前提交
5807b1b8ad
共有 6 个文件被更改,包括 447 次插入29 次删除
  1. 37 8
      ExpertClient/EXLoginWidget.cpp
  2. 4 0
      ExpertClient/EXLoginWidget.h
  3. 369 0
      ExpertClient/Login.ui
  4. 10 10
      ExpertClient/MainWindow.cpp
  5. 8 4
      ExpertClient/MainWindow.h
  6. 19 7
      ExpertClient/main.cpp

+ 37 - 8
ExpertClient/EXLoginWidget.cpp

@@ -11,6 +11,8 @@
 #include <QBoxLayout>
 #include <QLabel>
 #include <QPainter>
+#include <QDebug>
+#include "MainWindow.h"
 
 EXLoginWidget::EXLoginWidget(QWidget *parent) : QWidget(parent)
 {
@@ -126,8 +128,8 @@ void EXLoginWidget::initLayout()
 
 void EXLoginWidget::connectSignalsAndSlots()
 {
-    connect(m_loginButton, &PushButton::clicked, this, &EXLoginWidget::signalLogin);
-    connect(m_cancelButton, &PushButton::clicked, this, &EXLoginWidget::signalCancel);
+    connect(m_loginButton, &PushButton::clicked, this, &EXLoginWidget::slotLogin);
+    connect(m_cancelButton, &PushButton::clicked, this, &EXLoginWidget::slotCancelLogin);
 }
 
 void EXLoginWidget::loadAccount()
@@ -139,12 +141,39 @@ void EXLoginWidget::loadAccount()
         setTitle("专家登录");
     }
 
-    bool rem = EXConfig::rememberPassword();
-    m_remCheckBox->setChecked(rem);
-    if (rem) {
-        m_accLineEdit->setText(EXConfig::username());
-        m_pwLineEdit->setText(EXConfig::password());
-    }
+    //    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());
 }
+
+void EXLoginWidget::slotCancelLogin()
+{
+    exit(0);
+}
+
+void EXLoginWidget::slotLogin()
+{
+
+    QString account  = m_accLineEdit->text();
+    QString password = m_pwLineEdit->text();
+    QFUser user(account, account);
+
+    int code = user.login();
+
+    qDebug() << __FUNCTION__ << __LINE__ << "login code:" << account << password << code;
+
+    if ((code == QF_CODE_SUCCEEDED || code == QF_CODE_ALREADY_LOGIN) && QFUser::currentUser() != nullptr) {
+        MainWindow *m = new MainWindow(user.projectId.toInt(), this);
+
+        m->show();
+        // this->close();
+    } else {
+        qDebug() << "-----------失败";
+        // QFDAlert::showAlertWithCode(code, this);
+    }
+}

+ 4 - 0
ExpertClient/EXLoginWidget.h

@@ -39,6 +39,10 @@ signals:
     void signalLogin();
     void signalCancel();
 
+private slots:
+    void slotLogin();
+    void slotCancelLogin();
+
 private:
     QVBoxLayout *m_vBoxLayout = nullptr;
 

+ 369 - 0
ExpertClient/Login.ui

@@ -0,0 +1,369 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Login</class>
+ <widget class="QDialog" name="Login">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>591</width>
+    <height>361</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">background-image: url(:/res/background/login.jpg);</string>
+  </property>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>10</y>
+     <width>561</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="font">
+    <font>
+     <pointsize>20</pointsize>
+    </font>
+   </property>
+   <property name="layoutDirection">
+    <enum>Qt::LeftToRight</enum>
+   </property>
+   <property name="styleSheet">
+    <string notr="true">background:transparent;
+color: rgb(255, 255, 255);</string>
+   </property>
+   <property name="text">
+    <string>技术模型与数据处理软件</string>
+   </property>
+   <property name="alignment">
+    <set>Qt::AlignCenter</set>
+   </property>
+  </widget>
+  <widget class="QStackedWidget" name="stackedWidget">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>80</y>
+     <width>301</width>
+     <height>271</height>
+    </rect>
+   </property>
+   <property name="styleSheet">
+    <string notr="true">background:transparent;</string>
+   </property>
+   <property name="currentIndex">
+    <number>1</number>
+   </property>
+   <widget class="QWidget" name="page1">
+    <widget class="QLineEdit" name="usernameEdit">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>60</y>
+       <width>211</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color:white;</string>
+     </property>
+     <property name="text">
+      <string notr="true"/>
+     </property>
+     <property name="placeholderText">
+      <string notr="true">账号</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>10</y>
+       <width>191</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>15</pointsize>
+      </font>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">color: rgb(255, 255, 255);
+background:transparent;</string>
+     </property>
+     <property name="text">
+      <string notr="true">登录</string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="passwordEdit">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>110</y>
+       <width>211</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color:white;</string>
+     </property>
+     <property name="placeholderText">
+      <string>密码</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="loginBtn">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>200</y>
+       <width>91</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color: rgb(255, 255, 255);</string>
+     </property>
+     <property name="text">
+      <string notr="true">登 录</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="cancelBtn">
+     <property name="geometry">
+      <rect>
+       <x>150</x>
+       <y>200</y>
+       <width>91</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color: rgb(255, 255, 255);</string>
+     </property>
+     <property name="text">
+      <string notr="true">取 消</string>
+     </property>
+    </widget>
+    <widget class="QCheckBox" name="rememberChb">
+     <property name="enabled">
+      <bool>true</bool>
+     </property>
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>160</y>
+       <width>121</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>11</pointsize>
+      </font>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">color: rgb(255, 255, 255);</string>
+     </property>
+     <property name="text">
+      <string notr="true">记住密码</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+     <property name="tristate">
+      <bool>false</bool>
+     </property>
+    </widget>
+    <widget class="QLabel" name="adminTips">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>240</y>
+       <width>231</width>
+       <height>20</height>
+      </rect>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>8</pointsize>
+      </font>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">color: rgb(255, 255, 255);
+background:transparent;</string>
+     </property>
+     <property name="text">
+      <string notr="true">...</string>
+     </property>
+    </widget>
+   </widget>
+   <widget class="QWidget" name="page2">
+    <widget class="QPushButton" name="confirmBtn">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>220</y>
+       <width>91</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color: rgb(255, 255, 255);</string>
+     </property>
+     <property name="text">
+      <string notr="true">确定</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_2">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>70</y>
+       <width>191</width>
+       <height>35</height>
+      </rect>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>15</pointsize>
+      </font>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">color: rgb(255, 255, 255);
+background:transparent;</string>
+     </property>
+     <property name="text">
+      <string notr="true">新密码</string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="newPass">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>100</y>
+       <width>211</width>
+       <height>35</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color:white;</string>
+     </property>
+     <property name="text">
+      <string notr="true"/>
+     </property>
+     <property name="placeholderText">
+      <string notr="true">新密码</string>
+     </property>
+    </widget>
+    <widget class="QPushButton" name="cancelBtn2">
+     <property name="geometry">
+      <rect>
+       <x>150</x>
+       <y>220</y>
+       <width>91</width>
+       <height>41</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color: rgb(255, 255, 255);</string>
+     </property>
+     <property name="text">
+      <string notr="true">取 消</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_4">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>140</y>
+       <width>191</width>
+       <height>35</height>
+      </rect>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>15</pointsize>
+      </font>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">color: rgb(255, 255, 255);
+background:transparent;</string>
+     </property>
+     <property name="text">
+      <string notr="true">确认密码</string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="checkPass">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>170</y>
+       <width>211</width>
+       <height>35</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color:white;</string>
+     </property>
+     <property name="text">
+      <string notr="true"/>
+     </property>
+     <property name="placeholderText">
+      <string notr="true">确认密码</string>
+     </property>
+    </widget>
+    <widget class="QLabel" name="label_5">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>0</y>
+       <width>191</width>
+       <height>35</height>
+      </rect>
+     </property>
+     <property name="font">
+      <font>
+       <pointsize>15</pointsize>
+      </font>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">color: rgb(255, 255, 255);
+background:transparent;</string>
+     </property>
+     <property name="text">
+      <string notr="true">新账号</string>
+     </property>
+    </widget>
+    <widget class="QLineEdit" name="newUserName">
+     <property name="geometry">
+      <rect>
+       <x>30</x>
+       <y>30</y>
+       <width>211</width>
+       <height>35</height>
+      </rect>
+     </property>
+     <property name="styleSheet">
+      <string notr="true">background-color:white;</string>
+     </property>
+     <property name="text">
+      <string notr="true"/>
+     </property>
+     <property name="placeholderText">
+      <string notr="true">新账号id</string>
+     </property>
+    </widget>
+   </widget>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 10 - 10
ExpertClient/MainWindow.cpp

@@ -10,24 +10,24 @@
 
 #include <QDebug>
 
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
+MainWindow::MainWindow(int projectId, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
 {
     ui->setupUi(this);
     setWindowTitle("");
 
-    int projId = 110;
+    //    int projId = 110;
+
+    //    QList<UserConfig *> cfgList;
+    //    bool ret = UserConfigService().QueryUserConfigListInfoByEngineerId(&cfgList, projId);
+    //    if (!ret) {
+    //        return;
+    //    }
+    proj    = new ProjectInfo;
+    int ret = ProjectService().QueryProjectById(proj, projectId);
 
-    QList<UserConfig *> cfgList;
-    bool ret = UserConfigService().QueryUserConfigListInfoByEngineerId(&cfgList, projId);
-    if (!ret) {
-        return;
-    }
-    ProjectInfo *proj = new ProjectInfo();
-    ret               = ProjectService().QueryProjectById(proj, 121);
     if (!ret) {
         return;
     }
-
     EXProjectView *projView = new EXProjectView(proj, this);
     setCentralWidget(projView);
 }

+ 8 - 4
ExpertClient/MainWindow.h

@@ -1,8 +1,8 @@
-#ifndef MAINWINDOW_H
+#ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
 #include <QMainWindow>
-
+#include <dbService/ClassSet.h>
 namespace Ui {
 class MainWindow;
 }
@@ -12,11 +12,15 @@ class MainWindow : public QMainWindow
     Q_OBJECT
 
 public:
-    explicit MainWindow(QWidget *parent = nullptr);
+    explicit MainWindow(int projectId, QWidget *parent = nullptr);
     ~MainWindow();
+    void setProjectId(int projectId);
 
 private:
     Ui::MainWindow *ui;
+
+private:
+    ProjectInfo *proj;
 };
 
-#endif // MAINWINDOW_H
+#endif  // MAINWINDOW_H

+ 19 - 7
ExpertClient/main.cpp

@@ -9,6 +9,9 @@
 
 #include "EXLoginWidget.h"
 #include "MainWindow.h"
+#include "FileUtil.h"
+#include "importDataUtil.h"
+#include "EXConfig.h"
 
 int main(int argc, char *argv[])
 {
@@ -44,13 +47,22 @@ int main(int argc, char *argv[])
     QIcon icon = QIcon(":/resource/logo.png");
     a.setWindowIcon(icon);
 
-    EXLoginWidget w;
-
-    // 居中显示窗体
-    w.move((QApplication::primaryScreen()->availableGeometry().width() - w.width()) / 2,
-           (QApplication::primaryScreen()->availableGeometry().height() - w.height()) / 2);
-
-    w.show();
+    int roleType = EXConfig::roleType();
+    if (roleType == QFUser::SuperAdmin) {
+    } else {
+        EXLoginWidget w;
+        // 居中显示窗体
+        w.move((QApplication::primaryScreen()->availableGeometry().width() - w.width()) / 2,
+               (QApplication::primaryScreen()->availableGeometry().height() - w.height()) / 2);
+        bool result = FileUtil().importEngineerFile();
+        if (result) {
+            ImportDataUtil().importSystemData();
+            w.show();
+        } else {
+            qDebug() << "----";
+            qApp->exit();
+        }
+    }
 
     return a.exec();
 }