Browse Source

设置指标体系和方案规划的可编辑状态

chengxr 1 year ago
parent
commit
f578875ea4

+ 5 - 0
QFD/CCanvas/CMindView.cpp

@@ -274,6 +274,11 @@ void CMindView::setAllowEdit(bool allow)
     m_allowEdit = allow;
 }
 
+bool CMindView::allowEdit() const
+{
+    return m_allowEdit;
+}
+
 void CMindView::slotEditNode(CNodeData n)
 {
     emit sigEditNode(n);

+ 2 - 0
QFD/CCanvas/CMindView.h

@@ -52,6 +52,8 @@ public:
 
     void setAllowEdit(bool allow);
 
+    bool allowEdit() const;
+
 public slots:
 
     void slotEditNode(CNodeData n);

+ 45 - 0
QFD/dbService/NodeMatrixService.cpp

@@ -639,3 +639,48 @@ bool NodeMatrixService::UpdateMeasureData(const NodeMatrixInfo &info)
     }
     return ret;
 }
+
+bool NodeMatrixService::hasMeasureData(int projId, QString index)
+{
+    QSqlDatabase db = SqlDBHelper::getDatabase();
+    QSqlQuery query(db);
+    bool ret          = false;
+    QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
+                                "node_value, expert_id,mind_id,write_date,mark,str_uuid,table_msg from "
+                                "t_node_matrix_info where mind_id = 1 and engineer_id ='%1' and table_msg ='%2'")
+                                .arg(QString::number(projId))
+                                .arg(index);
+    // qDebug() << "selectSql=" << selectSql;
+    if (query.exec(selectSql)) {
+        if (query.next()) {
+
+            ret = true;
+        }
+    } else {
+        qDebug() << query.lastError();
+    }
+    return ret;
+}
+
+bool NodeMatrixService::hasExpertData(int projId, QString index, int expertId)
+{
+    QSqlDatabase db = SqlDBHelper::getDatabase();
+    QSqlQuery query(db);
+    bool ret          = false;
+    QString selectSql = QString("select id,expert_name, engineer_id, node, abscissa, ordinate, "
+                                "node_value, expert_id,mind_id,write_date,mark,str_uuid,table_msg from "
+                                "t_node_matrix_info where expert_id = '%1' and engineer_id ='%2' and table_msg ='%3'")
+                                .arg(QString::number(expertId))
+                                .arg(QString::number(projId))
+                                .arg(index);
+    // qDebug() << "selectSql=" << selectSql;
+    if (query.exec(selectSql)) {
+        if (query.next()) {
+
+            ret = true;
+        }
+    } else {
+        qDebug() << query.lastError();
+    }
+    return ret;
+}

+ 4 - 0
QFD/dbService/NodeMatrixService.h

@@ -70,6 +70,10 @@ public:
 
     /*修改节点值*/
     bool UpdateMeasureData(const NodeMatrixInfo &info);
+
+    /*查询是否已录入数据*/
+    bool hasMeasureData(int projId, QString index);
+    bool hasExpertData(int projId, QString index, int expertId);
 };
 
 #endif  // NODEMATRIXSERVICE_H

+ 9 - 0
QFD/shemeFlow/FlowGraphNodeWidget.cpp

@@ -124,6 +124,15 @@ bool FlowGraphCommonNodeWidget::isTitleHidden() const
     return (algs.count() > 0 || dsrc.count() > 0 || opt);
 }
 
+void FlowGraphCommonNodeWidget::setAllowEdit(bool allow)
+{
+    m_allowEdit = allow;
+    m_algCombo->setEnabled(allow);
+    m_dataCombo->setEnabled(allow);
+    m_spinBox->setEnabled(allow);
+    m_checkBox->setEnabled(allow);
+}
+
 void FlowGraphCommonNodeWidget::initWidget()
 {
     setFixedWidth(300);

+ 4 - 0
QFD/shemeFlow/FlowGraphNodeWidget.h

@@ -97,6 +97,8 @@ public:
 
     bool isTitleHidden() const;
 
+    void setAllowEdit(bool allow);
+
 signals:
     void sigProcessEdited(SchemePlanManager::SchemeProcessInfo process);
 
@@ -130,6 +132,8 @@ private:
     QVBoxLayout *m_layout = nullptr;
 
     bool m_isLoaded = false;
+
+    bool m_allowEdit = true;
 };
 
 #endif  // FLOWGRAPHNODEWIDGET_H

+ 34 - 1
QFD/widgets/IndexSystemWidget.cpp

@@ -4,6 +4,8 @@
 
 #include <dbService/ClassSet.h>
 #include <dbService/CNodeDataService.h>
+#include <dbService/NodeMatrixService.h>
+#include <dbService/UserConfigService.h>
 
 #include <CMindView.h>
 #include <CMind.h>
@@ -100,9 +102,40 @@ void IndexSystemWidget::addNode(CNodeData node)
     }
 }
 
