From 286e598f0d7487bc67a6cca4078afd581c6cb0dc Mon Sep 17 00:00:00 2001 From: 18631081161 <2088094923@qq.com> Date: Fri, 16 Jan 2026 14:26:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrganizationsController.cs | 24 +++++++++++++++++++ src/frontend/src/views/Dashboard.vue | 2 +- .../src/views/allocations/AllocationList.vue | 10 +++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/MilitaryTrainingManagement/Controllers/OrganizationsController.cs b/src/MilitaryTrainingManagement/Controllers/OrganizationsController.cs index ea04c0b..939e3f7 100644 --- a/src/MilitaryTrainingManagement/Controllers/OrganizationsController.cs +++ b/src/MilitaryTrainingManagement/Controllers/OrganizationsController.cs @@ -195,6 +195,30 @@ public class OrganizationsController : BaseApiController return NotFound(new { message = "账户不存在" }); } + // 检查是否有关联的上报记录 + var hasConsumptionReports = await _context.ConsumptionReports + .AnyAsync(r => r.ReportedByUserId == accountId); + if (hasConsumptionReports) + { + return BadRequest(new { message = "该账户有上报记录,无法删除" }); + } + + // 检查是否有关联的配额分配上报 + var hasDistributionReports = await _context.AllocationDistributions + .AnyAsync(d => d.ReportedByUserId == accountId); + if (hasDistributionReports) + { + return BadRequest(new { message = "该账户有配额上报记录,无法删除" }); + } + + // 检查是否有关联的人员审批历史 + var hasApprovalHistory = await _context.PersonnelApprovalHistories + .AnyAsync(h => h.ReviewedByUserId == accountId); + if (hasApprovalHistory) + { + return BadRequest(new { message = "该账户有审批记录,无法删除" }); + } + _context.UserAccounts.Remove(account); await _context.SaveChangesAsync(); diff --git a/src/frontend/src/views/Dashboard.vue b/src/frontend/src/views/Dashboard.vue index 2af1e36..ea0380b 100644 --- a/src/frontend/src/views/Dashboard.vue +++ b/src/frontend/src/views/Dashboard.vue @@ -10,7 +10,7 @@