ViewTitle.vue
6.65 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
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2022-10-25 10:12:26
* @LastEditors: huyue
* @LastEditTime: 2023-08-24 15:52:22
* @FilePath: \dj-data-view\src\components\ViewTitle.vue
* @Description: 页面头部组件
-->
<template>
<div class="content flex">
<div class="logo user-select">
<img style="height: 48px" src="@/assets/images/logo.png" alt="logo" />
</div>
<div class="tab">
<div v-for="(item, index) in menuList" :key="index">
<template v-if="item.tabName == 'business' && item.isShow">
<div class="tab-item first-tab" :class="currentMenu == item.tabName ? 'active' : ''" @click.prevent="jump(item.tabName)">
<div class="tab-title">{{ firstTab.label }}</div>
<img class="arrow-down" @click.stop="openSelect" src="@/assets/images/title-arrow.png" alt="">
<SelectBox :isShow="isShow" @clickOutside="clickOutside" :dataList="item.children" :boxWidth="'16.94vw'" isObject @selectVal="selectVal"></SelectBox>
</div>
</template>
<template v-else>
<div v-show="item.isShow" class="tab-item other-tab" :class="currentMenu == item.tabName ? 'active' : ''" @click="jump(item.tabName)">
<div class="tab-name">{{item.label}}</div>
</div>
</template>
</div>
</div>
<!-- <div class="tab">
<div class="tab-item first-tab" :class="currentMenu == 'home' ? 'active' : ''" @click.prevent="jump('home')">
<div class="tab-title">{{ firstTab.label }}</div>
<img class="arrow-down" @click.stop="openSelect" src="@/assets/images/title-arrow.png" alt="">
<SelectBox :isShow="isShow" @clickOutside="clickOutside" :dataList="dataList" :boxWidth="'16.94vw'" isObject @selectVal="selectVal"></SelectBox>
</div> -->
<!-- <div class="tab-item other-tab" :class="currentMenu == 'operational' ? 'active' : ''" @click="jump('operational')">
<div class="tab-name">运营数据</div>
</div>
<div class="tab-item other-tab" :class="currentMenu == 'interior' ? 'active' : ''" @click="jump('interior')">
<div class="tab-name">内部数据</div>
</div> -->
<!-- </div> -->
<!-- <div class="view-title user-select">嘀加智慧门店运营看板</div> -->
<div class="time">
<div class="top flex">
{{ weekList[week] }}
<div class="now">{{ now }}</div>
</div>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import datas from '@/utils/data'
export default {
name: 'ViewTitle',
data() {
return {
isShow: false,
// dataList: datas.DefaultData.businessList,
menuList: datas.DefaultData.menuList,
weekList: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
firstTab: '', // 存储第一个tab下的子菜单对象
now: new Date().format('yyyy-MM-dd hh:mm:ss'),
week: new Date().getDay(),
currentMenu: 'home' // 标记当前是哪个tab菜单
}
},
created() {
const { menuList, $roleAuth, $role } = this
const permissions = $roleAuth[$role]
menuList.forEach(menu => {
if (menu.children) {
menu.children = menu.children.filter(child => {
child.isShow = permissions[child.value]
return child.isShow
})
menu.isShow = menu.children.length > 0
} else {
menu.isShow = permissions[menu.value]
}
})
this.menuList = menuList.filter(item => item.isShow)
this.firstTab = this.menuList[0].children ? this.menuList[0].children[0] : this.menuList[0]
this.jump(this.firstTab.tabName)
},
mounted() {
this.timer()
},
methods: {
timer() {
setInterval(() => {
this.now = new Date().format('yyyy-MM-dd hh:mm:ss')
}, 1e3)
},
openSelect() {
this.isShow = !this.isShow
},
// 监听子菜单变化
selectVal(val) {
this.firstTab = val
this.$bus.$emit('selectVal', val.value)
this.openSelect()
},
// tab菜单切换
jump(val) {
let _val = val
this.currentMenu = val
if (val === 'business') _val = this.firstTab.value
this.$bus.$emit('selectVal', _val)
this.isShow = false
},
clickOutside() {
this.isShow = false
}
}
}
</script>
<style scoped lang="scss">
.content {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 26px 0 24px;
justify-content: space-between;
.view-title {
font-weight: 600;
font-size: 24px;
color: #ffffff;
letter-spacing: 8px;
text-align: center;
}
.time {
text-align: right;
font-size: 14px;
color: #ffffff;
.top {
justify-content: flex-end;
.now {
width: 11.2vw;
}
}
.icon {
width: 14px;
height: 14px;
margin-right: 8px;
}
}
}
.tab {
display: flex;
// align-items: center;
color: #FFFFFF;
font-size: 16px;
&-item {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: 4.44vh;
// padding: 0 1.36vw;
box-sizing: border-box;
margin-right: 0.56vw;
border: 2px solid;
border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;
background-image: linear-gradient(180deg, #001948 0%, #00223C 99%);
cursor: pointer;
.tab-title {
max-width: 18.61vw;
}
}
.first-tab {
position: relative;
width: 16.94vw;
box-sizing: border-box;
justify-content: flex-start;
padding-left: 1.39vw;
&.active {
background-image: url('../assets/images/first-tab-bg.png');
background-repeat: no-repeat;
background-size: 100% 100%;
border: none;
.tab-title {
color: #5894FF;
background-image: -webkit-linear-gradient(left, #24D8FF, #7787FF);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
.arrow-down {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 1.39vw;
margin-left: 0.28vw;
width: 1.39vw;
height: 2.22vh;
}
}
.other-tab{
width: 7.22vw;
box-sizing: border-box;
&.active {
background-image: url('../assets/images/other-tab-bg.png');
background-repeat: no-repeat;
background-size: 100% 100%;
border: none;
.tab-name {
color: #5894FF;
background-image: -webkit-linear-gradient(left, #24D8FF, #7787FF);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
}
}
</style>