123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include "EXDataView.h"
- #include "EXDataTableView.h"
- #include "dbService/SchemeProcessService.h"
- #include "dbService/ClassSet.h"
- #include "dbService/CNodeDataService.h"
- #include "dbService/NodeMatrixService.h"
- #include <CNode.h>
- #include <Widgets/Button.h>
- #include <QTabWidget>
- #include <QBoxLayout>
- #include <QMap>
- #include <QFileDialog>
- #include <QDebug>
- EXDataView::EXDataView(ProjectInfo *proj, QWidget *parent) : EXEvalView(proj, parent)
- {
- setTitle("数据采集");
- connect(m_tab, &QTabWidget::currentChanged, this, &EXDataView::slotTabCurrentChanged);
- }
- void EXDataView::setType(int type)
- {
- EXEvalView::setType(type);
- setupTabWidget();
- }
- ///
- /// \brief EXDataView::setupTabWidget
- /// 根据评估类型, 评估方案, 评估算法, 加载合适的数据导入界面
- void EXDataView::setupTabWidget()
- {
- m_tab->clear();
- QMap<int, QList<CNodeData>> nodeListMap;
- for (int i : indexList()) {
- // 获取指标体系数据
- QList<CNodeData> nodeList;
- bool ret = CNodeDataService().QueryAllValid(nodeList, m_proj->id, i);
- if (ret) {
- nodeListMap[i] = nodeList;
- } else {
- return;
- }
- // 获取方案规划数据
- QList<SchemePlanManager::SchemeProcessInfo> processList;
- ret = SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, i);
- if (ret == false) {
- return;
- }
- ProjectManager::IndexType t = (ProjectManager::IndexType)i;
- QString indexName = ProjectManager::nameOfIndexType(t);
- for (SchemePlanManager::SchemeProcessInfo process : processList) {
- // 导入效能评估的权重分析数据
- // 导入其他评估的权重分析数据和评估数据
- if (process.dSource == SchemePlanManager::FromExpert) {
- if (process.type == SchemePlanManager::ImportEvalData
- && process.indexType != ProjectManager::TechIndex) {
- continue;
- }
- EXDataTableView *table = new EXDataTableView(process, this);
- table->setProjectInfo(m_proj);
- table->mind1()->setNodeList(nodeListMap[i]);
- if (i == ProjectManager::TechIndex) {
- table->mind2()->setNodeList(nodeListMap[ProjectManager::AbilityIndex]);
- }
- table->setupModels();
- QString processName = SchemePlanManager::processName(process);
- m_tab->addTab(table, indexName + " - " + processName);
- connect(table, &EXDataTableView::signalItemEdited, this, &EXDataView::slotDataEdited);
- }
- }
- }
- }
- bool EXDataView::checkDataComplete()
- {
- for (int i = 0; i < m_tab->count(); ++i) {
- EXDataTableView *table = (EXDataTableView *)m_tab->widget(i);
- if (table->checkDataComplete() == false) {
- return false;
- }
- }
- return true;
- }
- void EXDataView::slotTabCurrentChanged(int index)
- {
- if (index < 0) {
- return;
- }
- bool complete = checkDataComplete();
- emit signalCompleteStateChanged(complete);
- }
- void EXDataView::slotExportData()
- {
- // 文件夹路径
- QFileDialog::Options options;
- options |= QFileDialog::DontUseNativeDialog;
- QString filePath = QFileDialog::getExistingDirectory(nullptr, "导出资源包", "/", options);
- if (filePath.isEmpty()) {
- qDebug() << "--empty";
- return;
- }
- for (int i = 0; i < m_tab->count(); i++) {
- EXDataTableView *table = (EXDataTableView *)m_tab->widget(i);
- SchemePlanManager::SchemeProcessInfo process = table->process();
- qDebug() << __FUNCTION__ << __LINE__ << "导出"
- << ProjectManager::nameOfIndexType((ProjectManager::IndexType)process.indexType) << endl;
- table->exportData(filePath);
- }
- }
- void EXDataView::slotDataEdited()
- {
- bool complete = checkDataComplete();
- emit signalCompleteStateChanged(complete);
- }
|