Browse Source

保存方案数据

chengxr 1 year ago
parent
commit
8ca6234c55

+ 7 - 0
QFD/widgets/CreateSchemeWidget.cpp

@@ -25,6 +25,12 @@ void CreateSchemeWidget::clearInputs()
     m_picLine->clear();
 }
 
+void CreateSchemeWidget::showEvent(QShowEvent *e)
+{
+    QDialog::showEvent(e);
+    clearInputs();
+}
+
 void CreateSchemeWidget::initWindow()
 {
     setWindowTitle("新建方案");
@@ -45,6 +51,7 @@ void CreateSchemeWidget::initialize()
     m_schemeLabel = new QLabel("方案描述:", this);
     m_schemeLabel->setFixedHeight(35);
     m_schemeEdit = new TextEdit(this);
+    m_schemeEdit->setObjectName("textEdit");
     m_schemeEdit->setFixedWidth(250);
     m_schemeEdit->setFixedHeight(150);
     m_picButton = new PushButton("方案图片", this);

+ 2 - 0
QFD/widgets/CreateSchemeWidget.h

@@ -23,6 +23,8 @@ public:
     void clearInputs();
 
 private:
+    void showEvent(QShowEvent *e) override;
+
     void initWindow();
     void initialize();
     void initLayout();

+ 57 - 27
QFD/widgets/DataTableWidget.cpp

@@ -135,18 +135,19 @@ void DataTableWidget::setupModels()
 
             hIndex += hHeaders.size();
 
-            QList<SchemaEval *> schemeList;
+            m_schemeList.clear();
             if (m_process.indexType == ProjectManager::EfficiencyIndex) {
-                SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_process.projectId, 1);
+                SchemeInfoService().QuerySchemeInfoByEngineerId(&m_schemeList, m_process.projectId, 1);
             }
             if (m_process.indexType == ProjectManager::OptimalIndex) {
-                SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_process.projectId, 0);
+                SchemeInfoService().QuerySchemeInfoByEngineerId(&m_schemeList, m_process.projectId, 0);
             }
 
