两位小数

This commit is contained in:
Vergil
2020-04-02 13:39:53 +08:00
parent 29cac18293
commit c5fd68b17c
3 changed files with 60 additions and 11 deletions

View File

@@ -15,7 +15,7 @@
</el-table-column>
<el-table-column label="请款金额" align="right" min-width="100" prop="请款金额">
<template slot-scope="scope">
{{ scope.row.请款金额 }}
{{ Number(scope.row.请款金额).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="请款人" align="center" min-width="100">
@@ -31,7 +31,7 @@
<el-table-column label="审核" align="center" width="320">
<template slot-scope="scope">
<el-popover placement="right" width="400" trigger="click">
<el-table v-show="scope.row.类别==='采购'" :data="gridData2" stripe size="mini" show-summary>
<el-table v-show="scope.row.类别==='采购'" :data="gridData2" :summary-method="getSummaries" stripe size="mini" show-summary>
<el-table-column width="50" align="center" type="index" label="序号"/>
<el-table-column min-width="150" align="center" label="采购合同编号">
<template slot-scope="scope">
@@ -40,7 +40,7 @@
</el-table-column>
<el-table-column min-width="100" align="center" label="合同总额" prop="请款金额">
<template slot-scope="scope">
{{ scope.row.请款金额 }}
{{ Number(scope.row.请款金额).toFixed(2) }}
</template>
</el-table-column>
</el-table>
@@ -242,6 +242,33 @@ export default {
this.fetchData()
},
methods: {
// 合计
getSummaries(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
return
} else if (index === 2) {
const values = data.map(item => Number(item[column.property]))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0)
sums[index] = sums[index].toFixed(2) + ' 元'
} else {
sums[index] = 'N/A'
}
}
})
return sums
},
fetchData() {
this.searchTable()
},

View File

@@ -15,7 +15,7 @@
</el-table-column>
<el-table-column label="请款金额" align="right" min-width="100" prop="请款金额">
<template slot-scope="scope">
{{ scope.row.请款金额 }}
{{ Number(scope.row.请款金额).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="请款人" align="center" min-width="100">
@@ -31,7 +31,7 @@
<el-table-column label="审核" align="center" width="320">
<template slot-scope="scope">
<el-popover placement="right" width="400" trigger="click">
<el-table v-show="scope.row.类别==='采购'" :data="gridData1" stripe size="mini" show-summary>
<el-table v-show="scope.row.类别==='采购'" :data="gridData1" :summary-method="getSummaries" stripe size="mini" show-summary>
<el-table-column width="50" align="center" type="index" label="序号"/>
<el-table-column min-width="150" align="center" label="采购合同编号">
<template slot-scope="scope">
@@ -40,7 +40,7 @@
</el-table-column>
<el-table-column min-width="100" align="center" label="合同总额" prop="请款金额">
<template slot-scope="scope">
{{ scope.row.请款金额 }}
{{ Number(scope.row.请款金额).toFixed(2) }}
</template>
</el-table-column>
</el-table>
@@ -252,6 +252,33 @@ export default {
this.searchTable()
},
methods: {
// 合计
getSummaries(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
return
} else if (index === 2) {
const values = data.map(item => Number(item[column.property]))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0)
sums[index] = sums[index].toFixed(2) + ' 元'
} else {
sums[index] = 'N/A'
}
}
})
return sums
},
fetchData() {
this.searchTable()
this.searchTable2()

View File

@@ -172,11 +172,6 @@
{{ scope.row.发票号 }}
</template>
</el-table-column>
<el-table-column label="供应商" align="center" min-width="250" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.供应商名称 }}
</template>
</el-table-column>
<el-table-column label="到票金额" align="center" min-width="70">
<template slot-scope="scope">
{{ Number(scope.row.开票金额).toFixed(2) }}