index.vue
4.9 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
<div class="layout">
<div class="top flex">
<div class="report-name text-hide">
{{ outputData.reportName || '' }}
</div>
<template v-if="outputData.reportTimeStart">
<div
class="time"
@click="showDateSelect = true"
>
{{ new Date(outputData.reportTimeStart).format('yyyy.MM.dd') }}- {{ new Date(outputData.reportTimeEnd).format('yyyy.MM.dd') }}
<van-icon name="arrow-down" />
</div>
</template>
</div>
<template v-if="tabIndex == 0">
<customer-statistics
:data="customerData"
:reportType="reportType"
/>
</template>
<template v-else>
<output-statistics
:data="outputData"
:reportType="reportType"
/>
</template>
<div class="bottom">
<tab
:list="['客户统计', '产值统计']"
@change="change"
:index="tabIndex"
></tab>
</div>
<van-popup
v-model="showDateSelect"
position="bottom"
>
<van-picker
show-toolbar
:title="reportType == 0 ? '选择周报' : '选择月报'"
:columns="dateColumns"
:default-index="dateColumns.length"
@confirm="confirmDate"
@cancel="showDateSelect = false"
/>
</van-popup>
</div>
</template>
<script>
import { reportApi } from '@/api'
export default {
name: '',
data() {
return {
tabIndex: 1,
reportType:0, //0 周 1 月
customerData: {},
outputData: {},
detail: {},
showDateSelect: false,
dateColumns: []
}
},
mounted() {
this.initDate()
this.getOutputReport()
},
methods: {
initDate() {
let { reportType } = this
let now = new Date()
let dateColumns = []
if (reportType == 0) {
let dateTime = now.getTime()
let day = now.getDay() || 7
let oneDayTime = 24 * 60 * 60 * 1000
for (let i = 24; i > 0; i--) {
let monday = new Date(dateTime - (day - 1 + i * 7) * oneDayTime).format('yyyy-MM-dd') // 获取周一
let sunday = new Date(dateTime + (7 - day - i * 7) * oneDayTime).format('yyyy-MM-dd') // 获取周日
dateColumns.push(`${monday}~${sunday}`)
}
this.dateColumns = dateColumns
} else {
let nowMonth = now.getMonth()
for (let i = nowMonth - 12; i <= nowMonth - 1; i++) {
dateColumns.push(new Date(new Date().setMonth(i)).format('yyyy-MM'))
}
this.dateColumns = dateColumns
}
},
change(e) {
this.tabIndex = e
},
getOutputReport(reportTimeStart = '') {
let userInfo = this.getLocalStorage('dj_scrm_userInfo')
let { reportType } = this
reportApi
.getReport({
reportType,
reportTimeStart
})
.then(({ code, data, message }) => {
this.hideLoading()
if (code == 0) {
if (data) {
if (data.newProductionValueSequential) data.newProductionValueSequential = Number(data.newProductionValueSequential.replace('%', ''))
if (data.newEquityBillLadingSequential) data.newEquityBillLadingSequential = Number(data.newEquityBillLadingSequential.replace('%', ''))
if (data.merchantProductionValueReportList) {
data.merchantProductionValueReportList.map(e => Number((e.newProductionValue = this.centsToyuan(e.newProductionValue))))
}
if (data.productionValueReportList) {
data.productionValueReportList.map(e => Number((e.newProductionValue = this.centsToyuan(e.newProductionValue))))
}
if (data.trendList) {
data.trendList.map(e => Number((e.orderMoneyTotalSum = this.centsToyuan(e.orderMoneyTotalSum))))
}
data.userInfo = userInfo
this.outputData = data
}
} else {
this.refreshPage(`产值统计:${message}`).then(() => {
this.getOutputReport(reportTimeStart)
})
}
})
},
confirmDate(e) {
let { reportType } = this
this.showLoading('加载中...')
if (reportType == 1) {
this.getOutputReport(`${e}-01`)
this.showDateSelect = false
} else {
let [start] = e.split('~')
this.getOutputReport(start)
this.showDateSelect = false
}
}
}
}
</script>
<style lang="scss" scoped>
.layout {
color: #333333;
font-size: 14px;
padding-bottom: 65px;
.top {
position: sticky;
height: 44px;
padding: 0 16px;
background: #ffffff;
box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.05);
z-index: 9;
top: 0;
.report-name{
width: 50%;
}
.time {
margin-left: auto;
font-weight: 500;
font-size: 12px;
}
}
.bottom {
position: fixed;
bottom: 0;
left: 0;
background: #ffffff;
z-index: 2;
width: 100%;
}
}
</style>