|
@@ -153,7 +153,7 @@ void ConfigExpertDataWidget::loadData()
|
|
|
|
|
|
qDeleteAll(m_configList);
|
|
|
m_configList.clear();
|
|
|
- if (!UserConfigService().QueryAllUserConfig(&m_configList)) {
|
|
|
+ if (!UserConfigService().QueryUserConfigListInfoByEngineerId(&m_configList, m_process.projectId)) {
|
|
|
QFDAlert::showAlertWithCode(QF_CODE_DATA_ERROR, this);
|
|
|
return;
|
|
|
}
|
|
@@ -206,10 +206,36 @@ void ConfigExpertDataWidget::refreshExpList()
|
|
|
widget->setUser(expert);
|
|
|
widget->setIndex(i + 1);
|
|
|
m_expListWidget->setItemWidget(item, widget);
|
|
|
+
|
|
|
+ for (UserConfig *config : m_configList) {
|
|
|
+ if (config->userId == expert->id) {
|
|
|
+ widget->setAdded(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ConfigExpertDataWidget::slotSave() { }
|
|
|
+void ConfigExpertDataWidget::slotSave()
|
|
|
+{
|
|
|
+ int sum = 0;
|
|
|
+ for (int i = 0; i < m_configListWidget->count(); i++) {
|
|
|
+ QListWidgetItem *item = m_configListWidget->item(i);
|
|
|
+ ConfigListItemWidget *widget = (ConfigListItemWidget *)m_configListWidget->itemWidget(item);
|
|
|
+ sum += widget->spinValue();
|
|
|
+ widget->userConfig()->weight = widget->spinValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sum != 100) {
|
|
|
+ QFDAlert::showAlertWithCode(QF_CODE_WEIGHTSUM_ERROR, this);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (UserConfig *config : m_configList) {
|
|
|
+ UserConfigService().UpdateUserConfig(*config);
|
|
|
+ }
|
|
|
+ loadData();
|
|
|
+}
|
|
|
|
|
|
void ConfigExpertDataWidget::slotRefresh()
|
|
|
{
|
|
@@ -219,11 +245,27 @@ void ConfigExpertDataWidget::slotRefresh()
|
|
|
void ConfigExpertDataWidget::slotAddUser(QFUser *user)
|
|
|
{
|
|
|
qDebug() << __FUNCTION__ << __LINE__ << user->userName << endl;
|
|
|
+
|
|
|
+ for (UserConfig *config : m_configList) {
|
|
|
+ if (config->userId == user->id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UserConfig cfg;
|
|
|
+ cfg.userId = user->id;
|
|
|
+ cfg.userName = user->userName;
|
|
|
+ cfg.engineerId = m_process.projectId;
|
|
|
+ cfg.weight = m_configList.count() > 0 ? 0 : 100;
|
|
|
+ UserConfigService().AddUserConfig(cfg);
|
|
|
+ loadData();
|
|
|
}
|
|
|
|
|
|
void ConfigExpertDataWidget::slotRemoveConfig(UserConfig *config)
|
|
|
{
|
|
|
qDebug() << __FUNCTION__ << __LINE__ << config->userName << endl;
|
|
|
+ UserConfigService().DeleteUserConfigById(config->id);
|
|
|
+ loadData();
|
|
|
}
|
|
|
|
|
|
void ConfigExpertDataWidget::slotImportData(UserConfig *config)
|
|
@@ -250,11 +292,18 @@ void ConfigListItemWidget::setUserConfig(UserConfig *config)
|
|
|
m_weight->setValue(m_config->weight);
|
|
|
}
|
|
|
|
|
|
+int ConfigListItemWidget::spinValue() const
|
|
|
+{
|
|
|
+ return m_weight->value();
|
|
|
+}
|
|
|
+
|
|
|
void ConfigListItemWidget::initWidget()
|
|
|
{
|
|
|
m_name = new QLabel(this);
|
|
|
m_weight = new QSpinBox(this);
|
|
|
m_weight->setSuffix("%");
|
|
|
+ m_weight->setMaximum(100);
|
|
|
+ m_weight->setMinimum(0);
|
|
|
m_import = new QPushButton(NEWFLICON(FluentIcon, DOWNLOAD)->icon(), "", this);
|
|
|
m_import->setFixedSize(QSize(25, 25));
|
|
|
m_import->setIconSize(QSize(15, 15));
|
|
@@ -315,6 +364,11 @@ void ExpertListItemWidget::setIndex(int index)
|
|
|
m_index->setText(QString("%1").arg(index));
|
|
|
}
|
|
|
|
|
|
+void ExpertListItemWidget::setAdded(bool added)
|
|
|
+{
|
|
|
+ m_add->setHidden(added);
|
|
|
+}
|
|
|
+
|
|
|
void ExpertListItemWidget::initWidget()
|
|
|
{
|
|
|
m_index = new QLabel(this);
|
|
@@ -322,7 +376,7 @@ void ExpertListItemWidget::initWidget()
|
|
|
m_add = new QPushButton(NEWFLICON(FluentIcon, ADD)->icon(), "", this);
|
|
|
m_add->setFixedSize(QSize(25, 25));
|
|
|
m_add->setIconSize(QSize(10, 10));
|
|
|
- m_add->setToolTip("移除");
|
|
|
+ m_add->setToolTip("添加");
|
|
|
}
|
|
|
|
|
|
void ExpertListItemWidget::initLayout()
|