Commit 2bda4e03 authored by guoyou's avatar guoyou

订单统计日期筛选

parent 0bd5a630
export function formatDate(date, fmt) {
console.log(date);
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
......
......@@ -11,16 +11,16 @@
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker> -->
<el-date-picker
v-model="time"
type="daterange"
placeholder="请选择时间范围"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="changeTime">
</el-date-picker>
></el-date-picker>-->
<el-date-picker
v-model="time"
type="daterange"
placeholder="请选择时间范围"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="changeTime"
></el-date-picker>
</el-form-item>
<el-form-item label="统计周期">
<el-radio-group v-model="listQuery.statisticalWay">
......@@ -31,7 +31,7 @@
</el-form-item>
<el-form-item label="订单状态">
<el-select v-model="listQuery.orderState" clearable placeholder="请选择">
<!-- <el-option :value='null'>全部</el-option> -->
<!-- <el-option :value='null'>全部</el-option> -->
<el-option v-for="item in orderArr" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
......@@ -66,28 +66,37 @@
<!-- <p v-for="(item,index) in chartArr" :key="index">{{item.row}}</p> -->
<div v-for="(item,index) in chartArr" :key="index">
<p style="text-align:center">{{checkArr.filter(val => val.id == item.title)[0].name}}</p>
<ve-line :data="item" :extend="extend" :settings="chartSettings" :legend-visible="false" :data-zoom="dataZoom"></ve-line>
<ve-line
:data="item"
:extend="extend"
:settings="chartSettings"
:legend-visible="false"
:data-zoom="dataZoom"
></ve-line>
</div>
</div>
</div>
</template>
<script>
import { received_statistics,excelExport } from 'api/statistics/vehicleStatistics'
import {
received_statistics,
excelExport
} from 'api/statistics/vehicleStatistics'
import { formatDate } from 'utils/dateFormattor'
import { objDeepCopy } from '../../utils'
export default {
data: function() {
this.extend = {
// 'xAxis.0.axisLabel.rotate': 45
}
this.dataZoom = [
{
type: 'slider',
start: 0,
end: 30
}
]
}
this.dataZoom = [
{
type: 'slider',
start: 0,
end: 30
}
]
this.chartSettings = {
labelMap: {
orderAmount: '金额',
......@@ -95,7 +104,7 @@ export default {
}
}
return {
excelLoading:false,
excelLoading: false,
loading: true,
time: null,
checkArr: [
......@@ -130,10 +139,10 @@ export default {
},
//订单状态
orderArr: [
{
name:"全部",
id:'',
},
{
name: '全部',
id: ''
},
{
name: '未支付',
id: 0
......@@ -171,108 +180,7 @@ export default {
],
chartData: {
columns: ['dateStr', 'orderAmount'],
rows: [
// {
// 日期: '2019-12-18',
// 访问用户: 1393,
// },
// {
// 日期: '2019-12-19',
// 访问用户: 1393,
// },
// {
// 日期: '2019-12-20',
// 访问用户: 7000,
// },
// {
// 日期: '2019-12-22',
// 访问用户: 2923,
// },
// {
// 日期: '2019-12-23',
// 访问用户: 1723,
// },
// {
// 日期: '2019-12-24',
// 访问用户: 3792,
// },
// {
// 日期: '2019-12-25',
// 访问用户: 4593,
// },
// {
// 日期: '2019-12-26',
// 访问用户: 4593,
// },
// {
// 日期: '2019-12-27',
// 访问用户: 4593,
// },
// {
// 日期: '2019-12-28',
// 访问用户: 4593,
// },
// {
// 日期: '2019-12-29',
// 访问用户: 4593,
// },
// {
// 日期: '2019-12-30',
// 访问用户: 4593,
// },
// {
// 日期: '2019-12-31',
// 访问用户: 4593,
// },
// {
// 日期: '2020-01-01',
// 访问用户: 4593,
// },
// {
// 日期: '2020-01-02',
// 访问用户: 4593,
// },
// {
// 日期: '2020-01-03',
// 访问用户: 4593,
// },
// {
// 日期: '2020-01-04',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-05',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-06',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-07',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-08',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-09',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-10',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-11',
// 访问用户: 5000,
// },
// {
// 日期: '2020-01-12',
// 访问用户: 5000,
// }
]
rows: []
},
chartArr: {}
}
......@@ -281,15 +189,15 @@ export default {
this.getList()
},
methods: {
//时间关闭
changeTime(val){
if (!val) {
this.time = null
this.listQuery.endDate = null
this.listQuery.startDate = null
}
},
//导出
//时间关闭
changeTime(val) {
if (!val) {
this.time = null
this.listQuery.endDate = null
this.listQuery.startDate = null
}
},
//导出
downloadExcel() {
this.excelLoading = true
var u = navigator.userAgent,
......@@ -319,18 +227,15 @@ export default {
},
//搜索
search() {
// console.log(this.time);
console.log(!!this.time[0]);
if (!!this.time[0]) {
this.listQuery.startDate = formatDate(
new Date(this.time[0]),
'yyyy-MM-dd'
)+" 00:00:00"
this.listQuery.endDate = formatDate(
new Date(this.time[1]),
'yyyy-MM-dd'
)+" 23:59:59"
console.log(!!this.time && !!this.time[0])
if (!!this.time && !!this.time[0]) {
this.listQuery.startDate =
formatDate(new Date(this.time[0]), 'yyyy-MM-dd') +
' 00:00:00'
this.listQuery.endDate =
formatDate(new Date(this.time[1]), 'yyyy-MM-dd') +
' 23:59:59'
}
this.getList()
},
......@@ -342,7 +247,7 @@ export default {
page: 1, //当前页
limit: 10, //每页条数
statisticalWay: 1, //统计方式
orderState:'', //订单状态
orderState: '', //订单状态
orderOrigin: null, //来源
payWay: null, //支付方式
statisticalSigns: ['aa_ota'] //筛选
......@@ -356,34 +261,34 @@ export default {
if (data.status == 200) {
let info = data.data
let params = {}
let choose = this.listQuery.statisticalSigns
let way = this.listQuery.statisticalWay
var x
var y
let dateIndex = way == 1 ?2:way == 2?1:1
let orderIndex = way == 1 ?3:way==2? 2 : 2
let choose = this.listQuery.statisticalSigns
let way = this.listQuery.statisticalWay
var x
var y
let dateIndex = way == 1 ? 2 : way == 2 ? 1 : 1
let orderIndex = way == 1 ? 3 : way == 2 ? 2 : 2
for (let i = 0; i < choose.length; i++) {
if (info[choose[i]] != '') {
params[choose[i]] = {
columns: [
Object.keys(info[choose[i]][0])[dateIndex], //年费
Object.keys(info[choose[i]][0])[orderIndex] //金额
],
rows: info[choose[i]].sort(function(a,b){
if(way===1){
x = a.date;
y = b.date;
}
if(way ===2){
x = a.weekOfYear;
y = b.weekOfYear;
}
if(way ===3){
x = a.month;
y = b.month;
}
return((x<y)?-1:((x>y)?1:0));
}),
Object.keys(info[choose[i]][0])[orderIndex] //金额
],
rows: info[choose[i]].sort(function(a, b) {
if (way === 1) {
x = a.date
y = b.date
}
if (way === 2) {
x = a.weekOfYear
y = b.weekOfYear
}
if (way === 3) {
x = a.month
y = b.month
}
return x < y ? -1 : x > y ? 1 : 0
}),
title: choose[i]
}
}
......@@ -394,7 +299,7 @@ export default {
this.loading = false
}, 300)
})
},
}
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment