|
@@ -1,10 +1,13 @@
|
|
#include "projectdialog.h"
|
|
#include "projectdialog.h"
|
|
|
|
|
|
|
|
+#include <QtCore/qlogging.h>
|
|
|
|
+
|
|
#include <QCheckBox>
|
|
#include <QCheckBox>
|
|
#include <QListView>
|
|
#include <QListView>
|
|
#include <QPushButton>
|
|
#include <QPushButton>
|
|
#include <QStandardItemModel>
|
|
#include <QStandardItemModel>
|
|
|
|
|
|
|
|
+#include "../components/MultiSelectComboBox.h"
|
|
#include "ui_projectdialog.h"
|
|
#include "ui_projectdialog.h"
|
|
|
|
|
|
ProjectDialog::ProjectDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ProjectDialog) {
|
|
ProjectDialog::ProjectDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ProjectDialog) {
|
|
@@ -13,80 +16,52 @@ ProjectDialog::ProjectDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Proj
|
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ProjectDialog::clearFormData);
|
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ProjectDialog::clearFormData);
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectDialog::SetComboBoxBlast(const QJsonArray &bapoYuanArray) {
|
|
|
|
- blasterArray = bapoYuanArray;
|
|
|
|
-
|
|
|
|
- // 创建标准项模型用于多选
|
|
|
|
- QStandardItemModel *blastModel = new QStandardItemModel(ui->comboBoxBlast);
|
|
|
|
|
|
+void ProjectDialog::initComboBoxBlaster(const QJsonArray &undergroundOperators) {
|
|
|
|
+ MultiSelectComboBox *comboBox = new MultiSelectComboBox(this);
|
|
|
|
|
|
- for (const QJsonValue &value : bapoYuanArray) {
|
|
|
|
|
|
+ for (const QJsonValue &value : undergroundOperators) {
|
|
if (value.isObject()) {
|
|
if (value.isObject()) {
|
|
QJsonObject obj = value.toObject();
|
|
QJsonObject obj = value.toObject();
|
|
if (obj.contains("nickName")) {
|
|
if (obj.contains("nickName")) {
|
|
QString name = obj["nickName"].toString();
|
|
QString name = obj["nickName"].toString();
|
|
- QStandardItem *item = new QStandardItem(name);
|
|
|
|
- item->setCheckable(true);
|
|
|
|
- item->setData(obj["identity"].toString(), Qt::UserRole);
|
|
|
|
- blastModel->appendRow(item);
|
|
|
|
|
|
+ comboBox->addItem(obj["identity"].toString(), name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- ui->comboBoxBlast->setModel(blastModel);
|
|
|
|
- ui->comboBoxBlast->setView(new QListView(ui->comboBoxBlast));
|
|
|
|
- ui->comboBoxBlast->view()->setMinimumWidth(200);
|
|
|
|
-
|
|
|
|
- // 连接项变更信号
|
|
|
|
- connect(blastModel, &QStandardItemModel::itemChanged, this, &ProjectDialog::onBlasterItemChanged);
|
|
|
|
|
|
+ QVBoxLayout *layout = new QVBoxLayout(ui->undergroundOperatorsWidget);
|
|
|
|
+ layout->addWidget(comboBox);
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectDialog::SetComboBoxOperator(const QJsonArray &anQuanYuanArray) {
|
|
|
|
- operatorArray = anQuanYuanArray;
|
|
|
|
|
|
+void ProjectDialog::initComboBoxSafetyInspectors(const QJsonArray &safeInspectors) {
|
|
|
|
+ MultiSelectComboBox *comboBox = new MultiSelectComboBox(this);
|
|
|
|
|
|
- // 创建标准项模型用于多选
|
|
|
|
- QStandardItemModel *operatorModel = new QStandardItemModel(ui->comboBoxOperator);
|
|
|
|
-
|
|
|
|
- for (const QJsonValue &value : anQuanYuanArray) {
|
|
|
|
|
|
+ for (const QJsonValue &value : safeInspectors) {
|
|
if (value.isObject()) {
|
|
if (value.isObject()) {
|
|
QJsonObject obj = value.toObject();
|
|
QJsonObject obj = value.toObject();
|
|
if (obj.contains("nickName")) {
|
|
if (obj.contains("nickName")) {
|
|
QString name = obj["nickName"].toString();
|
|
QString name = obj["nickName"].toString();
|
|
- QStandardItem *item = new QStandardItem(name);
|
|
|
|
- item->setCheckable(true);
|
|
|
|
- item->setData(obj["identity"].toString(), Qt::UserRole);
|
|
|
|
- operatorModel->appendRow(item);
|
|
|
|
|
|
+ comboBox->addItem(obj["identity"].toString(), name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- ui->comboBoxOperator->setModel(operatorModel);
|
|
|
|
- ui->comboBoxOperator->setView(new QListView(ui->comboBoxOperator));
|
|
|
|
- ui->comboBoxOperator->view()->setMinimumWidth(200);
|
|
|
|
-
|
|
|
|
- // 连接项变更信号
|
|
|
|
- connect(operatorModel, &QStandardItemModel::itemChanged, this, &ProjectDialog::onOperatorItemChanged);
|
|
|
|
|
|
+ QVBoxLayout *layout = new QVBoxLayout(ui->safetyInspectorsWidget);
|
|
|
|
+ layout->addWidget(comboBox);
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectDialog::on_comboBoxOperator_currentIndexChanged(int index) {
|
|
|
|
- // 此槽函数保留以避免编译错误,但不再需要之前的功能
|
|
|
|
- // 多选框的变更由 onOperatorItemChanged 处理
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void ProjectDialog::on_comboBoxBlast_currentIndexChanged(int index) {
|
|
|
|
- // 此槽函数保留以避免编译错误,但不再需要之前的功能
|
|
|
|
- // 多选框的变更由 onBlasterItemChanged 处理
|
|
|
|
-}
|
|
|
|
|
|
+void ProjectDialog::initComboBoxOperator(const QJsonArray &groundOperators) {
|
|
|
|
+ MultiSelectComboBox *comboBox = new MultiSelectComboBox(this);
|
|
|
|
|
|
-void ProjectDialog::fillComboBox(QComboBox *comboBox, const QJsonArray &jsonArray) {
|
|
|
|
- for (const QJsonValue &value : jsonArray) {
|
|
|
|
|
|
+ for (const QJsonValue &value : groundOperators) {
|
|
if (value.isObject()) {
|
|
if (value.isObject()) {
|
|
QJsonObject obj = value.toObject();
|
|
QJsonObject obj = value.toObject();
|
|
if (obj.contains("nickName")) {
|
|
if (obj.contains("nickName")) {
|
|
QString name = obj["nickName"].toString();
|
|
QString name = obj["nickName"].toString();
|
|
- comboBox->addItem(name);
|
|
|
|
|
|
+ comboBox->addItem(obj["identity"].toString(), name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ QVBoxLayout *layout = new QVBoxLayout(ui->groundOperatorsWidget);
|
|
|
|
+ layout->addWidget(comboBox);
|
|
}
|
|
}
|
|
|
|
|
|
void ProjectDialog::SetL1AddressOptions(const QJsonArray &Options) {
|
|
void ProjectDialog::SetL1AddressOptions(const QJsonArray &Options) {
|
|
@@ -136,35 +111,10 @@ void ProjectDialog::clearFormData() {
|
|
for (QLineEdit *lineEdit : lineEdits) {
|
|
for (QLineEdit *lineEdit : lineEdits) {
|
|
lineEdit->clear();
|
|
lineEdit->clear();
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 清除多选ComboBox
|
|
|
|
- if (ui->comboBoxBlast->model()) {
|
|
|
|
- QStandardItemModel *blastModel = qobject_cast<QStandardItemModel *>(ui->comboBoxBlast->model());
|
|
|
|
- if (blastModel) {
|
|
|
|
- for (int i = 0; i < blastModel->rowCount(); ++i) {
|
|
|
|
- QStandardItem *item = blastModel->item(i);
|
|
|
|
- if (item) {
|
|
|
|
- item->setCheckState(Qt::Unchecked);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ui->comboBoxBlast->setEditText("请选择井下爆破员");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (ui->comboBoxOperator->model()) {
|
|
|
|
- QStandardItemModel *operatorModel = qobject_cast<QStandardItemModel *>(ui->comboBoxOperator->model());
|
|
|
|
- if (operatorModel) {
|
|
|
|
- for (int i = 0; i < operatorModel->rowCount(); ++i) {
|
|
|
|
- QStandardItem *item = operatorModel->item(i);
|
|
|
|
- if (item) {
|
|
|
|
- item->setCheckState(Qt::Unchecked);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ui->comboBoxOperator->setEditText("请选择井上爆破员");
|
|
|
|
|
|
+ QList<MultiSelectComboBox *> multiSelectCombos = findChildren<MultiSelectComboBox *>();
|
|
|
|
+ for (MultiSelectComboBox *combo : multiSelectCombos) {
|
|
|
|
+ combo->setCheckedKeys(QStringList());
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 清除普通ComboBox
|
|
|
|
ui->comboBoxAddr->setCurrentIndex(-1);
|
|
ui->comboBoxAddr->setCurrentIndex(-1);
|
|
ui->comboBoxAddr_2->setCurrentIndex(-1);
|
|
ui->comboBoxAddr_2->setCurrentIndex(-1);
|
|
ui->comboBoxAddr_3->setCurrentIndex(-1);
|
|
ui->comboBoxAddr_3->setCurrentIndex(-1);
|
|
@@ -172,8 +122,7 @@ void ProjectDialog::clearFormData() {
|
|
// 清除选中数据
|
|
// 清除选中数据
|
|
selectedBlasters.clear();
|
|
selectedBlasters.clear();
|
|
selectedOperators.clear();
|
|
selectedOperators.clear();
|
|
- blasterIds.clear();
|
|
|
|
- operatorIds.clear();
|
|
|
|
|
|
+ selectedSafetyInspectors.clear(); // Add this line
|
|
|
|
|
|
// 显示确认按钮
|
|
// 显示确认按钮
|
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(true);
|
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setVisible(true);
|
|
@@ -195,6 +144,21 @@ void ProjectDialog::on_comboBoxAddr_2_currentIndexChanged(int index) {
|
|
}
|
|
}
|
|
|
|
|
|
void ProjectDialog::validateAndSaveProject() {
|
|
void ProjectDialog::validateAndSaveProject() {
|
|
|
|
+ for (const auto &pair :
|
|
|
|
+ ui->undergroundOperatorsWidget->findChild<MultiSelectComboBox *>()->checkedItemsWithKeys()) {
|
|
|
|
+ selectedBlasters.append(pair.first);
|
|
|
|
+ qDebug() << "Selected underground operator:" << pair.first;
|
|
|
|
+ }
|
|
|
|
+ for (const auto &pair : ui->groundOperatorsWidget->findChild<MultiSelectComboBox *>()->checkedItemsWithKeys()) {
|
|
|
|
+ selectedOperators.append(pair.first);
|
|
|
|
+ qDebug() << "Selected ground operator:" << pair.first;
|
|
|
|
+ }
|
|
|
|
+ for (const auto &pair : ui->safetyInspectorsWidget->findChild<MultiSelectComboBox *>()->checkedItemsWithKeys()) {
|
|
|
|
+ selectedSafetyInspectors.append(pair.first);
|
|
|
|
+
|
|
|
|
+ qDebug() << "Selected safety inspector:" << pair.first;
|
|
|
|
+ }
|
|
|
|
+
|
|
QString detNum = ui->editDetNum->text().trimmed();
|
|
QString detNum = ui->editDetNum->text().trimmed();
|
|
QString blastCount = ui->editRegCount->text().trimmed();
|
|
QString blastCount = ui->editRegCount->text().trimmed();
|
|
QString projectName = ui->editName->text().trimmed();
|
|
QString projectName = ui->editName->text().trimmed();
|
|
@@ -205,16 +169,18 @@ void ProjectDialog::validateAndSaveProject() {
|
|
QMessageBox::warning(nullptr, "输入错误", "请输入0-10000的数字!");
|
|
QMessageBox::warning(nullptr, "输入错误", "请输入0-10000的数字!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (selectedBlasters.isEmpty()) {
|
|
if (selectedBlasters.isEmpty()) {
|
|
QMessageBox::warning(nullptr, "选择错误", "请至少选择一名井下爆破员!");
|
|
QMessageBox::warning(nullptr, "选择错误", "请至少选择一名井下爆破员!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (selectedOperators.isEmpty()) {
|
|
if (selectedOperators.isEmpty()) {
|
|
QMessageBox::warning(nullptr, "选择错误", "请至少选择一名井上爆破员!");
|
|
QMessageBox::warning(nullptr, "选择错误", "请至少选择一名井上爆破员!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if (selectedSafetyInspectors.isEmpty()) {
|
|
|
|
+ QMessageBox::warning(nullptr, "选择错误", "请至少选择一名安全员!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
// 创建一个 QMap 集合,存储数据
|
|
// 创建一个 QMap 集合,存储数据
|
|
QMap<QString, QString> data;
|
|
QMap<QString, QString> data;
|
|
@@ -222,8 +188,6 @@ void ProjectDialog::validateAndSaveProject() {
|
|
data["name"] = projectName;
|
|
data["name"] = projectName;
|
|
data["xmbh"] = xmbh;
|
|
data["xmbh"] = xmbh;
|
|
data["htid"] = htid;
|
|
data["htid"] = htid;
|
|
- data["operatorName"] = selectedOperators.join(", ");
|
|
|
|
- data["blasterName"] = selectedBlasters.join(", ");
|
|
|
|
|
|
|
|
// 选择level最低的uuid
|
|
// 选择level最低的uuid
|
|
QString addressUuid = ui->comboBoxAddr->currentData().toString().trimmed();
|
|
QString addressUuid = ui->comboBoxAddr->currentData().toString().trimmed();
|
|
@@ -244,22 +208,25 @@ void ProjectDialog::validateAndSaveProject() {
|
|
|
|
|
|
data["addressPath"] = l1AddressName + "/" + l2AddressName + "/" + l3AddressName;
|
|
data["addressPath"] = l1AddressName + "/" + l2AddressName + "/" + l3AddressName;
|
|
data["addressUuid"] = addressUuid;
|
|
data["addressUuid"] = addressUuid;
|
|
- data["blasterIdentity"] = blasterIds.join(",");
|
|
|
|
- data["operatorIdentity"] = operatorIds.join(",");
|
|
|
|
|
|
+ data["blasterIdentity"] = selectedBlasters.join(",");
|
|
|
|
+ data["operatorIdentity"] = selectedOperators.join(",");
|
|
|
|
+ data["safetyInspectorIdentity"] = selectedSafetyInspectors.join(",");
|
|
data["blastCount"] = blastCount;
|
|
data["blastCount"] = blastCount;
|
|
|
|
|
|
- if (operationStatus == 0) {
|
|
|
|
- emit validateDetNum(data);
|
|
|
|
- } else if (operationStatus == 1) {
|
|
|
|
- emit validateDetNumUpdate(data);
|
|
|
|
|
|
+ if (operationType == 0) {
|
|
|
|
+ qDebug() << "Project data to create:" << data;
|
|
|
|
+ emit createProject(data);
|
|
|
|
+ } else if (operationType == 1) {
|
|
|
|
+ qDebug() << "Project data to update:" << data;
|
|
|
|
+ emit saveProject(data);
|
|
}
|
|
}
|
|
|
|
|
|
clearFormData(); // 清除表单数据
|
|
clearFormData(); // 清除表单数据
|
|
}
|
|
}
|
|
|
|
|
|
-int ProjectDialog::getOperationStatus() const { return operationStatus; }
|
|
|
|
|
|
+int ProjectDialog::getOperationType() const { return operationType; }
|
|
|
|
|
|
-void ProjectDialog::setOperationStatus(int newOperationStatus) { operationStatus = newOperationStatus; }
|
|
|
|
|
|
+void ProjectDialog::setOperationType(int newOperationType) { operationType = newOperationType; }
|
|
|
|
|
|
void ProjectDialog::setFormData(const HProject &Project) {
|
|
void ProjectDialog::setFormData(const HProject &Project) {
|
|
try {
|
|
try {
|
|
@@ -274,41 +241,7 @@ void ProjectDialog::setFormData(const HProject &Project) {
|
|
ui->editRegCount->setText(Project.getBlastCount());
|
|
ui->editRegCount->setText(Project.getBlastCount());
|
|
ui->level4Address->setText(Project.getLevel4Address());
|
|
ui->level4Address->setText(Project.getLevel4Address());
|
|
|
|
|
|
- // 设置井下爆破员多选
|
|
|
|
- QStringList blasterNames = Project.getBlasterName().split(", ");
|
|
|
|
- QStringList blasterIdList = Project.getBlasterIdentity().split(",");
|
|
|
|
- QStandardItemModel *blastModel = qobject_cast<QStandardItemModel *>(ui->comboBoxBlast->model());
|
|
|
|
- if (blastModel) {
|
|
|
|
- for (int i = 0; i < blastModel->rowCount(); ++i) {
|
|
|
|
- QStandardItem *item = blastModel->item(i);
|
|
|
|
- if (item && blasterNames.contains(item->text())) {
|
|
|
|
- item->setCheckState(Qt::Checked);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 设置井上爆破员多选
|
|
|
|
- QStringList operatorNames = Project.getOperatorName().split(", ");
|
|
|
|
- QStringList operatorIdList = Project.getOperatorIdentity().split(",");
|
|
|
|
- QStandardItemModel *operatorModel = qobject_cast<QStandardItemModel *>(ui->comboBoxOperator->model());
|
|
|
|
- if (operatorModel) {
|
|
|
|
- for (int i = 0; i < operatorModel->rowCount(); ++i) {
|
|
|
|
- QStandardItem *item = operatorModel->item(i);
|
|
|
|
- if (item && operatorNames.contains(item->text())) {
|
|
|
|
- item->setCheckState(Qt::Checked);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 更新已选择列表
|
|
|
|
- selectedBlasters = blasterNames;
|
|
|
|
- blasterIds = blasterIdList;
|
|
|
|
- selectedOperators = operatorNames;
|
|
|
|
- operatorIds = operatorIdList;
|
|
|
|
-
|
|
|
|
- // 更新ComboBox显示文本
|
|
|
|
- ui->comboBoxBlast->setEditText(selectedBlasters.join(", "));
|
|
|
|
- ui->comboBoxOperator->setEditText(selectedOperators.join(", "));
|
|
|
|
|
|
+ // TODO: 这里需要处理井下爆破员和井上爆破员及安全员
|
|
|
|
|
|
// 设置地址选择
|
|
// 设置地址选择
|
|
QStringList addressParts = Project.getAddressPath().split("/");
|
|
QStringList addressParts = Project.getAddressPath().split("/");
|
|
@@ -360,54 +293,4 @@ void ProjectDialog::setFormData(const HProject &Project) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void ProjectDialog::onBlasterItemChanged(QStandardItem *item) { updateSelectedBlasters(); }
|
|
|
|
-
|
|
|
|
-void ProjectDialog::onOperatorItemChanged(QStandardItem *item) { updateSelectedOperators(); }
|
|
|
|
-
|
|
|
|
-void ProjectDialog::updateSelectedBlasters() {
|
|
|
|
- selectedBlasters.clear();
|
|
|
|
- blasterIds.clear();
|
|
|
|
- QStandardItemModel *model = qobject_cast<QStandardItemModel *>(ui->comboBoxBlast->model());
|
|
|
|
-
|
|
|
|
- if (!model) return;
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
- QStandardItem *item = model->item(i);
|
|
|
|
- if (item && item->checkState() == Qt::Checked) {
|
|
|
|
- selectedBlasters.append(item->text());
|
|
|
|
- blasterIds.append(item->data(Qt::UserRole).toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 更新显示的文本
|
|
|
|
- if (selectedBlasters.isEmpty()) {
|
|
|
|
- ui->comboBoxBlast->setEditText("请选择井下爆破员");
|
|
|
|
- } else {
|
|
|
|
- ui->comboBoxBlast->setEditText(selectedBlasters.join(", "));
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void ProjectDialog::updateSelectedOperators() {
|
|
|
|
- selectedOperators.clear();
|
|
|
|
- operatorIds.clear();
|
|
|
|
- QStandardItemModel *model = qobject_cast<QStandardItemModel *>(ui->comboBoxOperator->model());
|
|
|
|
-
|
|
|
|
- if (!model) return;
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < model->rowCount(); ++i) {
|
|
|
|
- QStandardItem *item = model->item(i);
|
|
|
|
- if (item && item->checkState() == Qt::Checked) {
|
|
|
|
- selectedOperators.append(item->text());
|
|
|
|
- operatorIds.append(item->data(Qt::UserRole).toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 更新显示的文本
|
|
|
|
- if (selectedOperators.isEmpty()) {
|
|
|
|
- ui->comboBoxOperator->setEditText("请选择井上爆破员");
|
|
|
|
- } else {
|
|
|
|
- ui->comboBoxOperator->setEditText(selectedOperators.join(", "));
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
ProjectDialog::~ProjectDialog() { delete ui; }
|
|
ProjectDialog::~ProjectDialog() { delete ui; }
|