结算修改

This commit is contained in:
syruan 2025-10-10 12:11:00 +08:00
parent 8ba43c268d
commit 9b71da35f5
6 changed files with 977 additions and 47 deletions

View File

@ -36,6 +36,15 @@ export function getSltInfo(params){
})
}
// 查询材料站结算待审核详情(仅需 sltApplyCode
export function getClzSettledInfo(sltApplyCode) {
return request({
url: '/material/material_sltAgreementInfo/getSettledInfo',
method: 'get',
params: { sltApplyCode }
})
}
// 查询材料站费用结算申请详情
export function getClzSltInfo(params){
return request({
@ -119,6 +128,15 @@ export function getSltList(query) {
})
}
// 查询材料站的结算审批列表
export function getClzSltList(query) {
return request({
url: '/material/material_sltAgreementInfo/getSltList',
method: 'get',
params: query
})
}
// 查询已结算报表列表
export function getSltReportedList(params){
return request({
@ -137,6 +155,15 @@ export function costExamine(params){
})
}
// 材料站结算审批提交
export function clzCostExamine(params){
return request({
url: '/material/material_sltAgreementInfo/costExamine',
method: 'post',
data: params
})
}
// 查询减免费用列表
export function getReliefList(query) {
return request({

View File

@ -93,6 +93,20 @@ export const constantRoutes = [
meta: { title: '个人中心', icon: 'user' }
}
]
},
// 新增结算
{
path: '/settlement',
component: Layout,
hidden: true,
children: [
{
path: 'add',
name: 'SettlementAdd',
meta: { title: '新增结算' },
component: () => import('@/views/settlement/add.vue')
}
]
}
]

View File

@ -56,6 +56,7 @@
<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="primary" plain size="mini" @click="handleApplyList">批量结算</el-button>
<el-button type="success" icon="el-icon-plus" size="mini" @click="goToSettlement">新增结算</el-button>
</el-form-item>
</el-form>
@ -88,8 +89,10 @@
<el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
style="display: none"
disabled="disabled"
size="mini"
type="primary"
type="hi"
icon="el-icon-edit"
@click="handleApply(scope.row)"
v-if="scope.row.sltStatus == '0' || scope.row.sltStatus == '3'"
@ -199,7 +202,7 @@
<script>
import { getUnitList } from '@/api/back/index.js'
import { getTeamList } from '@/api/materialsStation/auth.js'
import { getSltAgreementInfo, getClzSltAgreementInfo, getProjectListByUnitIds, getClzProjectListByUnitIds, getAgreementInfoById, getClzAgreementInfoById, getSltInfo } from '@/api/cost/cost'
import { getClzSltAgreementInfo, getClzProjectListByUnitIds, getClzAgreementInfoById, getSltInfo } from '@/api/cost/cost'
import { toChineseAmount } from '@/utils/bonus.js'
import vueEasyPrint from 'vue-easy-print'
import Treeselect from '@riophae/vue-treeselect'
@ -432,6 +435,10 @@ export default {
// maxWidth:'1400'
// //
// });
},
/** 新增结算按钮操作 */
goToSettlement() {
this.$router.push('/settlement/add')
}
}
}

View File

