维修丢失报表

This commit is contained in:
syruan 2025-08-29 18:06:56 +08:00
parent ab1514ac95
commit 79b064b554
8 changed files with 1237 additions and 7 deletions

View File

@ -211,6 +211,33 @@ export function getClzAgreementInfoById(data) {
})
}
// 查询丢失费用报表列表
export function getLostReportList(query) {
return request({
url: '/material/slt_agreement_info/getLostReportList',
method: 'get',
params: query
})
}
// 查询维修费用报表列表
export function getRepairReportList(query) {
return request({
url: '/material/slt_agreement_info/getRepairReportList',
method: 'get',
params: query
})
}
// 查询报废费用报表列表
export function getScrapReportList(query) {
return request({
url: '/material/slt_agreement_info/getScrapReportList',
method: 'get',
params: query
})
}

View File

@ -57,7 +57,7 @@
<el-table-column label="计量单位" align="center" prop="mtUnitName" :show-overflow-tooltip="true"/>
<el-table-column label="租赁单价" align="center" prop="leasePrice" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.leasePrice">
{{ scope.row.leasePrice.toFixed(2) }}
{{ scope.row.leasePrice.toFixed(3) }}
</template>
</el-table-column>
<el-table-column label="租赁数量" align="center" prop="num" :show-overflow-tooltip="true">
@ -75,7 +75,7 @@
</el-table-column>
<el-table-column label="租赁费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.costs">
{{ scope.row.costs.toFixed(2) }}
{{ scope.row.costs.toFixed(3) }}
</template>
</el-table-column>
</el-table-column>
@ -104,7 +104,7 @@
<el-table-column label="是否收费" align="center" prop="partType" :show-overflow-tooltip="true"/>
<el-table-column label="维修费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.costs" >
{{ scope.row.costs.toFixed(2) }}
{{ scope.row.costs.toFixed(3) }}
</template>
</el-table-column>
</el-table-column>
@ -131,7 +131,7 @@
</el-table-column>
<el-table-column label="丢失费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.costs">
{{ scope.row.costs.toFixed(2) }}
{{ scope.row.costs.toFixed(3) }}
</template>
</el-table-column>
</el-table-column>
@ -159,7 +159,7 @@
<el-table-column label="是否收费" align="center" prop="partType" :show-overflow-tooltip="true"/>
<el-table-column label="报废费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.costs">
{{ scope.row.costs.toFixed(2) }}
{{ scope.row.costs.toFixed(3) }}
</template>
</el-table-column>
</el-table-column>
@ -187,7 +187,7 @@
<el-table-column label="减免原因" align="center" prop="remark" :show-overflow-tooltip="true"/>
<el-table-column label="减免费用(元)" align="center" prop="leaseMoney" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.leaseMoney">
{{ scope.row.leaseMoney.toFixed(2) }}
{{ scope.row.leaseMoney.toFixed(3) }}
</template>
</el-table-column>
</el-table-column>
@ -273,7 +273,7 @@ export default {
console.log('📋 row 数据为空,跳过初始化');
return;
}
console.log('📋 开始初始化数据row:', this.row);
let arr = JSON.parse(this.row)
console.log('📋 解析后的数据:', arr);

View File

