|
@@ -1,163 +1,24 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="dash-main">
|
3
|
|
- <el-row :gutter="24" class="sta-row">
|
4
|
|
- <el-col :span="8"><stat-card icon="el-icon-time" theme="success" tip="总到访" :val="personDt.total"></stat-card></el-col>
|
5
|
|
- <el-col :span="8"><stat-card icon="el-icon-date" tip="今日到访" theme="danger" :val="personDt.today"></stat-card></el-col>
|
6
|
|
- <el-col :span="8"><stat-card icon="el-icon-news" tip="今日老客户" theme="warn" :val="personDt.regular"></stat-card></el-col>
|
7
|
|
- </el-row>
|
8
|
|
- <div class="sta-row">
|
9
|
|
- <el-card shadow="never">
|
10
|
|
- <div slot="header" class="short-filters">
|
11
|
|
- <div class="flex-item"> </div>
|
12
|
|
- <div class="static-item item-space">
|
13
|
|
- <el-radio-group
|
14
|
|
- size="small"
|
15
|
|
- v-model="filterData.dateShortcut"
|
16
|
|
- @change="handeShortDateChange"
|
17
|
|
- >
|
18
|
|
- <el-radio-button label="本年"></el-radio-button>
|
19
|
|
- <el-radio-button label="本季"></el-radio-button>
|
20
|
|
- <el-radio-button label="本月"></el-radio-button>
|
21
|
|
- </el-radio-group>
|
22
|
|
- </div>
|
23
|
|
- <div class="static-item item-space">
|
24
|
|
- <el-date-picker
|
25
|
|
- size="small"
|
26
|
|
- v-model="filterData.dateRange"
|
27
|
|
- type="daterange"
|
28
|
|
- range-separator="至"
|
29
|
|
- start-placeholder="开始日期"
|
30
|
|
- end-placeholder="结束日期"
|
31
|
|
- @change="handleDateChange">
|
32
|
|
- </el-date-picker>
|
33
|
|
- </div>
|
34
|
|
- </div>
|
35
|
|
- <el-row :gutter="12" type="flex">
|
36
|
|
- <el-col :span="12">
|
37
|
|
- <table-chart :page="visitingPage" :source="visitingList" @page-change="nextVistingLogPage"></table-chart>
|
38
|
|
- </el-col>
|
39
|
|
- <el-col :span="12">
|
40
|
|
- <line-chart :source="dailyVisiting" :style="{minHeight: '400px'}"></line-chart>
|
41
|
|
- </el-col>
|
42
|
|
- </el-row>
|
43
|
|
- </el-card>
|
44
|
|
- </div>
|
|
3
|
+ <h3>欢迎使用经纪人系统</h3>
|
45
|
4
|
</div>
|
46
|
5
|
</template>
|
47
|
6
|
|
48
|
7
|
<script>
|
49
|
|
-import dayjs from 'dayjs'
|
50
|
|
-import { createNamespacedHelpers } from 'vuex'
|
51
|
|
-
|
52
|
|
-const {mapState: mapStatsState, mapActions: mapStatsActions} = createNamespacedHelpers('stats')
|
53
|
8
|
|
54
|
9
|
export default {
|
55
|
10
|
name: 'dashboard',
|
56
|
11
|
components: {
|
57
|
|
- lineChart: () => import('@/components/charts/VisitingDayLine.vue'),
|
58
|
|
- tableChart: () => import('@/components/charts/VisitingDayTable.vue'),
|
59
|
|
- statCard: () => import('@/components/charts/StatCard.vue'),
|
60
|
12
|
},
|
61
|
13
|
data () {
|
62
|
14
|
return {
|
63
|
|
- filterData: {
|
64
|
|
- dateRange: [],
|
65
|
|
- dateShortcut: '',
|
66
|
|
- },
|
67
|
|
- visitingLogCurrentPage: 1,
|
68
|
15
|
}
|
69
|
16
|
},
|
70
|
17
|
computed: {
|
71
|
|
- ...mapStatsState({
|
72
|
|
- personDts: x => x.person,
|
73
|
|
- dailyVisiting: x => x.visitingDaily,
|
74
|
|
- visitingLog: x => x.visitingLog,
|
75
|
|
- }),
|
76
|
|
- personDt () {
|
77
|
|
- return (this.personDts || [])[0] || {}
|
78
|
|
- },
|
79
|
|
- visitingPage () {
|
80
|
|
- return {
|
81
|
|
- total: (this.visitingLog || {}).total || 0,
|
82
|
|
- size: (this.visitingLog || {}).size || 10,
|
83
|
|
- current: this.visitingLogCurrentPage,
|
84
|
|
- }
|
85
|
|
- },
|
86
|
|
- visitingList () {
|
87
|
|
- return (this.visitingLog || {}).records || []
|
88
|
|
- }
|
89
|
18
|
},
|
90
|
19
|
created () {
|
91
|
|
- this.changeDate('week')
|
92
|
|
- this.getPersonStats()
|
93
|
20
|
},
|
94
|
21
|
methods: {
|
95
|
|
- ...mapStatsActions([
|
96
|
|
- 'getPersonStats',
|
97
|
|
- 'getVisitingDaily',
|
98
|
|
- 'getVisitingLog',
|
99
|
|
- ]),
|
100
|
|
- handleDateChange (dts) {
|
101
|
|
- this.filterData.dateRange = dts
|
102
|
|
- this.filterData.dateShortcut = ''
|
103
|
|
- this.search()
|
104
|
|
- },
|
105
|
|
- search (rg) {
|
106
|
|
- if (!rg || rg === 'visiting-daily') {
|
107
|
|
- this.getVisitingDaily({
|
108
|
|
- startDate: dayjs(this.filterData.dateRange[0]).format('YYYY-MM-DDT00:00:00'),
|
109
|
|
- endDate: dayjs(this.filterData.dateRange[1]).format('YYYY-MM-DDT23:59:59'),
|
110
|
|
- })
|
111
|
|
- }
|
112
|
|
-
|
113
|
|
- if (!rg || rg === 'visiting-log') {
|
114
|
|
- this.getVisitingLog({
|
115
|
|
- pageNum: this.visitingLogCurrentPage,
|
116
|
|
- pageSize: this.visitingPage.size,
|
117
|
|
- beginDate: dayjs(this.filterData.dateRange[0]).format('YYYY-MM-DDT00:00:00'),
|
118
|
|
- endDate: dayjs(this.filterData.dateRange[1]).format('YYYY-MM-DDT23:59:59'),
|
119
|
|
- })
|
120
|
|
- }
|
121
|
|
- },
|
122
|
|
- changeDate (typ) {
|
123
|
|
- this.filterData.dateRange = this.getDateRange(typ)
|
124
|
|
- this.search()
|
125
|
|
- },
|
126
|
|
- nextVistingLogPage (page) {
|
127
|
|
- this.visitingLogCurrentPage = page
|
128
|
|
- this.search('visiting-log')
|
129
|
|
- },
|
130
|
|
- handeShortDateChange (val) {
|
131
|
|
- switch (val) {
|
132
|
|
- case '本年':
|
133
|
|
- this.changeDate('year')
|
134
|
|
- break
|
135
|
|
- case '本季':
|
136
|
|
- this.changeDate('quarter')
|
137
|
|
- break
|
138
|
|
- case '本月':
|
139
|
|
- this.changeDate('month')
|
140
|
|
- break
|
141
|
|
- }
|
142
|
|
- },
|
143
|
|
- getDateRange(typ) {
|
144
|
|
- // typ: https://github.com/iamkun/dayjs/blob/dev/src/constant.js#L13
|
145
|
|
- const now = new Date();
|
146
|
|
-
|
147
|
|
- const start = typ === 'quarter' ? this.getQuarterStart(now) : dayjs(now).startOf(typ).toDate()
|
148
|
|
-
|
149
|
|
- return [ start, now ]
|
150
|
|
- },
|
151
|
|
- getQuarterStart(dt) {
|
152
|
|
- const mon = dt.getMonth()
|
153
|
|
- const year = dt.getFullYear()
|
154
|
|
-
|
155
|
|
- if (mon < 3) return dayjs(`${year}-01-01`).toDate()
|
156
|
|
- if (mon < 6) return dayjs(`${year}-03-01`).toDate()
|
157
|
|
- if (mon < 9) return dayjs(`${year}-06-01`).toDate()
|
158
|
|
-
|
159
|
|
- return dayjs(`${year}-09-01`).toDate()
|
160
|
|
- }
|
161
|
22
|
}
|
162
|
23
|
}
|
163
|
24
|
</script>
|
|
@@ -166,34 +27,7 @@ export default {
|
166
|
27
|
<style lang="scss" scoped>
|
167
|
28
|
.dash-main {
|
168
|
29
|
background-color: transparent !important;
|
169
|
|
- padding: 20px 0;
|
170
|
|
-}
|
171
|
|
-
|
172
|
|
-.sta-row {
|
173
|
|
- & + .sta-row {
|
174
|
|
- margin-top: 24px;
|
175
|
|
- }
|
176
|
|
-}
|
177
|
|
-
|
178
|
|
-.short-filters {
|
179
|
|
- display: flex;
|
180
|
|
-
|
181
|
|
- .item-space {
|
182
|
|
- margin-left: 24px;
|
183
|
|
- }
|
184
|
|
-
|
185
|
|
- .flex-item {
|
186
|
|
- flex: auto;
|
187
|
|
- }
|
188
|
|
-
|
189
|
|
- .static-item {
|
190
|
|
- flex: none;
|
191
|
|
- }
|
192
|
|
-}
|
193
|
|
-</style>
|
194
|
|
-
|
195
|
|
-<style lang="scss">
|
196
|
|
-.dash-main .el-card__header {
|
197
|
|
- padding: 12px;
|
|
30
|
+ padding: 200px 0;
|
|
31
|
+ text-align: center;
|
198
|
32
|
}
|
199
|
33
|
</style>
|