index.vue
9.19 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<template>
<div class="layout">
<view-container>
<template #title>
<DetailTitle :searchType="'solar'" :dataList="merchantList" :dataListObj="merchantListObj" :tabObject="tabObject"></DetailTitle>
</template>
<template #content>
<div class="solar-detail-content">
<view-date :defaultYear="defaultYear" :dataList="yearList" :businessTime="businessTime"></view-date>
<StatisticsBox class="statistic-box" :list="solarDetailList"></StatisticsBox>
<div class="solar-detail-content-bottom">
<div class="solar-detail-left">
<!-- 采购趋势 -->
<MerchantsPurchaseTrends ref="merchantsTrends" :dataList="dataList" :isEmpty="isEmpty"></MerchantsPurchaseTrends>
<!-- 商品占比 -->
<MerchantsPropotion :shopmallData="shopmallData" :selfPickData="selfPickData"></MerchantsPropotion>
</div>
<div class="solar-detail-right">
<div class="service-box">
<box-title title="服务中心-采购及入库情况"></box-title>
<PurchaseStorageTable :tableData="merchantServiceDataList" class="main-table" id="serviceTable"></PurchaseStorageTable>
</div>
<div class="merchant-box">
<box-title title="门店-采购及入库情况"></box-title>
<PurchaseStorageTable firstName="门店名称名称" :tableData="merchantMerDataList" class="main-table" id="merchantTable"></PurchaseStorageTable>
</div>
</div>
</div>
</div>
</template>
</view-container>
</div>
</template>
<script>
import { changeMixin } from '@/mixins'
import MerchantsPurchaseTrends from './MerchantsPurchaseTrends.vue'
import MerchantsPropotion from './MerchantsPropotion.vue'
import PurchaseStorageTable from './PurchaseStorageTable.vue'
export default {
name: 'SolarDetail',
mixins: [changeMixin],
components: {
MerchantsPropotion,
MerchantsPurchaseTrends,
PurchaseStorageTable
},
data() {
return {
yearList: [
{
label: '全部',
value: ''
}
],
defaultYear: '',
isEmpty: false,
dataList: [],
tooltipFormatterObj: [
{
label: '商城',
attrName: 'data1'
},
{
label: '自采',
attrName: 'data2'
},
{
label: '占比',
attrName: 'data3',
addSymbol: '%'
}
],
merchantList: [],
merchantListObj: {
labelName: 'merchantname',
valueName: 'merchantid'
},
tabObject: {},
solarDetailList: [
{
name: '总采购额',
valueName: 'amounttotal',
value: '0',
unit: '¥',
unitType: 'left',
bottomLabel: '本月采购额',
bottemName: 'amounttotalThismonth',
bottomValue: '0',
bottomType: 'money'
},
{
name: '商城采购额',
valueName: 'amountshop',
value: '0',
unit: '¥',
unitType: 'left',
bottomLabel: '本月采购额',
bottemName: 'amountshopThismonth',
bottomValue: '0',
bottomType: 'money'
},
{
name: '自采采购额',
valueName: 'amountself',
value: '0',
unit: '¥',
unitType: 'left',
bottomLabel: '本月采购额',
bottemName: 'amountselfThismonth',
bottomValue: '0',
bottomType: 'money'
}
],
// 商城采购数据
shopmallData: [],
// 自采采购数据
selfPickData: [],
businessTime: '',
merchantMerDataList: [],
merchantServiceDataList: []
}
},
created() {
this.$bus.$on('selectVal', data => {
this.$router.replace({
path: '/solarDetail',
query: {
merchantid: data.merchantid,
merchantname: data.merchantname,
purchaseType: this.purchaseType,
year: this.$store.state.app.solarYear
}
})
this.init()
})
},
methods: {
async init() {
this.tabObject = this.$route.query
const { merchantid, purchaseType, year } = this.$route.query
this.defaultYear = year
const _merchantList = await this.getAllRanking(purchaseType)
this.merchantList = _merchantList
this.purchaseType = purchaseType
this.getMerchantGoodsRatio(merchantid)
this.getMerchantPurchase(merchantid)
this.getMerchantPurchaseTrend(merchantid)
this.getYears(merchantid)
this.getMerchantMer(merchantid)
this.getMerchantServiceCenter(merchantid)
},
// 获取门店的商品采购占比(商城、自采)
getMerchantGoodsRatio(merchantid) {
this.api.solar.getMerchantGoodsRatio({ year: this.$store.state.app.solarYear, MerchantId: merchantid }).then(res => {
if (!res.code === '0') {
this.openMessage('获取门店商品采购占比失败')
return
}
this.shopmallData = res.data.dataList[0].shopgoodsRatioList.slice(0, 6) || []
this.selfPickData = res.data.dataList[0].selfgoodsRatioList.slice(0, 6) || []
})
},
// 获取每个门店的 总采购额(总计、本月) 、商城采购额(总计、本月) 、自采采购额(总计、本月)
getMerchantPurchase(merchantid) {
this.api.solar.getMerchantPurchase({ year: this.$store.state.app.solarYear, MerchantId: merchantid }).then(res => {
if (!res.code === '0') {
this.openMessage('获取门店采购额趋势失败')
return
}
const _dataList = res.data.dataList[0]
if (_dataList) {
this.businessTime = _dataList.businessstarttime
this.solarDetailList.forEach(item => {
item.value = _dataList[item.valueName]
item.bottomValue = _dataList[item.bottemName]
})
}
})
},
// 获取每个门店的商城采购额(占比)、自采采购额(占比) 趋势
getMerchantPurchaseTrend(merchantid) {
this.api.solar.getMerchantPurchaseTrend({ year: this.$store.state.app.solarYear, MerchantId: merchantid }).then(res => {
if (!res.code === '0') {
this.openMessage('获取门店商品采购占比失败')
return
}
if (!res.data || !res.data.dataList.length) {
this.isEmpty = true
return
}
const _dataList = res.data.dataList
_dataList.forEach((item, index) => {
this.dataList[index] = {
month: item.statDate,
data1: item.shopamount,
data2: item.selfamount,
data3: item.shopratio
}
})
this.$refs.merchantsTrends.$refs.purchaseTrend.drawBarLine()
})
},
// 获取所有门店数据
getAllRanking(purchaseType) {
return new Promise(resolve => {
let _merchantList
this.api.solar.getAllRanking({ year: this.$store.state.app.solarYear }).then(res => {
if (!res.code === '0') {
this.openMessage('获取商品采购额排名失败')
return
}
const _data = res.data.dataList[0]
_merchantList = _data[purchaseType]
resolve(_merchantList)
})
})
},
// 获取年份数据参数门店id
async getYears(MerchantId) {
this.yearList = [
{
label: '全部',
value: ''
}
]
const _data = await this.api.solar.getYears({ MerchantId })
const _yearList = _data.data.dataList[0].year.reverse()
_yearList.forEach(item => {
this.yearList.push({
label: item,
value: item + ''
})
})
this.defaultYear = this.yearList[0].value
},
// 获取每个门店的门店采购额和入库情况
getMerchantMer(merchantid) {
this.api.solar.getMerchantMer({ year: this.$store.state.app.solarYear, MerchantId: merchantid }).then(res => {
if (!res.code === '0') {
this.openMessage('获取每个门店的门店采购额和入库情况失败')
return
}
const _dataList = res.data.dataList
this.merchantMerDataList = _dataList
})
},
// 获取每个门店的服务中心的采购额和入库情况
getMerchantServiceCenter(merchantid) {
this.api.solar.getMerchantServiceCenter({ year: this.$store.state.app.solarYear, merchantid: merchantid }).then(res => {
if (!res.code === '0') {
this.openMessage('获取每个门店的服务中心的采购额和入库情况失败')
return
}
const _dataList = res.data.dataList
this.merchantServiceDataList = _dataList
})
}
}
}
</script>
<style lang="scss" scoped>
.solar-detail-content {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 1.78vh 24px;
gap: 0 16px;
&-bottom {
margin-top: 1.78vh;
display: flex;
justify-content: space-between;
}
.statistic-box {
margin-top: 1.78vh;
}
}
.service-box,
.merchant-box {
width: 31.53vw;
height: 32.56vh;
box-shadow: inset 0 0 20px 0 #3d57ff69;
}
.merchant-box {
margin-top: 1.78vh;
}
.main-table {
padding: 1.11vh 1.39vw 2.44vh;
}
</style>