|
@@ -1,21 +1,20 @@
|
|
|
<template>
|
|
|
<div class="SalesReportRejectedNew" v-loading="loading">
|
|
|
<el-table :data="tableData" size="mini" border>
|
|
|
- <el-table-column label="计数项:订单编号">
|
|
|
- <el-table-column width="120px" label="申请人所属部门" prop="name" />
|
|
|
- </el-table-column>
|
|
|
+ <el-table-column width="120px" label="申请人所属部门" prop="name" />
|
|
|
+
|
|
|
<el-table-column label="订单状态" width="110px">
|
|
|
<template slot-scope="scope">
|
|
|
{{ getStatus(scope.row) }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="下单月份" align="center">
|
|
|
- <el-table-column label="01">
|
|
|
+ <el-table-column label="下单月份" align="center" v-if="months">
|
|
|
+ <el-table-column :label="'0' + month" v-for="month in months" :key="month" width="100px">
|
|
|
<template slot-scope="scope">
|
|
|
- {{getField('1',scope.row)}}
|
|
|
+ {{getField(month, scope.row)}}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="02">
|
|
|
+ <!-- <el-table-column label="02">
|
|
|
<template slot-scope="scope">
|
|
|
{{getField('2',scope.row)}}
|
|
|
</template>
|
|
@@ -48,9 +47,9 @@
|
|
|
<template slot-scope="scope">
|
|
|
{{getField('7',scope.row)}}
|
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
+ </el-table-column> -->
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="总计">
|
|
|
+ <el-table-column label="总计" width="110px">
|
|
|
<template slot-scope="scope">
|
|
|
{{getTotal(scope.row)}}
|
|
|
</template>
|
|
@@ -78,6 +77,7 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
tableData:[],
|
|
|
+ months: [],
|
|
|
loading:false,
|
|
|
statusOptions: [
|
|
|
{ id: "0", label: "待发货" },
|
|
@@ -107,14 +107,13 @@ export default {
|
|
|
}) || {}).label || '--'
|
|
|
},
|
|
|
getTotal(row){
|
|
|
- const keys = ['1','2','3','4','5','6','7'];
|
|
|
- return keys.reduce((prev, key) => {
|
|
|
+ return this.months.reduce((prev, key) => {
|
|
|
return addition(prev, (row.result[key]['1'] || {}).num || 0)
|
|
|
},0)
|
|
|
},
|
|
|
getField(month,row){
|
|
|
if(Array.isArray(row.result[month])) return 0
|
|
|
- return row.result[month]['1'].num || 0
|
|
|
+ return (row.result[month]['1'] || {}).num || 0
|
|
|
},
|
|
|
async searchList() {
|
|
|
this.loading = true;
|
|
@@ -127,6 +126,28 @@ export default {
|
|
|
|
|
|
if (res.code === 0 && res.data && res.data.result.length > 0) {
|
|
|
this.tableData = res.data.result
|
|
|
+ this.months = Object.keys(this.tableData[0].result)
|
|
|
+
|
|
|
+ const totalItemDefault = this.months.reduce((prev,month) => ({
|
|
|
+ ...prev,
|
|
|
+ [month]:{ 1:{ num:0 }}
|
|
|
+ }), {})
|
|
|
+
|
|
|
+
|
|
|
+ this.tableData.push({
|
|
|
+ name:'合计',
|
|
|
+ result: this.tableData.reduce((prev,current) => {
|
|
|
+ const { result} = current;
|
|
|
+
|
|
|
+ return this.months.reduce((pre,month) => {
|
|
|
+ const res = Array.isArray(result[month]) ? ({num : 0}) : (result[month]['1'] || {num : 0});
|
|
|
+ const { num } = res;
|
|
|
+ const newNum = addition(prev[month]['1'].num, num)
|
|
|
+ return { ...pre, [month]: { 1: { num:newNum }}
|
|
|
+ }
|
|
|
+ }, {})
|
|
|
+ },{...totalItemDefault})
|
|
|
+ })
|
|
|
} else {
|
|
|
this.tableData = [];
|
|
|
}
|