-            if (schemeList.count() > 0) {
-                for (SchemaEval *scheme : schemeList) {
+            if (m_schemeList.count() > 0) {
+                for (SchemaEval *scheme : m_schemeList) {
                     QStandardItem *item = new QStandardItem(scheme->name);
                     model->setHorizontalHeaderItem(++hIndex, item);
+                    m_schemeStartIndex = hIndex;
                     for (QString indexValue : scheme->valueStr.split(";")) {
                         QStringList indexAndValue = indexValue.split(":");
                         if (indexAndValue.size() < 2) {
@@ -156,6 +157,7 @@ void DataTableWidget::setupModels()
                             QStandardItem *hHeader = model->verticalHeaderItem(l);
                             if (hHeader->text() == indexAndValue.first()) {
                                 QStandardItem *item = new QStandardItem(indexAndValue.last());
+                                item->setData(indexAndValue.last());
                                 model->setItem(l, hIndex, item);
                             }
                         }
@@ -444,6 +446,7 @@ void DataTableWidget::setNodeMatrixData(QList<NodeMatrixInfo *> data, bool isExp
                 for (int c = 0; c < model->columnCount(); c++) {
                     QStandardItem *item = model->item(r, c);
                     if (item != nullptr) {
+                        item->setData("");
                         item->setText("");
                     }
                 }
@@ -489,6 +492,7 @@ void DataTableWidget::setNodeMatrixData(QList<NodeMatrixInfo *> data, bool isExp
                             if (cHeader->text() == info->abscissa) {
                                 QStandardItem *item = new QStandardItem();
                                 item->setText(info->nodeValue);
+                                item->setData(info->nodeValue);
                                 model->setItem(0, c, item);
                             }
                         }
@@ -511,6 +515,7 @@ void DataTableWidget::setNodeMatrixData(QList<NodeMatrixInfo *> data, bool isExp
                             if (cHeader->text() == info->abscissa && rHeader->text() == info->ordinate) {
                                 QStandardItem *item = new QStandardItem();
                                 item->setText(info->nodeValue);
+                                item->setData(info->nodeValue);
                                 model->setItem(r, c, item);
                             }
                         }
@@ -602,35 +607,60 @@ void DataTableWidget::itemChanged(QStandardItem *item)
         return;
     }
 
-    // 只关心用户编辑实测数据
+    static bool useOldData = false;
+    if (useOldData) {
+        useOldData = false;
+        return;
+    }
+
+    // ([0-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])
+    // (-?[1-9][0-9]+)|(-?[0-9])|(-?[1-9]\\d+\\.\\d+)|(-?[0-9]\\.\\d+)
+    QString Pattern("(\\d*\\.?\\d*)");  // 匹配非负数
+    QRegExp reg(Pattern);
+    if (!reg.exactMatch(item->text())) {
+        useOldData = true;
+        item->setText(item->data().toString());
+        return;
+    } else {
+        if (item->data().toString() != item->text()) {
+            item->setData(item->text());
+            return;
+        }
+    }
+
+    // 用户编辑实测数据, 包括权重数据和能力重要度评估数据
     bool weightData = m_process.type == SchemePlanManager::ImportWeightData
             && m_process.dSource == SchemePlanManager::FromMeasurement;
     bool evalData = m_process.type == SchemePlanManager::ImportEvalData
             && m_process.dSource == SchemePlanManager::FromMeasurement
             && m_process.indexType == ProjectManager::TechIndex;
 
-    if (!weightData && !evalData) {
-        return;
-    }
-
-    QString indexName = ProjectManager::nameOfIndexType((ProjectManager::IndexType)m_process.indexType);
-    NodeMatrixInfo info;
-    info.nodeValue  = item->text();
-    info.engineerId = m_process.projectId;
-    info.tableMsg   = indexName;
-    info.strUuid    = m_uuidStr;
-
-    QStandardItem *hHeader = item->model()->horizontalHeaderItem(item->column());
-    info.abscissa          = hHeader->text();
+    // 用户编辑方案数据, 包括方案优选评估数据和效能评估数据
+    bool schemeData = m_process.type == SchemePlanManager::ImportEvalData
+            && (m_process.indexType == ProjectManager::OptimalIndex
+                || m_process.indexType == ProjectManager::EfficiencyIndex);
+
+    if (weightData || evalData) {
+        QString indexName = ProjectManager::nameOfIndexType((ProjectManager::IndexType)m_process.indexType);
+        NodeMatrixInfo info;
+        info.nodeValue  = item->text();
+        info.engineerId = m_process.projectId;
+        info.tableMsg   = indexName;
+        info.strUuid    = m_uuidStr;
+
+        QStandardItem *hHeader = item->model()->horizontalHeaderItem(item->column());
+        info.abscissa          = hHeader->text();
+
+        if (evalData) {
+            QStandardItem *vHeader = item->model()->verticalHeaderItem(item->row());
+            info.ordinate          = vHeader->text();
+        }
 
-    if (evalData) {
-        QStandardItem *vHeader = item->model()->verticalHeaderItem(item->row());
-        info.ordinate          = vHeader->text();
+        bool ret = NodeMatrixService().UpdateMeasureData(info);
+        if (ret) {
+            emit sigMeasureDataEdited(&info);
+        }
     }
 
-    bool ret = NodeMatrixService().UpdateMeasureData(info);
-    qDebug() << __FUNCTION__ << __LINE__ << ret << endl;
-    if (ret) {
-        emit sigMeasureDataEdited(&info);
-    }
+    if (schemeData) { }
 }

+ 3 - 0
QFD/widgets/DataTableWidget.h

@@ -114,6 +114,9 @@ private:
     QString m_uuidStr;
 
     bool m_isFillingData = false;
+
+    int m_schemeStartIndex = -1;
+    QList<SchemaEval *> m_schemeList;
 };
 
 #endif  // DATATABLEWIDGET_H