|
@@ -9,7 +9,7 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="下单月份" align="center" v-if="months">
|
|
|
- <el-table-column :label="'0' + month" v-for="month in months" :key="month" min-width="100px">
|
|
|
+ <el-table-column :label="month.length > 1 ? month : '0' + month" v-for="month in months" :key="month" min-width="100px">
|
|
|
<template slot-scope="scope">
|
|
|
{{getField(month, scope.row, scope.row.name === '无地址订单总金额')}}
|
|
|
</template>
|
|
@@ -50,7 +50,7 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
tableData:[],
|
|
|
- months: [],
|
|
|
+ months: ['1','2','3','4','5','6','7','8','9','10','11','12'],
|
|
|
loading:false,
|
|
|
statusOptions: [
|
|
|
{ id: "0", label: "待发货" },
|
|
@@ -125,7 +125,7 @@ export default {
|
|
|
getTotal(row, isTotalPrice){
|
|
|
if(isTotalPrice){
|
|
|
const total = this.months.reduce((prev, month) => {
|
|
|
- return addition(prev, row.result[month]['total_price'] || 0)
|
|
|
+ return addition(prev, row.result[month] ? row.result[month]['total_price'] : 0)
|
|
|
},0)
|
|
|
return Number(total) === 0 ? "0元" : unit2TenThousand(total) + "元"
|
|
|
}
|
|
@@ -143,7 +143,7 @@ export default {
|
|
|
|
|
|
if(isTotalPrice){
|
|
|
const { total_price } = row.result[month]
|
|
|
- console.log(total_price,month)
|
|
|
+
|
|
|
return Number(total_price) === 0 ? "0元" : unit2TenThousand(total_price) + "元"
|
|
|
}
|
|
|
|
|
@@ -182,8 +182,23 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.tableData = tableData
|
|
|
- this.months = Object.keys(this.tableData[0].result).filter(month => month !== 'status')
|
|
|
+ this.tableData = tableData.reduce((prev,current) => {
|
|
|
+ return [...prev, {
|
|
|
+ name: current.name,
|
|
|
+ result: this.months.reduce((pre,month) => {
|
|
|
+ return {
|
|
|
+ ...pre,
|
|
|
+ [month]:{
|
|
|
+ '1': current.result[month] && current.result[month]['1'] ? current.result[month]['1'] : {num: 0 ,send_status : null},
|
|
|
+ '2': current.result[month] && current.result[month]['2'] ? current.result[month]['2'] : {num: 0, send_status : null },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },{})
|
|
|
+ }]
|
|
|
+ },[])
|
|
|
+
|
|
|
+ console.log(this.tableData)
|
|
|
+
|
|
|
const totalItemDefault = this.months.reduce((prev,month) => ({
|
|
|
...prev,
|
|
|
[month]:{ 1:{ num:0 }}
|
|
@@ -208,7 +223,20 @@ export default {
|
|
|
this.tableData.push(totalItem)
|
|
|
|
|
|
noAddr.name = "无地址订单总金额"
|
|
|
+
|
|
|
+ noAddr.result = this.months.reduce((prev,month) => ({
|
|
|
+ ...prev,
|
|
|
+ [month]:{
|
|
|
+ total_price:noAddr.result[month] && noAddr.result[month].total_price
|
|
|
+ ? noAddr.result[month].total_price
|
|
|
+ : 0
|
|
|
+ }
|
|
|
+ }),{})
|
|
|
+
|
|
|
+
|
|
|
noAddr.result.status = "--"
|
|
|
+
|
|
|
+ console.log(noAddr)
|
|
|
this.tableData.push(noAddr)
|
|
|
} else {
|
|
|
this.tableData = [];
|