From 15e6e5c85b05d43db2529c148804a9261b924ec0 Mon Sep 17 00:00:00 2001
From: syruan <15555146157@163.com>
Date: Thu, 30 Oct 2025 10:49:56 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=A7=E7=BA=BF=E9=94=99?=
 =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0=EF=BC=8C=E5=88=86?=
 =?UTF-8?q?=E6=9E=90=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 src/api/cost/cost.js                          |  45 +++
 .../material/cost/component/unreportHome.vue  | 343 +++++++++++++++++-
 2 files changed, 387 insertions(+), 1 deletion(-)
diff --git a/src/api/cost/cost.js b/src/api/cost/cost.js
index e86b8411..d0e2b730 100644
--- a/src/api/cost/cost.js
+++ b/src/api/cost/cost.js
@@ -292,5 +292,50 @@ export function viewRepairCodeApi(query) {
   })
 }
 
+// 查询历史报表列表(按年月)
+export function getHistoryReportList(query) {
+  return request({
+    url: '/material/slt_agreement_info/getHistoryReportList',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询历史租赁费用详情
+export function getHistoryLeaseCostDetails(query) {
+  return request({
+    url: '/material/slt_agreement_info/getHistoryLeaseCostDetails',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询历史维修费用详情
+export function getHistoryRepairCostDetails(query) {
+  return request({
+    url: '/material/slt_agreement_info/getHistoryRepairCostDetails',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询历史丢失费用详情
+export function getHistoryLoseCostDetails(query) {
+  return request({
+    url: '/material/slt_agreement_info/getHistoryLoseCostDetails',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询历史报废费用详情
+export function getHistoryScrapCostDetails(query) {
+  return request({
+    url: '/material/slt_agreement_info/getHistoryScrapCostDetails',
+    method: 'get',
+    params: query
+  })
+}
+
 
 
diff --git a/src/views/material/cost/component/unreportHome.vue b/src/views/material/cost/component/unreportHome.vue
index bd041d5d..dc319dd5 100644
--- a/src/views/material/cost/component/unreportHome.vue
+++ b/src/views/material/cost/component/unreportHome.vue
@@ -27,6 +27,7 @@
                 重置
                 导出Excel
                 批量导出ZIP
+                查看历史报表
             
         
 
@@ -330,6 +331,209 @@
                 关闭
             
         
+
+        
+        
+            
+                
+                    
+                    
+                
+            
+            
+        
+
+        
+        
+            
+                
+                
+                
+                
+                
+                    
+                        工器具
+                        安全工器具
+                        总费用
+                    
+                
+                
+                    
+                        
+                            {{ scope.row.leaseCost || 0 }}
+                        
+                    
+                
+                
+                    
+                        
+                            {{ scope.row.repairCost || 0 }}
+                        
+                    
+                
+                
+                    
+                        
+                            {{ scope.row.loseCost || 0 }}
+                        
+                    
+                
+                
+                    
+                        
+                            {{ scope.row.scrapCost || 0 }}
+                        
+                    
+                
+                
+                    
+                        {{ calculateTotalCost(scope.row).toFixed(2) }}
+                    
+                
+            
+            
+        
+
+        
+        
+            
+            
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                
+                    
+                        {{ scope.row.cost ? scope.row.cost.toFixed(2) : '0.00' }}
+                    
+                
+            
+
+            
+            
+                
+                
+                
+                
+                
+                
+                    
+                        收费
+                        不收费
+                        {{ scope.row.partType || '-' }}
+                    
+                
+                
+                    
+                        {{ scope.row.cost ? scope.row.cost.toFixed(2) : '0.00' }}
+                    
+                
+            
+
+            
+            
+                
+                
+                
+                
+                
+                
+                    
+                        {{ scope.row.cost ? scope.row.cost.toFixed(2) : '0.00' }}
+                    
+                
+            
+
+            
+            
+                
+                
+                
+                
+                
+                
+                    
+                        {{ scope.row.cost ? scope.row.cost.toFixed(2) : '0.00' }}
+                    
+                
+            
+
+            
+        
     
 
 
@@ -339,7 +543,7 @@ import {
   getUnitList,
   getAgreementInfoById, getUnitListFilterTeam,
 } from '@/api/back/index.js'
-import {getSltList, costExamine, getSltReportedList, getSltReportList} from '@/api/cost/cost'
+import {getSltList, costExamine, getSltReportedList, getSltReportList, getHistoryReportList, getHistoryLeaseCostDetails, getHistoryRepairCostDetails, getHistoryLoseCostDetails, getHistoryScrapCostDetails} from '@/api/cost/cost'
 import { toChineseAmount } from '@/utils/bonus.js'
 import vueEasyPrint from "vue-easy-print";
 import Treeselect from "@riophae/vue-treeselect";
@@ -421,6 +625,22 @@ export default {
             costDetailTitle: '',
             costDetailList: [],
             costDetailType: '', // 当前查看的费用类型
+            // 历史报表相关
+            historyReportDialogVisible: false,
+            historyReportListVisible: false,
+            historyReportLoading: false,
+            historyReportTitle: '',
+            historyReportList: [],
+            historyReportParams: {
+                yearMonth: null,
+            },
+            // 历史费用详情相关
+            historyCostDetailVisible: false,
+            historyCostDetailLoading: false,
+            historyCostDetailTitle: '',
+            historyCostDetailList: [],
+            historyCostDetailType: '', // 当前查看的历史费用类型
+            currentHistoryRow: {}, // 当前选中的历史报表行
         }
     },
     created() {
@@ -1018,6 +1238,127 @@ export default {
             return leaseCost + repairCost + loseCost + scrapCost - reductionCost;
         },
 
+        // 显示历史报表选择弹窗
+        showHistoryReportDialog() {
+            this.historyReportParams.yearMonth = null;
+            this.historyReportDialogVisible = true;
+        },
+
+        // 查询历史报表
+        queryHistoryReport() {
+            if (!this.historyReportParams.yearMonth) {
+                this.$message.error('请选择年月');
+                return;
+            }
+
+            this.historyReportLoading = true;
+            const params = {
+                yearMonth: this.historyReportParams.yearMonth
+            };
+
+            getHistoryReportList(params).then((response) => {
+                this.historyReportList = response.rows || [];
+                this.historyReportTitle = `${this.historyReportParams.yearMonth}历史报表`;
+                this.historyReportDialogVisible = false;
+                this.historyReportListVisible = true;
+                this.historyReportLoading = false;
+            }).catch(() => {
+                this.historyReportLoading = false;
+            });
+        },
+
+        // 显示历史费用详情
+        showHistoryCostDetail(row, costType) {
+            this.currentHistoryRow = row;
+            const costTypeMap = {
+                'lease': '租赁费用',
+                'repair': '维修费用',
+                'lose': '丢失费用',
+                'scrap': '报废费用'
+            };
+
+            this.historyCostDetailTitle = `${costTypeMap[costType]}详情 - ${row.agreementCode}`;
+            this.historyCostDetailType = costType;
+            this.historyCostDetailVisible = true;
+            this.historyCostDetailLoading = true;
+            this.historyCostDetailList = [];
+
+            // 根据费用类型调用不同的接口
+            const params = {
+                agreementId: row.agreementId,
+                yearMonth: this.historyReportParams.yearMonth
+            };
+
+            let apiCall;
+            switch (costType) {
+                case 'lease':
+                    apiCall = getHistoryLeaseCostDetails(params);
+                    break;
+                case 'repair':
+                    apiCall = getHistoryRepairCostDetails(params);
+                    break;
+                case 'lose':
+                    apiCall = getHistoryLoseCostDetails(params);
+                    break;
+                case 'scrap':
+                    apiCall = getHistoryScrapCostDetails(params);
+                    break;
+                default:
+                    this.historyCostDetailLoading = false;
+                    return;
+            }
+
+            apiCall.then((response) => {
+                const sourceList = response.rows || [];
+
+                // 根据不同费用类型处理数据
+                this.historyCostDetailList = sourceList.map(item => {
+                    const baseData = {
+                        name: item.typeName || '',
+                        model: item.modelName || '',
+                        unit: item.mtUnitName || '',
+                        cost: item.costs || 0,
+                        costType: costType
+                    };
+
+                    // 根据费用类型添加特定字段
+                    if (costType === 'lease') {
+                        return {
+                            ...baseData,
+                            unitPrice: item.leasePrice || 0,
+                            quantity: item.num || 0,
+                            returnQuantity: item.backNum || 0,
+                            leaseDate: item.startTime || '',
+                            returnDate: item.endTime || '',
+                            days: item.leaseDays || 0
+                        };
+                    } else if (costType === 'repair') {
+                        return {
+                            ...baseData,
+                            repairQuantity: item.num || 0,
+                            partType: item.partType
+                        };
+                    } else if (costType === 'lose') {
+                        return {
+                            ...baseData,
+                            loseQuantity: item.num || 0
+                        };
+                    } else if (costType === 'scrap') {
+                        return {
+                            ...baseData,
+                            scrapQuantity: item.num || 0
+                        };
+                    }
+
+                    return baseData;
+                });
+
+                this.historyCostDetailLoading = false;
+            }).catch(() => {
+                this.historyCostDetailLoading = false;
+            });
+        },
+
     },
 }