1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<template>
<div class="historicalVisitors">
<div class="searchBox">
<a-input placeholder="访客人员" v-model="searchSource.visitorName" style="width: 120px"/>
<a-input placeholder="访客人员" v-model="searchSource.visitorName" style="width: 120px"/>
<a-date-picker
:disabledDate="disabledStartDate"
format="YYYY-MM-DD"
v-model="startValue"
placeholder="开始日期"
@change="onChangeStartValue"
@openChange="handleStartOpenChange"
/>
~
<a-date-picker
:disabledDate="disabledEndDate"
format="YYYY-MM-DD"
placeholder="结束日期"
@change="onChangeEndValue"
v-model="endValue"
:open="endOpen"
@openChange="handleEndOpenChange"
/>
<a-button type="primary" @click="getStatisticalProductPage">查询</a-button>
</div>
<div class="title">账单汇总</div>
<a-table :columns="columns" :dataSource="dataSource" rowKey="productId" :pagination="pagination" @change="handleTableChange">
<span slot="productIcon" slot-scope="productIcon">
<img style="width: 100px" :src="productIcon" alt="" />
</span>
<span slot="productName"></span>
<!-- <span slot="productPrice" slot-scope="productPrice">
{{ productPrice.toFixed(2) }}
</span> -->
<span slot="productStatisticalQuantity"></span>
</a-table>
</div>
</template>
<script>
import { $http } from './../../../api/axios.js'
import moment from 'moment'
export default {
name: 'historicalVisitors',
data () {
return {
startTime: '',
endTime: '',
startValue: null,
endValue: null,
endOpen: false,
pagination: {
current: 1,
defaultCurrent: 10,
defaultPageSize: 10,
hideOnSinglePage: true,
total: 0
},
columns: [{
title: '产品图',
dataIndex: 'productIcon',
scopedSlots: { customRender: 'productIcon' }
}, {
title: '菜名',
dataIndex: 'productName'
}, {
title: '售出(份数)',
dataIndex: 'productStatisticalQuantity'
}],
dataSource: []
}
},
created () {
let date = new Date()
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = (new Date(year, month, 0).getDate().toString()).length > 1 ? new Date(year, month, 0).getDate() : '0' + new Date(year, month, 0).getDate()
this.startTime = `${year}-${month.toString().length > 1 ? month : '0' + month}-01`
this.endTime = `${year}-${month.toString().length > 1 ? month : '0' + month}-${day}`
this.startValue = this.moment(`${year}-${month.toString().length > 1 ? month : '0' + month}-01`, 'YYYY-MM-DD')
this.endValue = this.moment(`${year}-${month.toString().length > 1 ? month : '0' + month}-${day}`, 'YYYY-MM-DD')
this.getStatisticalProductPage()
},
methods: {
moment,
disabledStartDate (startValue) {
const endValue = this.endValue
if (!startValue || !endValue) {
return false
}
return startValue.valueOf() > endValue.valueOf() || startValue.valueOf() >= moment().endOf('day').valueOf()
},
disabledEndDate (endValue) {
const startValue = this.startValue
if (!endValue || !startValue) {
return false
}
return startValue.valueOf() > endValue.valueOf() || endValue.valueOf() > moment().endOf('day').valueOf()
},
handleStartOpenChange (open) {
if (!open) {
this.endOpen = true
}
},
handleEndOpenChange (open) {
this.endOpen = open
},
onChangeStartValue (date, dateString) {
this.startTime = dateString
},
onChangeEndValue (date, dateString) {
this.endTime = dateString
},
getStatisticalProductPage () {
let SubsidyListData = {
startTime: this.startTime,
endTime: this.endTime,
pageNumber: 10,
currentPage: this.pagination.current
}
$http.post(`/admin/visit/list`, SubsidyListData).then((res) => {
if (res.data.resultCode === 0) {
this.dataSource = res.data.data.list
this.pagination.total = res.data.data.total
} else {
this.$message.error(res.data.message)
}
})
},
// 分页
handleTableChange (pagination, filters, sorter) {
this.pagination.current = pagination.current
this.getStatisticalProductPage()
}
}
}
</script>
<style lang="less" scoped>
.title{
font-weight: bold;
margin-top: 20px;
margin-bottom: 20px;
}
.searchBox button{
margin-left: 10px;
}
</style>