区间费用报表vue编写

This commit is contained in:
syruan 2025-08-30 17:04:19 +08:00
parent ae32826796
commit 5305aa1169
4 changed files with 770 additions and 0 deletions

View File

@ -238,6 +238,24 @@ export function getScrapReportList(query) {
})
}
// 查询租赁费用区间报表列表
export function getLeaseCostRangeReportList(query) {
return request({
url: '/material/slt_agreement_info/leasePeriodCostList',
method: 'get',
params: query
})
}
// 查询租赁费用明细详情
export function getLeaseCostDetails(query) {
return request({
url: '/material/slt_agreement_info/leasePeriodCostDetails',
method: 'get',
params: query
})
}

View File

@ -242,6 +242,51 @@ export const dynamicRoutes = [
component: () => import('@/views/business-examine/reduction-apply/business-details.vue')
}
]
},
// 丢失费用报表
{
path: '/material/cost/lost-report',
component: Layout,
hidden: true,
permissions: ['material:cost:lost-report'], // 权限字符
children: [
{
path: 'index',
name: 'LostReport',
meta: { title: '丢失费用报表', activeMenu: '/material/cost' },
component: () => import('@/views/material/cost/lostReportList.vue')
}
]
},
// 维修费用报表
{
path: '/material/cost/repair-report',
component: Layout,
hidden: true,
permissions: ['material:cost:repair-report'], // 权限字符
children: [
{
path: 'index',
name: 'RepairReport',
meta: { title: '维修费用报表', activeMenu: '/material/cost' },
component: () => import('@/views/material/cost/repairReportList.vue')
}
]
},
// 报废费用报表
{
path: '/material/cost/scrap-report',
component: Layout,
hidden: true,
permissions: ['material:cost:scrap-report'], // 权限字符
children: [
{
path: 'index',
name: 'ScrapReport',
meta: { title: '报废费用报表', activeMenu: '/material/cost' },
component: () => import('@/views/material/cost/scrapReportList.vue')
}
]
}
]

View File