+bool IndexSystemWidget::hasData(QString indexName) const
+{
+    bool ret = NodeMatrixService().hasMeasureData(m_proj->id, indexName);
+
+    if (ret == true) {
+        return true;
+    }
+
+    QList<UserConfig *> cfgList;
+    ret = UserConfigService().QueryUserConfigListInfoByEngineerId(&cfgList, m_proj->id);
+    if (ret == false) {
+        return false;
+    }
+
+    for (UserConfig *cfg : cfgList) {
+        ret = NodeMatrixService().hasExpertData(m_proj->id, indexName, cfg->userId);
+        if (ret) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void IndexSystemWidget::slotTabCurrentChanged(int c)
 {
-    Q_UNUSED(c)
+    bool ret     = hasData(m_tab->tabText(c));
+    CMindView *m = (CMindView *)m_tab->currentWidget();
+
+    if (m != nullptr) {
+        m->setAllowEdit(!ret);
+        QList<CNodeData> list = m->mind()->nodeList();
+        m->setNodeList(list);
+    }
 }
 
 void IndexSystemWidget::slotSelectAllNodes() { }

+ 2 - 0
QFD/widgets/IndexSystemWidget.h

@@ -32,6 +32,8 @@ private:
 
     void addNode(CNodeData node);
 
+    bool hasData(QString indexName) const;
+
 signals:
 
 public slots:

+ 11 - 0
QFD/widgets/SchemeFlowWidget.cpp

@@ -132,6 +132,7 @@ void SchemeFlowWidget::loadSchemes(const QList<SchemePlanManager::SchemeProcessI
         NodeId id = m_graphModel->addNode(FlowCommonData().type().id);
         m_graphModel->setNodeData(id, NodeRole::Position, QPointF(0, y));
         FlowGraphCommonNodeWidget *w = new FlowGraphCommonNodeWidget();
+        w->setAllowEdit(m_allowEdit);
         connect(w, &FlowGraphCommonNodeWidget::sigProcessEdited, this, &SchemeFlowWidget::slotSchemeProcessEdited);
 
         w->setProcess(process);
@@ -150,6 +151,16 @@ void SchemeFlowWidget::loadSchemes(const QList<SchemePlanManager::SchemeProcessI
     }
 }
 
+void SchemeFlowWidget::setAllowEdit(bool allow)
+{
+    m_allowEdit = allow;
+    for (int id : m_graphModel->allNodeIds()) {
+        FlowGraphCommonNodeWidget *w =
+                m_graphModel->nodeData(id, NodeRole::Widget).value<FlowGraphCommonNodeWidget *>();
+        w->setAllowEdit(allow);
+    }
+}
+
 void SchemeFlowWidget::initWidget()
 {
     m_graphModel = new DataFlowModel(registerDataModels());

+ 4 - 0
QFD/widgets/SchemeFlowWidget.h

@@ -49,6 +49,8 @@ public:
 
     void loadSchemes(const QList<SchemePlanManager::SchemeProcessInfo> &schems);
 
+    void setAllowEdit(bool allow);
+
 signals:
     void sigSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process);
 
@@ -64,6 +66,8 @@ private:
     DataFlowModel *m_graphModel = nullptr;
 
     QHBoxLayout *m_layout = nullptr;
+
+    bool m_allowEdit = true;
 };
 
 #endif  // SCHEMEFLOWWIDGET_H

+ 38 - 0
QFD/widgets/SchemePlanWidget.cpp

@@ -5,6 +5,8 @@
 
 #include <dbService/ClassSet.h>
 #include <dbService/SchemeProcessService.h>
+#include <dbService/NodeMatrixService.h>
+#include <dbService/UserConfigService.h>
 
 #include <CSchemeView.h>
 
@@ -43,6 +45,7 @@ void SchemePlanWidget::setupUI()
     //    m_contentLayout->addWidget(m_description);
 
     connect(m_export, &PushButton::clicked, this, &SchemePlanWidget::slotExportClicked);
+    connect(m_tab, &QTabWidget::currentChanged, this, &SchemePlanWidget::slotTabCurrentChanged);
 }
 
 QList<SchemePlanManager::SchemeProcessInfo> SchemePlanWidget::templateSchemes(int projId, int indexType)
@@ -101,6 +104,7 @@ void SchemePlanWidget::setupTabWidget()
 
     for (int i : indexList()) {
         SchemeFlowWidget *m = new SchemeFlowWidget(this);
+
         connect(m, &SchemeFlowWidget::sigSchemeProcessEdited, this, &SchemePlanWidget::slotSchemeProcessEdited);
 
         QList<SchemePlanManager::SchemeProcessInfo> schemes;
@@ -118,6 +122,30 @@ void SchemePlanWidget::setupTabWidget()
     }
 }
 
+bool SchemePlanWidget::hasData(QString indexName) const
+{
+    bool ret = NodeMatrixService().hasMeasureData(m_proj->id, indexName);
+
+    if (ret == true) {
+        return true;
+    }
+
+    QList<UserConfig *> cfgList;
+    ret = UserConfigService().QueryUserConfigListInfoByEngineerId(&cfgList, m_proj->id);
+    if (ret == false) {
+        return false;
+    }
+
+    for (UserConfig *cfg : cfgList) {
+        ret = NodeMatrixService().hasExpertData(m_proj->id, indexName, cfg->userId);
+        if (ret) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void SchemePlanWidget::slotExportClicked()
 {
 
@@ -132,3 +160,13 @@ void SchemePlanWidget::slotSchemeProcessEdited(const SchemePlanManager::SchemePr
     qDebug() << __FUNCTION__ << __LINE__ << process.algorithm << endl;
     SchemeProcessService().UpdateSchemeProcess(process);
 }
+
+void SchemePlanWidget::slotTabCurrentChanged(int c)
+{
+    bool ret            = hasData(m_tab->tabText(c));
+    SchemeFlowWidget *m = (SchemeFlowWidget *)m_tab->currentWidget();
+
+    if (m != nullptr) {
+        m->setAllowEdit(!ret);
+    }
+}

+ 4 - 0
QFD/widgets/SchemePlanWidget.h

@@ -30,11 +30,15 @@ public:
 private:
     void setupTabWidget();
 
+    bool hasData(QString indexName) const;
+
 private slots:
     void slotExportClicked();
 
     void slotSchemeProcessEdited(const SchemePlanManager::SchemeProcessInfo &process);
 
+    void slotTabCurrentChanged(int c);
+
 private:
     PushButton *m_export = nullptr;