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 @@