@ -0,0 +1,685 @@
<template>
<div class="app-container" id="leaseCostRangeReportList">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="查询时间范围" prop="dateRange">
<el-date-picker
v-model="queryParams.dateRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
style="width: 240px"
@change="handleDateRangeChange">
</el-date-picker>
</el-form-item>
<el-form-item label="协议号" prop="agreementCode">
<el-input v-model="queryParams.agreementCode" placeholder="请输入协议号" clearable style="width: 180px"/>
</el-form-item>
<el-form-item label="结算状态" prop="settlementStatus">
<el-select v-model="queryParams.settlementStatus" placeholder="请选择结算状态" clearable style="width: 160px">
<el-option label="未结算" value="0"></el-option>
<el-option label="已结算" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
<el-button type="success" icon="el-icon-download" size="mini" @click="exportExcel" :disabled="tableList.length === 0">导出Excel</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="tableList" border stripe>
<el-table-column label="序号" align="center" type="index" width="60">
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="协议号" align="center" prop="agreementCode" :show-overflow-tooltip="true" width="150"/>
<el-table-column label="结算单位" align="center" prop="unitName" :show-overflow-tooltip="true" width="180"/>
<el-table-column label="结算工程" align="center" prop="projectName" :show-overflow-tooltip="true" width="200"/>
<el-table-column label="结算状态" align="center" prop="isSettled" width="90">
<template slot-scope="scope">
<el-tag :type="scope.row.isSettled === '1' ? 'success' : 'warning'">
{{ scope.row.isSettled === '1' ? '已结算' : '未结算' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="设备类型数" align="center" prop="equipmentTypeCount" width="100"/>
<el-table-column label="设备总数量" align="center" prop="totalEquipmentCount" width="100">
<template slot-scope="scope">
{{ scope.row.totalEquipmentCount ? parseFloat(scope.row.totalEquipmentCount).toFixed(3) : '0.000' }}
</template>
</el-table-column>
<el-table-column label="总租赁天数" align="center" prop="totalLeaseDays" width="100"/>
<el-table-column label="总租赁费用(元)" align="center" prop="totalLeaseCost" width="130">
<template slot-scope="scope">
{{ scope.row.totalLeaseCost ? parseFloat(scope.row.totalLeaseCost).toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="日均租金(元)" align="center" prop="avgDailyRent" width="120">
<template slot-scope="scope">
{{ scope.row.avgDailyRent ? parseFloat(scope.row.avgDailyRent).toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="查询开始日期" align="center" prop="queryStartDate" width="120"/>
<el-table-column label="查询结束日期" align="center" prop="queryEndDate" width="120"/>
<el-table-column label="最早租赁时间" align="center" prop="earliestLeaseTime" width="120">
<template slot-scope="scope">
{{ scope.row.earliestLeaseTime || '-' }}
</template>
</el-table-column>
<el-table-column label="最晚归还时间" align="center" prop="latestReturnTime" width="120">
<template slot-scope="scope">
{{ scope.row.latestReturnTime || '-' }}
</template>
</el-table-column>
<el-table-column label="结算时间" align="center" prop="settlementTime" width="120">
<template slot-scope="scope">
{{ scope.row.settlementTime || '-' }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="100">
<template slot-scope="scope">
{{ scope.row.remark || '-' }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="100" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleViewDetails(scope.row)">详情</el-button>
</template>
</el-table-column>
</el-table>
<!-- 详情弹窗 -->
<el-dialog
title="租赁费用明细详情"
:visible.sync="detailDialogVisible"
width="90%"
:close-on-click-modal="false">
<div v-if="detailDialogVisible">
<div class="detail-header">
<el-row :gutter="20">
<el-col :span="8">
<div class="detail-info">
<span class="label">协议号</span>
<span class="value">{{ selectedRowData.agreementCode }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="detail-info">
<span class="label">结算单位</span>
<span class="value">{{ selectedRowData.unitName }}</span>
</div>
</el-col>
<el-col :span="8">
<div class="detail-info">
<span class="label">结算工程</span>
<span class="value">{{ selectedRowData.projectName }}</span>
</div>
</el-col>
</el-row>
</div>
<div class="detail-operations">
<el-button type="success" icon="el-icon-download" size="mini" @click="exportDetailExcel" :disabled="detailTableList.length === 0">导出明细Excel</el-button>
</div>
<el-table v-loading="detailLoading" :data="detailTableList" border stripe max-height="400">
<el-table-column label="序号" align="center" type="index" width="60">
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="机具名称" align="center" prop="typeName" :show-overflow-tooltip="true" width="150"/>
<el-table-column label="机具规格" align="center" prop="modelName" :show-overflow-tooltip="true" width="120">
<template slot-scope="scope">
{{ scope.row.modelName || '-' }}
</template>
</el-table-column>
<el-table-column label="物资编码" align="center" prop="maCode" :show-overflow-tooltip="true" width="120">
<template slot-scope="scope">
{{ scope.row.maCode || '-' }}
</template>
</el-table-column>
<el-table-column label="租赁数量" align="center" prop="num" width="100">
<template slot-scope="scope">
{{ scope.row.num ? parseFloat(scope.row.num).toFixed(3) : '0.000' }}
</template>
</el-table-column>
<el-table-column label="单位" align="center" prop="mtUnitName" width="80"/>
<el-table-column label="租赁单价(元)" align="center" prop="leasePrice" width="120">
<template slot-scope="scope">
{{ scope.row.leasePrice ? parseFloat(scope.row.leasePrice).toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="计算开始时间" align="center" prop="calcStartTime" width="120"/>
<el-table-column label="计算结束时间" align="center" prop="calcEndTime" width="120"/>
<el-table-column label="租赁天数" align="center" prop="leaseDays" width="100"/>
<el-table-column label="租赁费用(元)" align="center" prop="leaseCost" width="120">
<template slot-scope="scope">
{{ scope.row.leaseCost ? parseFloat(scope.row.leaseCost).toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="结算状态" align="center" prop="isSettled" width="90">
<template slot-scope="scope">
<el-tag :type="scope.row.isSettled === '1' ? 'success' : 'warning'">
{{ scope.row.isSettled === '1' ? '已结算' : '未结算' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="结算时间" align="center" prop="settlementTime" width="120">
<template slot-scope="scope">
{{ scope.row.settlementTime || '-' }}
</template>
</el-table-column>
<el-table-column label="出场时间" align="center" prop="startTime" width="120">
<template slot-scope="scope">
{{ scope.row.startTime || '-' }}
</template>
</el-table-column>
<el-table-column label="退场时间" align="center" prop="endTime" width="120">
<template slot-scope="scope">
{{ scope.row.endTime || '-' }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="100">
<template slot-scope="scope">
{{ scope.row.remark || '-' }}
</template>
</el-table-column>
</el-table>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getProjectList,
getUnitList,
getAgreementInfoById,
getUnitListFilterTeam,
} from '@/api/back/index.js'
import { getLeaseCostRangeReportList, getLeaseCostDetails } from '@/api/cost/cost'
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import * as XLSX from 'xlsx';
export default {
name: 'LeaseCostRangeReportHome',
components: { Treeselect },
data() {
return {
//
loading: false,
//
showSearch: true,
//
unitList: [],
//
proList: [],
//
tableList: [],
//
queryParams: {
unitId: null,
projectId: null,
agreementCode: null,
isSettled: null,
dateRange: null,
startDate: null,
endDate: null,
},
//
detailDialogVisible: false,
detailLoading: false,
detailTableList: [],
selectedRowData: {},
detailQueryParams: {
agreementId: null,
startDate: null,
endDate: null,
},
}
},
created() {
this.initDefaultDateRange()
this.GetUnitData()
this.GetProData()
this.getList()
},
methods: {
//
initDefaultDateRange() {
const now = new Date()
const year = now.getFullYear()
const month = now.getMonth()
//
const firstDay = new Date(year, month, 1)
const firstDayStr = this.formatDate(firstDay)
//
const lastDay = new Date(year, month + 1, 0)
const lastDayStr = this.formatDate(lastDay)
this.queryParams.dateRange = [firstDayStr, lastDayStr]
this.queryParams.startDate = firstDayStr
this.queryParams.endDate = lastDayStr
},
// yyyy-MM-dd
formatDate(date) {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
},
//
handleDateRangeChange(dateRange) {
if (dateRange && dateRange.length === 2) {
this.queryParams.startDate = dateRange[0]
this.queryParams.endDate = dateRange[1]
} else {
this.queryParams.startDate = null
this.queryParams.endDate = null
}
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children,
};
},
//
async GetUnitData() {
const params = {}
const res = await getUnitListFilterTeam(params)
this.unitList = res.data;
this.getAgreementInfo()
},
unitChange(val){
setTimeout(()=>{
this.queryParams.projectId=null
this.queryParams.agreementCode = null
this.GetProData()
},500)
},
//
async GetProData() {
const params = {
unitId: this.queryParams.unitId,
}
const res = await getProjectList(params)
this.proList = res.data;
this.getAgreementInfo()
},
proChange(val){
setTimeout(()=>{
this.GetUnitData()
},500)
},
// id
async getAgreementInfo() {
if (this.queryParams.unitId && this.queryParams.projectId) {
const params = {
unitId: this.queryParams.unitId,
projectId: this.queryParams.projectId,
}
const res = await getAgreementInfoById(params)
if (!(res.data && res.data.agreementId)) {
this.$message.error('当前单位和工程无协议!')
this.queryParams.unitId = null
this.queryParams.projectId = null
this.GetUnitData()
this.GetProData()
} else {
this.queryParams.agreementCode = res.data.agreementCode
}
}
},
/** 查询列表 */
getList() {
this.loading = true
getLeaseCostRangeReportList(this.queryParams).then((response) => {
this.tableList = response.rows || []
this.loading = false
}).catch((error) => {
console.error('获取租赁费用区间报表失败:', error)
this.tableList = []
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
unitId: null,
projectId: null,
agreementCode: null,
isSettled: null,
dateRange: null,
startDate: null,
endDate: null,
}
//
this.initDefaultDateRange()
this.resetForm('queryForm')
this.handleQuery()
},
// Excel
exportExcel() {
if (!this.tableList || this.tableList.length === 0) {
this.$modal.msgWarning('没有可导出的数据');
return;
}
try {
// Excel
const columns = [
{ key: 'index', title: '序号' },
{ key: 'agreementCode', title: '协议号' },
{ key: 'unitName', title: '结算单位' },
{ key: 'projectName', title: '结算工程' },
{ key: 'isSettled', title: '结算状态' },
{ key: 'equipmentTypeCount', title: '设备类型数' },
{ key: 'totalEquipmentCount', title: '设备总数量' },
{ key: 'totalLeaseDays', title: '总租赁天数' },
{ key: 'totalLeaseCost', title: '总租赁费用(元)' },
{ key: 'avgDailyRent', title: '日均租金(元)' },
{ key: 'queryStartDate', title: '查询开始日期' },
{ key: 'queryEndDate', title: '查询结束日期' },
{ key: 'earliestLeaseTime', title: '最早租赁时间' },
{ key: 'latestReturnTime', title: '最晚归还时间' },
{ key: 'settlementTime', title: '结算时间' },
{ key: 'remark', title: '备注' }
];
// Excel
const excelData = [];
//
const headerRow = columns.map(col => col.title);
excelData.push(headerRow);
//
this.tableList.forEach((row, index) => {
const dataRow = columns.map(col => {
if (col.key === 'index') {
return index + 1;
} else if (col.key === 'isSettled') {
return row.isSettled === '1' ? '已结算' : '未结算';
} else if (col.key === 'totalEquipmentCount') {
return row.totalEquipmentCount ? parseFloat(row.totalEquipmentCount).toFixed(3) : '0.000';
} else if (col.key === 'totalLeaseCost' || col.key === 'avgDailyRent') {
return row[col.key] ? parseFloat(row[col.key]).toFixed(2) : '0.00';
} else {
return row[col.key] || '';
}
});
excelData.push(dataRow);
});
// 簿
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.aoa_to_sheet(excelData);
//
const columnWidths = [
{ wch: 8 }, //
{ wch: 18 }, //
{ wch: 20 }, //
{ wch: 25 }, //
{ wch: 10 }, //
{ wch: 12 }, //
{ wch: 12 }, //
{ wch: 12 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 12 }, //
{ wch: 20 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '租赁费用区间报表');
//
let fileName = '租赁费用区间报表';
if (this.queryParams.startDate && this.queryParams.endDate) {
fileName += `_${this.queryParams.startDate}_至_${this.queryParams.endDate}`;
}
fileName += `_${new Date().toISOString().slice(0, 10)}.xlsx`;
// Excel
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
//
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', fileName);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// URL
URL.revokeObjectURL(url);
this.$modal.msgSuccess('Excel导出成功');
} catch (error) {
console.error('导出Excel失败:', error);
this.$modal.msgError('导出Excel失败请稍后重试');
}
},
/** 查看详情 */
handleViewDetails(row) {
this.selectedRowData = row
this.detailQueryParams = {
agreementId: row.agreementId,
startDate: this.queryParams.startDate,
endDate: this.queryParams.endDate,
}
this.detailDialogVisible = true
this.getDetailList()
},
/** 获取详情列表 */
getDetailList() {
this.detailLoading = true
getLeaseCostDetails(this.detailQueryParams).then((response) => {
this.detailTableList = response.rows || []
this.detailLoading = false
}).catch((error) => {
console.error('获取租赁费用明细失败:', error)
this.detailTableList = []
this.detailLoading = false
})
},
/** 导出详情Excel */
exportDetailExcel() {
if (!this.detailTableList || this.detailTableList.length === 0) {
this.$modal.msgWarning('没有可导出的详情数据');
return;
}
try {
// Excel
const columns = [
{ key: 'index', title: '序号' },
{ key: 'agreementCode', title: '协议号' },
{ key: 'typeName', title: '机具名称' },
{ key: 'modelName', title: '机具规格' },
{ key: 'maCode', title: '物资编码' },
{ key: 'num', title: '租赁数量' },
{ key: 'mtUnitName', title: '单位' },
{ key: 'leasePrice', title: '租赁单价(元)' },
{ key: 'calcStartTime', title: '计算开始时间' },
{ key: 'calcEndTime', title: '计算结束时间' },
{ key: 'leaseDays', title: '租赁天数' },
{ key: 'leaseCost', title: '租赁费用(元)' },
{ key: 'isSettled', title: '结算状态' },
{ key: 'settlementTime', title: '结算时间' },
{ key: 'startTime', title: '出场时间' },
{ key: 'endTime', title: '退场时间' },
{ key: 'remark', title: '备注' }
];
// Excel
const excelData = [];
//
const headerRow = columns.map(col => col.title);
excelData.push(headerRow);
//
this.detailTableList.forEach((row, index) => {
const dataRow = columns.map(col => {
if (col.key === 'index') {
return index + 1;
} else if (col.key === 'isSettled') {
return row.isSettled === '1' ? '已结算' : '未结算';
} else if (col.key === 'num') {
return row.num ? parseFloat(row.num).toFixed(3) : '0.000';
} else if (col.key === 'leasePrice' || col.key === 'leaseCost') {
return row[col.key] ? parseFloat(row[col.key]).toFixed(2) : '0.00';
} else {
return row[col.key] || '';
}
});
excelData.push(dataRow);
});
// 簿
const workbook = XLSX.utils.book_new();
const worksheet = XLSX.utils.aoa_to_sheet(excelData);
//
const columnWidths = [
{ wch: 8 }, //
{ wch: 18 }, //
{ wch: 20 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 12 }, //
{ wch: 8 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 10 }, //
{ wch: 15 }, //
{ wch: 10 }, //
{ wch: 15 }, //
{ wch: 15 }, //
{ wch: 15 }, // 退
{ wch: 20 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '租赁费用明细');
//
let fileName = `租赁费用明细_${this.selectedRowData.agreementCode}`;
if (this.detailQueryParams.startDate && this.detailQueryParams.endDate) {
fileName += `_${this.detailQueryParams.startDate}_至_${this.detailQueryParams.endDate}`;
}
fileName += `_${new Date().toISOString().slice(0, 10)}.xlsx`;
// Excel
const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
const blob = new Blob([excelBuffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
//
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', fileName);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// URL
URL.revokeObjectURL(url);
this.$modal.msgSuccess('详情Excel导出成功');
} catch (error) {
console.error('导出详情Excel失败:', error);
this.$modal.msgError('导出详情Excel失败请稍后重试');
}
},
},
}
</script>
<style lang="scss" scoped>
::v-deep.el-table .fixed-width .el-button--mini {
width: 80px !important;
margin-bottom: 10px;
}
.detail-header {
background-color: #f5f7fa;
padding: 15px;
border-radius: 4px;
margin-bottom: 15px;
.detail-info {
margin-bottom: 10px;
.label {
font-weight: bold;
color: #606266;
}
.value {
color: #303133;
margin-left: 5px;
}
}
}
.detail-operations {
margin-bottom: 15px;
text-align: right;
}
</style>

View File

@ -0,0 +1,22 @@
<template>
<div class="app-container">
<LeaseCostRangeReportHome />
</div>
</template>
<script>
import LeaseCostRangeReportHome from './component/leaseCostRangeReportHome.vue'
export default {
name: 'LeaseCostRangeReportList',
components: {
LeaseCostRangeReportHome
}
}
</script>
<style lang="scss" scoped>
.app-container {
padding: 20px;
}
</style>