EXDataView.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include "EXDataView.h"
  2. #include "EXDataTableView.h"
  3. #include "dbService/SchemeProcessService.h"
  4. #include "dbService/ClassSet.h"
  5. #include "dbService/CNodeDataService.h"
  6. #include "dbService/NodeMatrixService.h"
  7. #include <CNode.h>
  8. #include <Widgets/Button.h>
  9. #include <QTabWidget>
  10. #include <QBoxLayout>
  11. #include <QMap>
  12. #include <QFileDialog>
  13. #include <QDebug>
  14. EXDataView::EXDataView(ProjectInfo *proj, QWidget *parent) : EXEvalView(proj, parent)
  15. {
  16. setTitle("数据采集");
  17. connect(m_tab, &QTabWidget::currentChanged, this, &EXDataView::slotTabCurrentChanged);
  18. }
  19. void EXDataView::setType(int type)
  20. {
  21. EXEvalView::setType(type);
  22. setupTabWidget();
  23. }
  24. ///
  25. /// \brief EXDataView::setupTabWidget
  26. /// 根据评估类型, 评估方案, 评估算法, 加载合适的数据导入界面
  27. void EXDataView::setupTabWidget()
  28. {
  29. m_tab->clear();
  30. QMap<int, QList<CNodeData>> nodeListMap;
  31. for (int i : indexList()) {
  32. // 获取指标体系数据
  33. QList<CNodeData> nodeList;
  34. bool ret = CNodeDataService().QueryAllValid(nodeList, m_proj->id, i);
  35. if (ret) {
  36. nodeListMap[i] = nodeList;
  37. } else {
  38. return;
  39. }
  40. // 获取方案规划数据
  41. QList<SchemePlanManager::SchemeProcessInfo> processList;
  42. ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, i);
  43. if (ret == false) {
  44. return;
  45. }
  46. ProjectManager::IndexType t = (ProjectManager::IndexType)i;
  47. QString indexName = ProjectManager::nameOfIndexType(t);
  48. for (SchemePlanManager::SchemeProcessInfo process : processList) {
  49. // 导入效能评估的权重分析数据
  50. // 导入其他评估的权重分析数据和评估数据
  51. if (process.dSource == SchemePlanManager::FromExpert) {
  52. if (process.type == SchemePlanManager::ImportEvalData
  53. && process.indexType != ProjectManager::TechIndex) {
  54. continue;
  55. }
  56. EXDataTableView *table = new EXDataTableView(process, this);
  57. table->setProjectInfo(m_proj);
  58. table->mind1()->setNodeList(nodeListMap[i]);
  59. if (i == ProjectManager::TechIndex) {
  60. table->mind2()->setNodeList(nodeListMap[ProjectManager::AbilityIndex]);
  61. }
  62. table->setupModels();
  63. QString processName = SchemePlanManager::processName(process);
  64. m_tab->addTab(table, indexName + " - " + processName);
  65. connect(table, &EXDataTableView::signalItemEdited, this, &EXDataView::slotDataEdited);
  66. }
  67. }
  68. }
  69. }
  70. bool EXDataView::checkDataComplete()
  71. {
  72. for (int i = 0; i < m_tab->count(); ++i) {
  73. EXDataTableView *table = (EXDataTableView *)m_tab->widget(i);
  74. if (table->checkDataComplete() == false) {
  75. return false;
  76. }
  77. }
  78. return true;
  79. }
  80. void EXDataView::slotTabCurrentChanged(int index)
  81. {
  82. if (index < 0) {
  83. return;
  84. }
  85. bool complete = checkDataComplete();
  86. emit signalCompleteStateChanged(complete);
  87. }
  88. void EXDataView::slotExportData()
  89. {
  90. // 文件夹路径
  91. QFileDialog::Options options;
  92. options |= QFileDialog::DontUseNativeDialog;
  93. QString filePath = QFileDialog::getExistingDirectory(nullptr, "导出资源包", "/", options);
  94. if (filePath.isEmpty()) {
  95. qDebug() << "--empty";
  96. return;
  97. }
  98. for (int i = 0; i < m_tab->count(); i++) {
  99. EXDataTableView *table = (EXDataTableView *)m_tab->widget(i);
  100. SchemePlanManager::SchemeProcessInfo process = table->process();
  101. qDebug() << __FUNCTION__ << __LINE__ << "导出"
  102. << ProjectManager::nameOfIndexType((ProjectManager::IndexType)process.indexType) << endl;
  103. table->exportData(filePath);
  104. }
  105. }
  106. void EXDataView::slotDataEdited()
  107. {
  108. bool complete = checkDataComplete();
  109. emit signalCompleteStateChanged(complete);
  110. }