充值记录加合计

main
qsh 2 months ago
parent 0266fdf2d4
commit b33e1e23b2
  1. 34
      src/views/XjApplet/Vip/components/Recharge.vue

@ -34,7 +34,13 @@
<el-button @click="searchList">查询</el-button> <el-button @click="searchList">查询</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" :data="tableList" height="calc(100vh - 260px)"> <el-table
v-loading="loading"
:data="tableList"
height="calc(100vh - 260px)"
show-summary
:summary-method="getSummaries"
>
<el-table-column type="index" width="55" align="center" /> <el-table-column type="index" width="55" align="center" />
<el-table-column label="手机号" align="left" prop="phone" width="140" /> <el-table-column label="手机号" align="left" prop="phone" width="140" />
<el-table-column label="会员名" align="left" prop="memberName" min-width="140" /> <el-table-column label="会员名" align="left" prop="memberName" min-width="140" />
@ -104,6 +110,32 @@ function getList() {
loading.value = false loading.value = false
}) })
} }
function getSummaries(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计'
return
}
const values = data.map((item) => Number(item[column.property]))
if (column.property === 'money') {
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] = ''
}
})
return sums
}
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

Loading…
Cancel
Save