From 4d9d8d22e3666076988c30afb4e7c6fe365c19aa Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期二, 06 一月 2026 18:53:04 +0800
Subject: [PATCH] 1.修复一个回复错误的问题;

---
 SourceCode/Bond/Servo/CPageReport.cpp |   87 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageReport.cpp b/SourceCode/Bond/Servo/CPageReport.cpp
index ca178ef..4e3fd2e 100644
--- a/SourceCode/Bond/Servo/CPageReport.cpp
+++ b/SourceCode/Bond/Servo/CPageReport.cpp
@@ -5,6 +5,8 @@
 #include "Servo.h"
 #include "CPageReport.h"
 #include "afxdialogex.h"
+#include "CReportEditDlg.h"
+#include <algorithm>
 
 
 // CPageReport 瀵硅瘽妗�
@@ -148,3 +150,88 @@
 
 	*pResult = 0;
 }
+
+void CPageReport::OnClickedBtn(const char* btnName)
+{
+	ASSERT(btnName);
+	if (_strcmpi(btnName, "鏂板") == 0) {
+		int rc = UX_CanExecute(L"addReports");
+		if (rc != 1) {
+			AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+			return;
+		}
+
+		unsigned int newId = theApp.m_model.m_hsmsPassive.getMaxReportId() + 1;
+		std::vector<unsigned int> initVids;
+		CReportEditDlg dlg(_T("鏂板鎶ュ憡"), static_cast<int>(newId), initVids, this);
+		if (dlg.DoModal() != IDOK) return;
+		const auto& vids = dlg.GetSelectedVids();
+
+		int ret = theApp.m_model.m_hsmsPassive.addReport(static_cast<int>(newId), vids);
+		if (ret == 0) {
+			UX_RecordAction(L"addReports");
+			m_listCtrl.DeleteAllItems();
+			loadReports();
+			if (CButton* pDel = GetBtnByName("鍒犻櫎")) pDel->EnableWindow(FALSE);
+			if (CButton* pEdit = GetBtnByName("缂栬緫")) pEdit->EnableWindow(FALSE);
+		}
+		else {
+			AfxMessageBox(_T("鏂板鎶ュ憡澶辫触锛堝彲鑳絀D閲嶅鎴栨枃浠跺啓鍏ュけ璐ワ級"));
+		}
+	}
+	else if (_strcmpi(btnName, "鍒犻櫎") == 0) {
+		POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
+		if (pos == nullptr) return;
+		int nItem = m_listCtrl.GetNextSelectedItem(pos);
+		auto pRpt = reinterpret_cast<SERVO::CReport*>(m_listCtrl.GetItemData(nItem));
+		if (pRpt == nullptr) return;
+
+		int rc = UX_CanExecute(L"delReports");
+		if (rc != 1) {
+			AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+			return;
+		}
+
+		int ret = theApp.m_model.m_hsmsPassive.deleteReport((int)pRpt->getReportId());
+		if (ret == 0) {
+			UX_RecordAction(L"delReports");
+			m_listCtrl.DeleteAllItems();
+			loadReports();
+			if (CButton* pDel = GetBtnByName("鍒犻櫎")) pDel->EnableWindow(FALSE);
+			if (CButton* pEdit = GetBtnByName("缂栬緫")) pEdit->EnableWindow(FALSE);
+		}
+		else {
+			AfxMessageBox(_T("鍒犻櫎鎶ュ憡澶辫触"));
+		}
+	}
+	else if (_strcmpi(btnName, "缂栬緫") == 0) {
+		POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
+		if (pos == nullptr) return;
+		int nItem = m_listCtrl.GetNextSelectedItem(pos);
+		auto pRpt = reinterpret_cast<SERVO::CReport*>(m_listCtrl.GetItemData(nItem));
+		if (pRpt == nullptr) return;
+
+		int rc = UX_CanExecute(L"editReports");
+		if (rc != 1) {
+			AfxMessageBox("鎿嶄綔鏉冮檺涓嶈冻锛岃鑱旂郴绠$悊浜哄憳锛�");
+			return;
+		}
+
+		std::vector<unsigned int> vidsExisting = pRpt->getVids();
+		CReportEditDlg dlg(_T("缂栬緫鎶ュ憡"), (int)pRpt->getReportId(), vidsExisting, this);
+		if (dlg.DoModal() != IDOK) return;
+		const auto& vids = dlg.GetSelectedVids();
+
+		int ret = theApp.m_model.m_hsmsPassive.updateReport((int)pRpt->getReportId(), vids);
+		if (ret == 0) {
+			UX_RecordAction(L"editReports");
+			m_listCtrl.DeleteAllItems();
+			loadReports();
+			if (CButton* pDel = GetBtnByName("鍒犻櫎")) pDel->EnableWindow(FALSE);
+			if (CButton* pEdit = GetBtnByName("缂栬緫")) pEdit->EnableWindow(FALSE);
+		}
+		else {
+			AfxMessageBox(_T("缂栬緫鎶ュ憡澶辫触锛堝彲鑳芥枃浠跺啓鍏ュけ璐ワ級"));
+		}
+	}
+}

--
Gitblit v1.9.3