diff --git a/src/MilitaryTrainingManagement/Controllers/ConsumptionChangeRequestsController.cs b/src/MilitaryTrainingManagement/Controllers/ConsumptionChangeRequestsController.cs index 80ae34e..ef1d5a7 100644 --- a/src/MilitaryTrainingManagement/Controllers/ConsumptionChangeRequestsController.cs +++ b/src/MilitaryTrainingManagement/Controllers/ConsumptionChangeRequestsController.cs @@ -177,6 +177,57 @@ public class ConsumptionChangeRequestsController : BaseApiController return Ok(requests); } + /// + /// 获取已处理的申请列表(上级单位已处理的下级申请) + /// + [HttpGet("processed")] + public async Task GetProcessedRequests() + { + var unitId = GetCurrentUnitId(); + if (unitId == null) + return Unauthorized(); + + // 获取下级单位的ID列表 + var subordinateIds = await GetSubordinateUnitIds(unitId.Value); + + var requests = await _context.ConsumptionReportChangeRequests + .Include(r => r.ConsumptionReport) + .ThenInclude(cr => cr.AllocationDistribution) + .ThenInclude(d => d.Allocation) + .Include(r => r.RequestedByUnit) + .Include(r => r.RequestedByUser) + .Include(r => r.ProcessedByUnit) + .Where(r => r.Status != ChangeRequestStatus.Pending + && subordinateIds.Contains(r.RequestedByUnitId)) + .OrderByDescending(r => r.ProcessedAt) + .Select(r => new + { + r.Id, + r.ConsumptionReportId, + RequestType = r.RequestType.ToString(), + r.Reason, + Status = r.Status.ToString(), + r.RequestedAt, + RequestedByUnitName = r.RequestedByUnit.Name, + RequestedByUserName = r.RequestedByUser.DisplayName, + r.ProcessedAt, + ProcessedByUnitName = r.ProcessedByUnit != null ? r.ProcessedByUnit.Name : null, + r.ProcessComments, + ConsumptionReport = new + { + r.ConsumptionReport.Id, + r.ConsumptionReport.ReportedAmount, + r.ConsumptionReport.ReportedAt, + r.ConsumptionReport.Remarks, + MaterialName = r.ConsumptionReport.AllocationDistribution.Allocation.MaterialName, + Unit = r.ConsumptionReport.AllocationDistribution.Allocation.Unit + } + }) + .ToListAsync(); + + return Ok(requests); + } + /// /// 处理申请(同意或拒绝) /// diff --git a/src/frontend/src/api/allocations.ts b/src/frontend/src/api/allocations.ts index 1148b24..1ba314c 100644 --- a/src/frontend/src/api/allocations.ts +++ b/src/frontend/src/api/allocations.ts @@ -118,6 +118,12 @@ export const changeRequestsApi = { return response.data }, + // 获取已处理的申请(上级已处理的下级申请) + async getProcessed(): Promise { + const response = await apiClient.get('/ConsumptionChangeRequests/processed') + return response.data + }, + // 获取本单位的申请 async getMy(): Promise { const response = await apiClient.get('/ConsumptionChangeRequests/my') diff --git a/src/frontend/src/views/allocations/ChangeRequestList.vue b/src/frontend/src/views/allocations/ChangeRequestList.vue index 4027293..f8bcb75 100644 --- a/src/frontend/src/views/allocations/ChangeRequestList.vue +++ b/src/frontend/src/views/allocations/ChangeRequestList.vue @@ -9,6 +9,7 @@ 待处理 + 已处理 我的申请 @@ -68,6 +69,57 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
@@ -188,8 +240,9 @@ import { changeRequestsApi, type ChangeRequest } from '@/api' const loading = ref(false) const processing = ref(false) -const viewMode = ref<'pending' | 'my'>('pending') +const viewMode = ref<'pending' | 'processed' | 'my'>('pending') const pendingRequests = ref([]) +const processedRequests = ref([]) const myRequests = ref([]) const rejectDialogVisible = ref(false) @@ -228,6 +281,14 @@ async function loadPendingRequests() { } } +async function loadProcessedRequests() { + try { + processedRequests.value = await changeRequestsApi.getProcessed() + } catch (error: any) { + console.error('加载已处理申请失败', error) + } +} + async function loadMyRequests() { try { myRequests.value = await changeRequestsApi.getMy() @@ -239,7 +300,7 @@ async function loadMyRequests() { async function loadData() { loading.value = true try { - await Promise.all([loadPendingRequests(), loadMyRequests()]) + await Promise.all([loadPendingRequests(), loadProcessedRequests(), loadMyRequests()]) } finally { loading.value = false }