@ -0,0 +1,381 @@
<template>
<div class="app-container" id="lostReportList">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item prop="unitIds">
<treeselect
v-model="queryParams.unitId"
:options="unitList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择结算单位" @select="unitChange"
/>
</el-form-item>
<el-form-item prop="projectIds">
<treeselect
v-model="queryParams.projectId"
:options="proList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择结算工程" @select="proChange"
/>
</el-form-item>
<el-form-item prop="agreementCode">
<el-input v-model="queryParams.agreementCode" placeholder="请输入协议号" clearable/>
</el-form-item>
<el-form-item 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>
<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>{{
(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
}}</span>
</template>
</el-table-column>
<el-table-column label="协议号" align="center" prop="agreementCode" :show-overflow-tooltip="true"/>
<el-table-column label="结算单位" align="center" prop="unitName" />
<el-table-column label="结算工程" align="center" prop="projectName" />
<el-table-column label="机具名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="center" prop="modelName" :show-overflow-tooltip="true" />
<el-table-column label="单位" align="center" prop="mtUnitName" width="80" />
<el-table-column label="丢失数量" align="center" prop="num" width="100" />
<el-table-column label="单价(元)" align="center" prop="buyPrice" width="120">
<template slot-scope="scope">
{{ scope.row.buyPrice ? scope.row.buyPrice.toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="丢失费用(元)" align="center" prop="cost" width="120">
<template slot-scope="scope">
{{ (scope.row.buyPrice * scope.row.num).toFixed(3) }}
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import {
getProjectList,
getUnitList,
getAgreementInfoById,
getUnitListFilterTeam,
} from '@/api/back/index.js'
import { getLostReportList } 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: 'LostReportHome',
components: { Treeselect },
data() {
return {
//
loading: false,
//
showSearch: true,
//
total: 0,
//
unitList: [],
//
proList: [],
//
tableList: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
unitId: null,
projectId: null,
agreementCode: null,
dateRange: null,
startTime: null,
endTime: 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.startTime = firstDayStr
this.queryParams.endTime = 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.startTime = dateRange[0]
this.queryParams.endTime = dateRange[1]
} else {
this.queryParams.startTime = null
this.queryParams.endTime = 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
getLostReportList(this.queryParams).then((response) => {
this.tableList = response.rows || []
this.total = response.total
this.loading = false
}).catch((error) => {
console.error('获取丢失费用报表失败:', error)
this.tableList = []
this.total = 0
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
unitId: null,
projectId: null,
agreementCode: null,
dateRange: null,
startTime: null,
endTime: 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: 'typeName', title: '机具名称' },
{ key: 'modelName', title: '规格型号' },
{ key: 'mtUnitName', title: '单位' },
{ key: 'num', title: '丢失数量' },
{ key: 'buyPrice', title: '单价(元)' },
{ key: 'cost', 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 (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
} else if (col.key === 'buyPrice') {
//
return row.buyPrice ? parseFloat(row.buyPrice.toFixed(2)) : 0.00;
} else if (col.key === 'cost') {
// buyPrice * num
const cost = (row.buyPrice || 0) * (row.num || 0);
return parseFloat(cost.toFixed(3));
} 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: 20 }, //
{ wch: 15 }, //
{ wch: 20 }, //
{ wch: 20 }, //
{ wch: 15 }, //
{ wch: 8 }, //
{ wch: 10 }, //
{ wch: 12 }, //
{ wch: 15 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '丢失费用报表');
//
let fileName = '丢失费用报表';
if (this.queryParams.startTime && this.queryParams.endTime) {
fileName += `_${this.queryParams.startTime}_至_${this.queryParams.endTime}`;
}
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;
}
</style>

View File

@ -0,0 +1,379 @@
<template>
<div class="app-container" id="repairReportList">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item prop="unitIds">
<treeselect
v-model="queryParams.unitId"
:options="unitList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择结算单位" @select="unitChange"
/>
</el-form-item>
<el-form-item prop="projectIds">
<treeselect
v-model="queryParams.projectId"
:options="proList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择结算工程" @select="proChange"
/>
</el-form-item>
<el-form-item prop="agreementCode">
<el-input v-model="queryParams.agreementCode" placeholder="请输入协议号" clearable/>
</el-form-item>
<el-form-item 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>
<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>{{
(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
}}</span>
</template>
</el-table-column>
<el-table-column label="协议号" align="center" prop="agreementCode" :show-overflow-tooltip="true"/>
<el-table-column label="结算单位" align="center" prop="unitName" />
<el-table-column label="结算工程" align="center" prop="projectName" />
<el-table-column label="机具名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="center" prop="modelName" :show-overflow-tooltip="true" />
<el-table-column label="单位" align="center" prop="mtUnitName" width="80" />
<el-table-column label="维修数量" align="center" prop="num" width="100" />
<el-table-column label="维修费用(元)" align="center" prop="cost" width="120">
<template slot-scope="scope">
{{ scope.row.costs ? scope.row.costs.toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="维修方式" align="center" prop="repairType" width="120" />
<el-table-column label="费用类型" align="center" prop="partType" width="120" />
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="50" />
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import {
getProjectList,
getUnitList,
getAgreementInfoById,
getUnitListFilterTeam,
} from '@/api/back/index.js'
import { getRepairReportList } 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: 'RepairReportHome',
components: { Treeselect },
data() {
return {
//
loading: false,
//
showSearch: true,
//
total: 0,
//
unitList: [],
//
proList: [],
//
tableList: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
unitId: null,
projectId: null,
agreementCode: null,
dateRange: null,
startTime: null,
endTime: 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.startTime = firstDayStr
this.queryParams.endTime = 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.startTime = dateRange[0]
this.queryParams.endTime = dateRange[1]
} else {
this.queryParams.startTime = null
this.queryParams.endTime = 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
getRepairReportList(this.queryParams).then((response) => {
this.tableList = response.rows || []
this.total = response.total
this.loading = false
}).catch((error) => {
console.error('获取维修费用报表失败:', error)
this.tableList = []
this.total = 0
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
unitId: null,
projectId: null,
agreementCode: null,
dateRange: null,
startTime: null,
endTime: 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: 'typeName', title: '机具名称' },
{ key: 'modelName', title: '规格型号' },
{ key: 'mtUnitName', title: '单位' },
{ key: 'num', title: '维修数量' },
{ key: 'cost', title: '维修费用(元)' },
{ key: 'repairDate', title: '维修日期' },
{ key: 'createTime', 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 (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
} else if (col.key === 'cost') {
//
return row.cost ? parseFloat(row.cost.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: 20 }, //
{ wch: 15 }, //
{ wch: 20 }, //
{ wch: 20 }, //
{ wch: 15 }, //
{ wch: 8 }, //
{ wch: 10 }, //
{ wch: 15 }, //
{ wch: 12 }, //
{ wch: 15 }, //
{ wch: 20 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '维修费用报表');
//
let fileName = '维修费用报表';
if (this.queryParams.startTime && this.queryParams.endTime) {
fileName += `_${this.queryParams.startTime}_至_${this.queryParams.endTime}`;
}
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;
}
</style>

View File

@ -0,0 +1,377 @@
<template>
<div class="app-container" id="scrapReportList">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item prop="unitIds">
<treeselect
v-model="queryParams.unitId"
:options="unitList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择结算单位" @select="unitChange"
/>
</el-form-item>
<el-form-item prop="projectIds">
<treeselect
v-model="queryParams.projectId"
:options="proList" :normalizer="normalizer"
:show-count="true" style="width: 240px" :disable-branch-nodes="true"
noChildrenText="没有数据了" noOptionsText="没有数据" noResultsText="没有搜索结果"
placeholder="请选择结算工程" @select="proChange"
/>
</el-form-item>
<el-form-item prop="agreementCode">
<el-input v-model="queryParams.agreementCode" placeholder="请输入协议号" clearable/>
</el-form-item>
<el-form-item 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>
<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>{{
(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
}}</span>
</template>
</el-table-column>
<el-table-column label="协议号" align="center" prop="agreementCode" :show-overflow-tooltip="true"/>
<el-table-column label="结算单位" align="center" prop="unitName" />
<el-table-column label="结算工程" align="center" prop="projectName" />
<el-table-column label="机具名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="机具规格" align="center" prop="modelName" :show-overflow-tooltip="true" />
<el-table-column label="单位" align="center" prop="mtUnitName" width="80" />
<el-table-column label="报废数量" align="center" prop="num" width="100" />
<el-table-column label="报废费用(元)" align="center" prop="cost" width="120">
<template slot-scope="scope">
{{ scope.row.cost ? scope.row.cost.toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" min-width="50" />
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
</template>
<script>
import {
getProjectList,
getUnitList,
getAgreementInfoById,
getUnitListFilterTeam,
} from '@/api/back/index.js'
import { getScrapReportList } 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: 'ScrapReportHome',
components: { Treeselect },
data() {
return {
//
loading: false,
//
showSearch: true,
//
total: 0,
//
unitList: [],
//
proList: [],
//
tableList: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
unitId: null,
projectId: null,
agreementCode: null,
dateRange: null,
startTime: null,
endTime: 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.startTime = firstDayStr
this.queryParams.endTime = 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.startTime = dateRange[0]
this.queryParams.endTime = dateRange[1]
} else {
this.queryParams.startTime = null
this.queryParams.endTime = 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
getScrapReportList(this.queryParams).then((response) => {
this.tableList = response.rows || []
this.total = response.total
this.loading = false
}).catch((error) => {
console.error('获取报废费用报表失败:', error)
this.tableList = []
this.total = 0
this.loading = false
})
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
unitId: null,
projectId: null,
agreementCode: null,
dateRange: null,
startTime: null,
endTime: 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: 'typeName', title: '机具名称' },
{ key: 'modelName', title: '机具规格' },
{ key: 'mtUnitName', title: '单位' },
{ key: 'num', title: '报废数量' },
{ key: 'cost', title: '报废费用(元)' },
{ key: 'scrapDate', title: '报废日期' },
{ key: 'createTime', 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 (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
} else if (col.key === 'cost') {
//
return row.cost ? parseFloat(row.cost.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: 20 }, //
{ wch: 15 }, //
{ wch: 20 }, //
{ wch: 20 }, //
{ wch: 15 }, //
{ wch: 8 }, //
{ wch: 10 }, //
{ wch: 15 }, //
{ wch: 12 }, //
{ wch: 15 }, //
{ wch: 20 } //
];
worksheet['!cols'] = columnWidths;
// 簿
XLSX.utils.book_append_sheet(workbook, worksheet, '报废费用报表');
//
let fileName = '报废费用报表';
if (this.queryParams.startTime && this.queryParams.endTime) {
fileName += `_${this.queryParams.startTime}_至_${this.queryParams.endTime}`;
}
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;
}
</style>

View File

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

View File

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

View File

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