@ -35,24 +35,24 @@
<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">
{{ scope.row.leasePrice.toFixed(2) }}
{{ Number(scope.row.leasePrice || 0).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="租赁数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.num.toFixed(2) }}
{{ Number(scope.row.num || 0).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="租赁日期" align="center" prop="startTime" :show-overflow-tooltip="true" />
<el-table-column label="归还日期 " align="center" prop="endTime" :show-overflow-tooltip="true" />
<el-table-column label="租赁天数" align="center" prop="leaseDays" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ Number(scope.row.leaseDays).toFixed(2) }}
{{ Number(scope.row.leaseDays || 0).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="租赁费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.costs.toFixed(2) }}
{{ Number(scope.row.costs || 0).toFixed(2) }}
</template>
</el-table-column>
</el-table-column>
@ -75,13 +75,13 @@
<el-table-column label="计量单位" align="center" prop="mtUnitName" :show-overflow-tooltip="true" />
<el-table-column label="维修数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.num.toFixed(2) }}
{{ Number(scope.row.num || 0).toFixed(2) }}
</template>
</el-table-column>
<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">
{{ scope.row.costs.toFixed(2) }}
{{ Number(scope.row.costs || 0).toFixed(2) }}
</template>
</el-table-column>
</el-table-column>
@ -103,13 +103,13 @@
<el-table-column label="计量单位" align="center" prop="mtUnitName" :show-overflow-tooltip="true" />
<el-table-column label="报废数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.num.toFixed(2) }}
{{ Number(scope.row.num || 0).toFixed(2) }}
</template>
</el-table-column>
<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">
{{ scope.row.costs.toFixed(2) }}
{{ Number(scope.row.costs || 0).toFixed(2) }}
</template>
</el-table-column>
</el-table-column>
@ -131,12 +131,12 @@
<el-table-column label="计量单位" align="center" prop="mtUnitName" :show-overflow-tooltip="true" />
<el-table-column label="丢失数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.num.toFixed(2) }}
{{ Number(scope.row.num || 0).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="丢失费用(元)" align="center" prop="costs" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.costs.toFixed(2) }}
{{ Number(scope.row.costs || 0).toFixed(2) }}
</template>
</el-table-column>
</el-table-column>
@ -163,8 +163,8 @@
<el-table-column label="减免天数" align="center" prop="days" :show-overflow-tooltip="true" />
<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-if="scope.row.leaseMoney">
{{ scope.row.leaseMoney.toFixed(2) }}
<template slot-scope="scope">
{{ Number(scope.row.leaseMoney || 0).toFixed(2) }}
</template>
</el-table-column>
</el-table-column>
@ -186,7 +186,7 @@
</template>
<script>
import { getSltInfo } from '@/api/cost/cost'
import { getSltInfo, getClzSettledInfo } from '@/api/cost/cost'
export default {
name: '',
@ -239,31 +239,74 @@ export default {
},
/** 查询列表 */
getDataAll() {
getSltInfo(this.rowData).then(response => {
this.leaseList = response.data.leaseList //
this.projectName = response.data.projectName
this.unitName = response.data.unitName
// code sltApplyCode
const code = Array.isArray(this.rowData)
? (this.rowData[0]?.sltApplyCode || this.rowData[0]?.code)
: (this.rowData?.sltApplyCode || this.rowData?.code)
getClzSettledInfo(code).then(response => {
const dataArray = Array.isArray(response.data) ? response.data : [response.data]
//
this.leaseList = []
this.repairList = []
this.scrapList = []
this.loseList = []
this.reducList = []
this.reducCost = 0
const projectNames = []
const unitNames = []
// 便
dataArray.forEach(item => {
if (!item) return
const currentUnitName = item.unitName || ''
const currentProjectName = item.projectName || ''
if (currentUnitName) unitNames.push(currentUnitName)
if (currentProjectName) projectNames.push(currentProjectName)
if (Array.isArray(item.leaseList) && item.leaseList.length) {
const listWithUnit = item.leaseList.map(x => ({ ...x, unitName: x.unitName || currentUnitName }))
this.leaseList = [...this.leaseList, ...listWithUnit]
}
if (Array.isArray(item.repairList) && item.repairList.length) {
const listWithUnit = item.repairList.map(x => ({ ...x, unitName: x.unitName || currentUnitName }))
this.repairList = [...this.repairList, ...listWithUnit]
}
if (Array.isArray(item.scrapList) && item.scrapList.length) {
const listWithUnit = item.scrapList.map(x => ({ ...x, unitName: x.unitName || currentUnitName }))
this.scrapList = [...this.scrapList, ...listWithUnit]
}
if (Array.isArray(item.loseList) && item.loseList.length) {
const listWithUnit = item.loseList.map(x => ({ ...x, unitName: x.unitName || currentUnitName }))
this.loseList = [...this.loseList, ...listWithUnit]
}
if (Array.isArray(item.reductionList) && item.reductionList.length) {
const listWithUnit = item.reductionList.map(x => ({ ...x, unitName: x.unitName || currentUnitName }))
this.reducList = [...this.reducList, ...listWithUnit]
}
})
// /
const unique = arr => Array.from(new Set(arr)).filter(Boolean)
this.unitName = unique(unitNames).join('')
this.projectName = unique(projectNames).join('')
//
const sumCosts = list => list.reduce((s, x) => s + (Number(x.costs) || 0), 0)
this.leaseCost = this.countCost(this.leaseList)
this.repairList = response.data.repairList //
this.repairCost = response.data.repairCost.toFixed(2)
// this.repairCost = this.countCost(this.repairList)
this.scrapList = response.data.scrapList //
this.scrapCost = response.data.scrapCost.toFixed(2)
// this.scrapCost = this.countCost(this.scrapList)
this.loseList = response.data.loseList //
this.loseCost = this.countCost(this.loseList)
this.reducList = response.data.reductionList //
console.log('111111111111111111', this.reducList)
if (this.reducList != null) {
this.reducList.forEach(item => {
this.reducCost = Number(this.reducCost) + Number(item.leaseMoney)
this.repairCost = sumCosts(this.repairList).toFixed(2)
this.scrapCost = sumCosts(this.scrapList).toFixed(2)
if (this.reducList && this.reducList.length) {
this.reducList.forEach(x => {
this.reducCost = Number(this.reducCost) + Number(x.leaseMoney || 0)
})
}
this.applyList = response.data.relations
// relations
this.applyList = (dataArray[0] && Array.isArray(dataArray[0].relations)) ? dataArray[0].relations : []
this.applyList.forEach(item => {
item.leaseCost = Number(item.leaseCost)
item.repairCost = Number(item.repairCost)
@ -279,7 +322,7 @@ export default {
Number(item.subCost)
})
let costSum =
const costSum =
Number(this.leaseCost) +
Number(this.repairCost) +
Number(this.scrapCost) +
@ -293,14 +336,10 @@ export default {
countCost(list) {
let arrCost = 0
list.forEach(item => {
// arrCost += parseInt(item.costs)
console.log(item)
if (item.partType != 0 && item.scrapType != 0) {
arrCost = arrCost + Number(item.costs)
}
// costs null
const costs = Number(item.costs || 0)
arrCost = arrCost + costs
})
return arrCost.toFixed(2)
},
//el-table-

View File

@ -209,7 +209,7 @@
<script>
import { getProjectList, getUnitList, getAgreementInfoById } from '@/api/back/index.js'
import { getSltList, costExamine, getSltInfo } from '@/api/cost/cost'
import {getClzSltList, costExamine, getSltInfo, getClzSettledInfo, clzCostExamine} from '@/api/cost/cost'
import { toChineseAmount } from '@/utils/bonus.js'
import vueEasyPrint from 'vue-easy-print'
import Treeselect from '@riophae/vue-treeselect'
@ -355,7 +355,7 @@ export default {
/** 查询列表 */
getList() {
this.loading = true
getSltList(this.queryParams).then(response => {
getClzSltList(this.queryParams).then(response => {
this.tableList = response.rows
this.total = response.total
this.loading = false
@ -390,6 +390,8 @@ export default {
},
//
handleExame(row) {
console.log(row)
this.sltApplyCode = row.sltApplyCode
this.id = row.id
this.agreementIdTemp = row.agreementId
this.applyVisible = true
@ -400,9 +402,10 @@ export default {
id: this.id,
status: this.aform.status,
remark: this.aform.remark,
agreementId: this.agreementIdTemp
agreementId: this.agreementIdTemp,
code: this.sltApplyCode,
}
costExamine(param)
clzCostExamine(param)
.then(res => {
if (res.code == 200) {
this.$modal.msgSuccess('审批成功')

View File

@ -0,0 +1,840 @@
<template>
<div class="app-container">
<!-- 操作栏 -->
<div class="operation-bar">
<el-form :inline="true" label-width="80px" style="margin-bottom: 20px;">
<el-form-item label="结算班组">
<treeselect
v-model="selectedTeams"
:options="teamList"
:normalizer="normalizer"
:show-count="true"
style="width: 300px"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择结算班组"
:multiple="true"
></treeselect>
</el-form-item>
<el-form-item label="结算工程">
<treeselect
v-model="selectedProject"
:options="projectList"
:normalizer="normalizer"
:show-count="true"
style="width: 300px"
:disable-branch-nodes="true"
noChildrenText="没有数据了"
noOptionsText="没有数据"
noResultsText="没有搜索结果"
placeholder="请选择结算工程"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery" :loading="loading">查询</el-button>
<el-button @click="reset">重置</el-button>
<el-button @click="goBack">返回</el-button>
</el-form-item>
</el-form>
</div>
<!-- 结算数据展示 -->
<div>
<el-row style="width: 100%">
<el-col :span="18">
<el-button type="primary" size="mini" @click="handleExport1" :disabled="!hasData">租赁明细导出</el-button>
<el-button type="primary" size="mini" @click="handleExport3" :disabled="!hasData">维修明细导出</el-button>
<el-button type="primary" size="mini" @click="handleExport4" :disabled="!hasData">报废明细导出</el-button>
<el-button type="primary" size="mini" @click="handleExport2" :disabled="!hasData">丢失明细导出</el-button>
<el-button type="primary" size="mini" @click="handleExport5" :disabled="!hasData">减免明细导出</el-button>
<el-button type="warning" size="mini" @click="handleExportAll" :disabled="!hasData">全部明细导出</el-button>
<el-button type="warning" size="mini" @click="handleExportEach" :disabled="!hasData">各结算明细导出</el-button>
<el-button type="success" size="mini" @click="handleAdd" :disabled="!hasData">提交</el-button>
</el-col>
</el-row>
<div style="margin-top: 20px">
<div class="tabelAllTop">
<div class="costTop">结算费用</div>
</div>
<div class="tabelAllTopUnit">
<div class="costTopUnit">结算班组</div>
<div class="costRightUnit">
{{ unitName || '请先选择班组并查询' }}
</div>
</div>
<div class="tabelAllTopUnit">
<div class="costTopUnit">结算工程</div>
<div class="costRightUnit">
{{ projectName || '请先选择工程并查询' }}
</div>
</div>
<!-- 租赁费用明细 -->
<el-table :data="leaseList">
<el-table-column label="租赁费用明细" align="center">
<el-table-column label="序号" align="center" type="index" width="60" />
<el-table-column label="单位名称" align="center" prop="unitName" :show-overflow-tooltip="true" width="150" />
<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" :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) }}
</template>
</el-table-column>
<el-table-column label="租赁数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.num">
{{ scope.row.num.toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="租赁日期" align="center" prop="startTime" :show-overflow-tooltip="true" />
<el-table-column label="归还日期 " align="center" prop="endTime" :show-overflow-tooltip="true" />
<el-table-column label="租赁天数" align="center" prop="leaseDays" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.leaseDays">
{{ Number(scope.row.leaseDays).toFixed(2) }}
</template>
</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) }}
</template>
</el-table-column>
</el-table-column>
</el-table>
<div class="tabelAll">
<div class="columnAllNum">费用小计</div>
<div class="columnAll">
{{ leaseCost || '0.00' }}
</div>
</div>
</div>
<!-- 维修费用明细 -->
<div>
<el-table :data="repairList">
<el-table-column label="维修费用明细" align="center">
<el-table-column label="序号" align="center" type="index" width="60" />
<el-table-column label="单位名称" align="center" prop="unitName" :show-overflow-tooltip="true" width="150" />
<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" :show-overflow-tooltip="true" />
<el-table-column label="维修数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.num">
{{ scope.row.num.toFixed(2) }}
</template>
</el-table-column>
<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) }}
</template>
</el-table-column>
</el-table-column>
</el-table>
<div class="tabelAll">
<div class="columnAllNum">费用小计</div>
<div class="columnAll">
{{ repairCost || '0.00' }}
</div>
</div>
</div>
<!-- 报废费用明细 -->
<div>
<el-table :data="scrapList">
<el-table-column label="报废费用明细" align="center">
<el-table-column label="序号" align="center" type="index" width="60" />
<el-table-column label="单位名称" align="center" prop="unitName" :show-overflow-tooltip="true" width="150" />
<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" :show-overflow-tooltip="true" />
<el-table-column label="报废数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.num">
{{ scope.row.num.toFixed(2) }}
</template>
</el-table-column>
<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) }}
</template>
</el-table-column>
</el-table-column>
</el-table>
<div class="tabelAll">
<div class="columnAllNum">费用小计</div>
<div class="columnAll">
{{ scrapCost || '0.00' }}
</div>
</div>
</div>
<!-- 丢失费用明细 -->
<div>
<el-table :data="loseList">
<el-table-column label="丢失费用明细" align="center">
<el-table-column label="序号" align="center" type="index" width="60" />
<el-table-column label="单位名称" align="center" prop="unitName" :show-overflow-tooltip="true" width="150" />
<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" :show-overflow-tooltip="true" />
<el-table-column label="丢失数量" align="center" prop="num" :show-overflow-tooltip="true">
<template slot-scope="scope" v-show="scope.row.num">
{{ scope.row.num.toFixed(2) }}
</template>
</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) }}
</template>
</el-table-column>
</el-table-column>
</el-table>
<div class="tabelAll">
<div class="columnAllNum">费用小计</div>
<div class="columnAll">
{{ loseCost || '0.00' }}
</div>
</div>
</div>
<!-- 减免费用明细 -->
<div>
<el-table :data="reducList">
<el-table-column label="减免费用明细" align="center">
<el-table-column label="序号" align="center" type="index" width="60" />
<el-table-column label="单位名称" align="center" prop="unitName" :show-overflow-tooltip="true" width="150" />
<el-table-column label="设备名称" align="center" prop="typeName" :show-overflow-tooltip="true" />
<el-table-column label="规格型号" align="center" prop="modeName" :show-overflow-tooltip="true" />
<el-table-column label="计量单位" align="center" prop="mtUnitName" :show-overflow-tooltip="true" />
<el-table-column label="租赁单价" align="center" prop="leasePrice" :show-overflow-tooltip="true" />
<el-table-column label="减免数量" align="center" prop="reduceNum" :show-overflow-tooltip="true" />
<el-table-column label="减免开始日期" align="center" prop="startTime" :show-overflow-tooltip="true" />
<el-table-column label="减免结束日期" align="center" prop="endTime" :show-overflow-tooltip="true" />
<el-table-column label="减免天数" align="center" prop="days" :show-overflow-tooltip="true" />
<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) }}
</template>
</el-table-column>
</el-table-column>
</el-table>
<div class="tabelAllBottom">
<div class="columnAllNum">费用小计</div>
<div class="columnAll">
{{ reducCost || '0.00' }}
</div>
</div>
<div class="tabelAllBottom">
<div class="columnAllNum">合计</div>
<div class="columnAll">
{{ costAll ? costAll.toFixed(2) : '0.00' }}
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { getClzSltInfo, submitClzCosts } from '@/api/cost/cost'
import { getUnitList, getProjectList } from '@/api/back/index.js'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
name: 'SettlementAdd',
components: {
Treeselect
},
data() {
return {
loading: false,
hasQueried: false,
selectedTeams: [],
selectedProject: '',
teamList: [],
projectList: [],
leaseList: [], //
leaseCost: 0,
repairList: [], //
repairCost: 0,
scrapList: [], //
scrapCost: 0,
loseList: [], //
loseCost: 0,
reducList: [], //
reducCost: 0,
costAll: 0,
applyList: [],
projectName: '', //
unitName: '', //
rowData: []
}
},
computed: {
hasData() {
return this.leaseList.length > 0 || this.repairList.length > 0 ||
this.scrapList.length > 0 || this.loseList.length > 0 || this.reducList.length > 0
}
},
async created() {
await this.loadTeamList()
await this.loadProjectList()
},
methods: {
normalizer(node) {
return {
id: node.id,
label: node.label || node.name,
children: node.children
}
},
async loadTeamList() {
try {
const response = await getUnitList({})
if (response.code === 200) {
this.teamList = response.data || []
}
} catch (error) {
console.error('获取班组列表失败:', error)
this.$message.error('获取班组列表失败')
}
},
async loadProjectList() {
try {
const response = await getProjectList({})
if (response.code === 200) {
this.projectList = response.data || []
}
} catch (error) {
console.error('获取工程列表失败:', error)
this.$message.error('获取工程列表失败')
}
},
async handleQuery() {
if (this.selectedTeams.length === 0) {
this.$message.warning('请选择结算班组')
return
}
if (!this.selectedProject) {
this.$message.warning('请选择结算工程')
return
}
this.loading = true
this.hasQueried = true
try {
// rowData
this.rowData = {
unitIds: this.selectedTeams,
projectId: this.selectedProject
}
await this.getDataAll()
} catch (error) {
console.error('查询结算数据失败:', error)
this.$message.error('查询结算数据失败')
} finally {
this.loading = false
}
},
/** 查询列表 */
async getDataAll() {
try {
const response = await getClzSltInfo(this.rowData)
console.log('接口返回数据:', response)
//
const dataArray = Array.isArray(response.data) ? response.data : [response.data]
console.log('数据数组:', dataArray)
//
this.leaseList = []
this.repairList = []
this.scrapList = []
this.loseList = []
this.reducList = []
//
const projectNames = []
const unitNames = []
let totalRepairCost = 0
let totalScrapCost = 0
//
dataArray.forEach((data, index) => {
console.log(`处理第${index + 1}个班组数据:`, data)
//
const currentUnitName = data.unitName || ''
//
if (data.leaseList && data.leaseList.length > 0) {
const leaseListWithUnit = data.leaseList.map(item => ({
...item,
unitName: item.unitName || currentUnitName
}))
this.leaseList = [...this.leaseList, ...leaseListWithUnit]
}
if (data.repairList && data.repairList.length > 0) {
const repairListWithUnit = data.repairList.map(item => ({
...item,
unitName: item.unitName || currentUnitName
}))
this.repairList = [...this.repairList, ...repairListWithUnit]
}
if (data.scrapList && data.scrapList.length > 0) {
const scrapListWithUnit = data.scrapList.map(item => ({
...item,
unitName: item.unitName || currentUnitName
}))
this.scrapList = [...this.scrapList, ...scrapListWithUnit]
}
if (data.loseList && data.loseList.length > 0) {
const loseListWithUnit = data.loseList.map(item => ({
...item,
unitName: item.unitName || currentUnitName
}))
this.loseList = [...this.loseList, ...loseListWithUnit]
}
if (data.reductionList && data.reductionList.length > 0) {
const reducListWithUnit = data.reductionList.map(item => ({
...item,
unitName: item.unitName || currentUnitName
}))
this.reducList = [...this.reducList, ...reducListWithUnit]
}
//
if (data.projectName && !projectNames.includes(data.projectName)) {
projectNames.push(data.projectName)
}
if (data.unitName && !unitNames.includes(data.unitName)) {
unitNames.push(data.unitName)
}
//
if (data.repairCost) {
totalRepairCost += Number(data.repairCost)
}
if (data.scrapCost) {
totalScrapCost += Number(data.scrapCost)
}
})
console.log('合并后的租赁列表:', this.leaseList)
console.log('合并后的维修列表:', this.repairList)
console.log('合并后的报废列表:', this.scrapList)
console.log('合并后的丢失列表:', this.loseList)
console.log('合并后的减免列表:', this.reducList)
//
this.projectName = projectNames.join(', ')
this.unitName = unitNames.join(', ')
console.log('项目名称:', this.projectName)
console.log('班组名称:', this.unitName)
//
this.leaseCost = this.countCost(this.leaseList)
this.repairCost = totalRepairCost.toFixed(2)
this.scrapCost = totalScrapCost.toFixed(2)
this.loseCost = this.countCost(this.loseList)
//
this.reducCost = 0
if (this.reducList.length > 0) {
this.reducList.forEach(item => {
this.reducCost = Number(this.reducCost) + Number(item.leaseMoney || 0)
})
}
console.log('租赁费用:', this.leaseCost)
console.log('维修费用:', this.repairCost)
console.log('报废费用:', this.scrapCost)
console.log('丢失费用:', this.loseCost)
console.log('减免费用:', this.reducCost)
//
let costSum =
Number(this.leaseCost) +
Number(this.repairCost) +
Number(this.scrapCost) +
Number(this.loseCost) -
Number(this.reducCost)
this.costAll = costSum
console.log('各项数据长度:', {
leaseList: this.leaseList.length,
repairList: this.repairList.length,
scrapList: this.scrapList.length,
loseList: this.loseList.length,
reducList: this.reducList.length
})
console.log('hasData结果:', this.hasData)
console.log('总费用:', this.costAll)
} catch (error) {
console.error('获取结算数据失败:', error)
this.$message.error('获取结算数据失败')
}
},
//
countCost(list) {
let arrCost = 0
list.forEach(item => {
// costs
// partTypescrapTypenull
if (item.costs && item.costs > 0) {
arrCost = arrCost + Number(item.costs)
}
})
return arrCost.toFixed(2)
},
//
handleAdd() {
this.$modal
.confirm('是否确认提交?')
.then(() => {
// ID
const agreementIds = this.getAgreementIds()
let params = {
agreementIds: agreementIds,
totalCostAll: this.costAll,
leaseList: this.leaseList,
repairList: this.repairList,
scrapList: this.scrapList,
loseList: this.loseList,
reductionList: this.reducList
}
console.log('提交参数:', params)
console.log('协议ID列表:', agreementIds)
submitClzCosts(params).then(response => {
this.$message({
type: 'success',
message: '提交成功'
})
this.reset()
})
})
.catch(() => {})
},
// ID
getAgreementIds() {
const agreementIds = new Set()
// ID
this.leaseList.forEach(item => {
if (item.agreementId) {
agreementIds.add(item.agreementId)
}
})
// ID
this.repairList.forEach(item => {
if (item.agreementId) {
agreementIds.add(item.agreementId)
}
})
// ID
this.scrapList.forEach(item => {
if (item.agreementId) {
agreementIds.add(item.agreementId)
}
})
// ID
this.loseList.forEach(item => {
if (item.agreementId) {
agreementIds.add(item.agreementId)
}
})
// ID
this.reducList.forEach(item => {
if (item.agreementId) {
agreementIds.add(item.agreementId)
}
})
//
return Array.from(agreementIds)
},
reset() {
this.selectedTeams = []
this.selectedProject = ''
this.hasQueried = false
this.clearData()
},
clearData() {
this.leaseList = []
this.leaseCost = 0
this.repairList = []
this.repairCost = 0
this.scrapList = []
this.scrapCost = 0
this.loseList = []
this.loseCost = 0
this.reducList = []
this.reducCost = 0
this.costAll = 0
this.projectName = ''
this.unitName = ''
this.rowData = []
},
goBack() {
this.$router.go(-1)
},
//
handleExport1() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportLease', { ...params }, `租赁费用明细_${currentTime}.xlsx`)
},
handleExport2() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportLose', { ...params }, `丢失费用明细_${currentTime}.xlsx`)
},
handleExport3() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportRepair', { ...params }, `维修费用明细_${currentTime}.xlsx`)
},
handleExport4() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportScrap', { ...params }, `报废费用明细_${currentTime}.xlsx`)
},
handleExport5() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportReduction', { ...params }, `减免费用明细_${currentTime}.xlsx`)
},
handleExportAll() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportAll', { ...params }, `全部费用明细_${currentTime}.xlsx`)
},
handleExportEach() {
const formatTime = date => {
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}${month}${day}_${hours}${minutes}${seconds}`
}
const currentTime = formatTime(new Date())
let data = _.cloneDeep(this.rowData)
const params = { params: JSON.stringify(data) }
this.download('material/material_sltAgreementInfo/exportEach', { ...params }, `各费用明细_${currentTime}.xlsx`)
},
//
},
mounted() {
//
}
}
</script>
<style lang="scss" scoped>
.operation-bar {
//background: #f5f7fa;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;
}
::v-deep .el-table .fixed-width .el-button--mini {
width: 80px !important;
margin-bottom: 10px;
}
.tabelAllTop {
display: flex;
border: 1px solid #dfe6ec;
width: 100%;
height: 50px;
background-color: #f8f8f9;
border-left: none;
border-bottom: none;
.costTop {
display: flex;
padding: 5px;
border-left: 1px solid #dfe6ec;
align-items: center;
text-align: center;
justify-content: center; /* 将内容对齐到中间 */
width: 100%;
font-weight: bold; /* 添加字体加粗样式 */
}
}
.tabelAllTopUnit {
display: flex;
border: 1px solid #dfe6ec;
width: 100%;
height: 50px;
background-color: #f8f8f9;
border-bottom: none;
.costTopUnit {
display: flex;
padding: 5px;
width: 21.4%;
border-left: none;
align-items: center;
text-align: center;
justify-content: center; /* 将内容对齐到中间 */
}
.costRightUnit {
display: flex;
padding: 5px;
border-left: 1px solid #dfe6ec;
text-align: center;
align-items: center;
width: 100%;
justify-content: center; /* 将内容对齐到中间 */
// padding-left: 20px; /* */
}
}
.tabelAll {
display: flex;
border: 1px solid #ecedf3;
width: 100%;
border-bottom: 1px solid #dfe6ec;
border-top: none;
margin-bottom: 15px;
}
.tabelAllBottom {
display: flex;
border: 1px solid #dfe6ec;
width: 100%;
border-bottom: 1px solid #dfe6ec;
border-top: none;
}
.columnAll {
display: flex;
padding: 5px;
border-left: 1px solid #dfe6ec;
text-align: center;
align-items: center;
width: 100%;
justify-content: flex-end; /* 将内容对齐到右侧 */
margin-right: 60px; /* 添加右边距 */
}
.columnAllNum {
padding: 5px;
text-align: center;
width: 21.4%;
border-left: none;
}
/* 最后一列无右边框 */
.tabelAll .column:last-child {
border-right: none;
}
</style>