PurchaseRank.vue
5.47 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
<!-- 采购额排名 -->
<template>
<div class="purchase-rank-box">
<box-title title="采购额排名"></box-title>
<div class="content-box">
<!-- 采购选项下拉 -->
<div class="purchase-plugin">
<div class="purchase" @click.stop="switchPurchase">
{{ purchase.labelName }}
<img class="arrow-down" src="@/assets/images/arrow-down.png" alt="" />
</div>
<SelectBox :isShow="isShow" @clickOutside="clickOutside" isObject :dataList="purchaseList" :boxWidth="'28.61vw'" @selectVal="selectPurchase" :labelName="'labelName'"></SelectBox>
<!-- <div v-show="isShow" class="select-purchase">
<div class="purchase-item" :class="purchase == item ? 'active' : ''" v-for="(item, index) in purchaseList" :key="index" @click.s="selectPurchase(item)">{{ item }}</div>
</div> -->
</div>
<!-- 门店排行 -->
<div v-if="merchantsList.length" class="merchant-box">
<ranking :rankingsList="merchantsList" :rankingDataObj="merchantsDataObj" :isMultiple="false" @goDetailPage="goDetailPage"></ranking>
</div>
<div v-else class="empty">
<Empty></Empty>
</div>
</div>
</div>
</template>
<script>
import { changeMixin } from '@/mixins'
import { mapActions } from 'vuex'
export default {
name: 'PurchaseRank',
mixins: [changeMixin],
data() {
return {
// 采购额排名下拉框显示
isShow: false,
// 采购额排名下拉框数据
purchaseList: [
{
labelName: '总采购额排行-商城采购',
value: 'shopranking'
},
{
labelName: '近三月采购额排行-商城采购',
value: 'shoprankingnear3'
},
{
labelName: '总采购额排行-自采',
value: 'selfranking'
},
{
labelName: '近三月采购额排行-自采',
value: 'selfrankingnear3'
}
],
rankingList: {},
// 采购额排名当前选中值
purchase: {},
// 采购额排名门店数据
merchantsList: [],
merchantsDataObj: [
{
name: 'merchantname',
width: '20.3vw',
action: true
},
{
name: 'num',
type: 'number'
}
]
}
},
mounted() {
this.purchase = this.purchaseList[0]
},
methods: {
...mapActions(['setMerchantRankingList']),
init() {
this.getAllRanking()
},
// 获取各类商品采购额排名
getAllRanking() {
this.api.solar.getAllRanking({ year: this.$store.state.app.solarYear }).then(res => {
if (!res.code === '0') {
this.openMessage('获取商品采购额排名失败')
return
}
this.rankingList = res.data.dataList[0]
this.merchantsList = this.rankingList[this.purchase.value || this.purchaseList[0].value].slice(0, 5)
this.setMerchantRankingList(this.merchantsList)
})
},
// 排名下拉显示/隐藏
switchPurchase() {
this.isShow = !this.isShow
},
// 排名下拉选中
selectPurchase(item) {
this.purchase = item
const purchaseIndex = this.purchaseList.findIndex(itm => itm.value === item.value)
// 只获取排名前五的数据
this.merchantsList = this.rankingList[this.purchaseList[purchaseIndex].value].slice(0, 5)
this.setMerchantRankingList(this.merchantsList)
this.switchPurchase()
},
// 跳转太阳膜详情页
goDetailPage(item) {
// this.$router.push({ path: `solarDetail?merchantid=${item.merchantid}&merchantname=${item.merchantname}&purchaseType=${this.purchase.value}` })
const routeData = this.$router.resolve({
name: 'solarDetail',
query: {
merchantid: item.merchantid,
merchantname: item.merchantname,
purchaseType: this.purchase.value,
year: this.$store.state.app.solarYear
}
})
window.open(routeData.href, '_blank')
},
// 点击外部控制排名下拉隐藏
clickOutside() {
this.isShow = false
}
}
}
</script>
<style lang="scss" scoped>
.purchase-rank-box {
width: 100%;
background: #061422;
box-shadow: inset 0 0 20px 0 #3d57ff69;
height: 27.33vh;
margin-bottom: 1.78vh;
.content-box {
padding: 1.11vh 1.39vw 0 1.39vw;
}
.purchase-plugin {
position: relative;
}
.select-purchase {
position: absolute;
top: 2.86vh;
width: 28.61vw;
background-color: #051526;
padding: 16px 20px;
box-sizing: border-box;
border: 2px solid;
border-image: linear-gradient(90deg, #074989, #30dcff, #074989) 1;
.purchase-item {
margin-bottom: 8px;
color: #c9c9c9;
max-width: 25.83vw;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
&:hover {
color: #ffffff;
}
&:last-child {
margin-bottom: 0;
}
&.active {
color: #ffffff;
}
}
}
.purchase {
display: flex;
align-items: center;
justify-content: space-between;
width: 28.61vw;
// height: 5.7vh;
padding: 0 0.56vw;
box-sizing: border-box;
background-image: linear-gradient(270deg, #6578ff 0%, #079ff1 100%);
font-weight: 400;
font-size: 14px;
margin-right: 0.56vw;
color: #ffffff;
.arrow-down {
width: 0.69vw;
height: 0.67vh;
}
}
.merchant-box {
margin-top: 2.06vh;
}
.empty {
height: 19vh;
display: flex;
align-items: center;
}
}
</style>