|
1
2
3
4
5
6
7
8
9
|
<template>
<!-- , width: fixedHeader ? `calc(100% - ${sidebarOpened ? 256 : 80}px)` : '100%' -->
<a-layout-header
v-if="!headerBarFixed"
:class="[fixedHeader && 'ant-header-fixedHeader', sidebarOpened ? 'ant-header-side-opened' : 'ant-header-side-closed', ]"
:style="{ padding: '0' }">
<div v-if="mode === 'sidemenu'" class="header" :class="theme">
<a-icon
|
谭毅彬
authored
|
10
|
v-if="device === 'mobile'"
|
|
11
12
|
class="trigger"
:type="collapsed ? 'menu-fold' : 'menu-unfold'"
|
谭毅彬
authored
|
13
14
15
|
@click="toggle"
></a-icon>
<a-icon v-else class="trigger" :type="collapsed ? 'menu-unfold' : 'menu-fold'" @click="toggle" />
|
|
16
|
|
|
17
18
|
<span style="height:59px;line-height:59px;" v-if="device === 'desktop'">欢迎进入 华恒仓储管理系统</span>
<span style="height:59px;line-height:59px;color: #d71345" v-if="manual === 'desktop'">{{ expirationTime }}</span>
|
谭毅彬
authored
|
19
|
<user-menu :theme="theme" />
|
|
20
21
22
23
24
|
</div>
<!-- 顶部导航栏模式 -->
<div v-else :class="['top-nav-header-index', theme]">
<div class="header-index-wide">
<div class="header-index-left" :style="topMenuStyle.headerIndexLeft">
|
谭毅彬
authored
|
25
|
<logo class="top-nav-header" :show-title="device !== 'mobile'" :style="topMenuStyle.topNavHeader" />
|
|
26
|
<div v-if="device !== 'mobile'" :style="topMenuStyle.topSmenuStyle">
|
谭毅彬
authored
|
27
|
<s-menu mode="horizontal" :menu="menus" :theme="theme" @updateMenuTitle="handleUpdateMenuTitle"></s-menu>
|
|
28
|
</div>
|
谭毅彬
authored
|
29
|
<a-icon v-else class="trigger" :type="collapsed ? 'menu-fold' : 'menu-unfold'" @click="toggle"></a-icon>
|
|
30
|
</div>
|
谭毅彬
authored
|
31
|
<user-menu class="header-index-right" :theme="theme" :style="topMenuStyle.headerIndexRight" />
|
|
32
33
34
35
36
37
|
</div>
</div>
</a-layout-header>
</template>
<script>
|
|
38
39
40
|
import UserMenu from '../tools/UserMenu'
import SMenu from '../menu/'
import Logo from '../tools/Logo'
|
|
41
|
import { querySystemActivationInfo } from '@/api/api'
|
谭毅彬
authored
|
42
|
import { mixin } from '@/utils/mixin.js'
|
|
43
|
import { downFile } from '@/api/manage'
|
|
44
|
|
|
45
46
47
48
49
|
export default {
name: 'GlobalHeader',
components: {
UserMenu,
SMenu,
|
谭毅彬
authored
|
50
|
Logo
|
|
51
52
53
54
55
56
57
|
},
mixins: [mixin],
props: {
mode: {
type: String,
// sidemenu, topmenu
default: 'sidemenu'
|
|
58
|
},
|
|
59
60
61
|
menus: {
type: Array,
required: true
|
|
62
|
},
|
|
63
64
65
66
|
theme: {
type: String,
required: false,
default: 'dark'
|
|
67
|
},
|
|
68
69
70
71
|
collapsed: {
type: Boolean,
required: false,
default: false
|
|
72
|
},
|
|
73
74
75
76
|
device: {
type: String,
required: false,
default: 'desktop'
|
|
77
|
},
|
谭毅彬
authored
|
78
|
manual: {
|
|
79
80
81
|
type: String,
required: false,
default: 'desktop'
|
谭毅彬
authored
|
82
|
}
|
|
83
84
85
86
|
},
data() {
return {
headerBarFixed: false,
|
|
87
|
//update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
|
|
88
89
90
91
92
93
|
topMenuStyle: {
headerIndexLeft: {},
topNavHeader: {},
headerIndexRight: {},
topSmenuStyle: {}
},
|
谭毅彬
authored
|
94
|
expirationTime: '',
|
|
95
|
chatStatus: '',
|
谭毅彬
authored
|
96
97
|
url: {
downLoad: '/sys/common/downLoad'
|
|
98
|
}
|
|
99
100
|
}
},
|
谭毅彬
authored
|
101
|
created() {
|
|
102
|
this.loadFrom()
|
谭毅彬
authored
|
103
|
},
|
|
104
105
106
|
watch: {
/** 监听设备变化 */
device() {
|
|
107
108
109
110
|
if (this.mode === 'topmenu') {
this.buildTopMenuStyle()
}
},
|
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/** 监听导航栏模式变化 */
mode(newVal) {
if (newVal === 'topmenu') {
this.buildTopMenuStyle()
}
}
},
//update-end--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
mounted() {
window.addEventListener('scroll', this.handleScroll)
//update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
if (this.mode === 'topmenu') {
this.buildTopMenuStyle()
}
//update-end--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
},
methods: {
handleScroll() {
if (this.autoHideHeader) {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
|
|
131
|
this.headerBarFixed = scrollTop > 100
|
|
132
133
134
135
|
} else {
this.headerBarFixed = false
}
},
|
谭毅彬
authored
|
136
137
|
loadFrom() {
querySystemActivationInfo().then(res => {
|
|
138
139
|
if (res.success && res.result) {
this.expirationTime = '系统授权到期日:' + res.result.expirationTime
|
谭毅彬
authored
|
140
141
142
|
}
})
},
|
|
143
144
145
|
toggle() {
this.$emit('toggle')
},
|
谭毅彬
authored
|
146
|
downWord() {
|
|
147
|
let fileName = '华恒WMS4操作说明书.doc'
|
谭毅彬
authored
|
148
|
return downFile(this.url.downLoad, fileName).then(data => {
|
|
149
|
debugger
|
谭毅彬
authored
|
150
|
this.$message.info('华恒WMS4操作说明书开始下载....')
|
|
151
|
if (!data || data.size === 0) {
|
谭毅彬
authored
|
152
|
this.$message.error('文件下载失败')
|
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data]), fileName)
} else {
let url = window.URL.createObjectURL(new Blob([data]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link) //下载完成移除元素
window.URL.revokeObjectURL(url) //释放掉blob对象
}
})
},
|
|
170
171
172
173
174
175
176
177
178
179
|
//update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
buildTopMenuStyle() {
if (this.mode === 'topmenu') {
if (this.device === 'mobile') {
// 手机端需要清空样式,否则显示会错乱
this.topMenuStyle.topNavHeader = {}
this.topMenuStyle.topSmenuStyle = {}
this.topMenuStyle.headerIndexRight = {}
this.topMenuStyle.headerIndexLeft = {}
} else {
|
|
180
|
let rightWidth = '356px'
|
谭毅彬
authored
|
181
182
183
184
|
this.topMenuStyle.topNavHeader = { 'min-width': '208px' }
this.topMenuStyle.topSmenuStyle = { width: 'calc(100% - 208px)' }
this.topMenuStyle.headerIndexRight = { 'min-width': rightWidth, 'white-space': 'nowrap' }
this.topMenuStyle.headerIndexLeft = { width: `calc(100% - ${rightWidth})` }
|
|
185
|
}
|
|
186
187
188
|
}
},
//update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
|
|
189
|
|
|
190
191
192
|
// update-begin-author:sunjianlei date:20210508 for: 修复动态功能测试菜单、带参数菜单标题错误、展开错误的问题
handleUpdateMenuTitle(value) {
this.$emit('updateMenuTitle', value)
|
谭毅彬
authored
|
193
|
}
|
|
194
|
// update-end-author:sunjianlei date:20210508 for: 修复动态功能测试菜单、带参数菜单标题错误、展开错误的问题
|
|
195
|
}
|
|
196
|
}
|
|
197
198
199
|
</script>
<style lang="less" scoped>
|
|
200
|
/* update_begin author:scott date:20190220 for: 缩小首页布局顶部的高度*/
|
|
201
|
|
|
202
|
@height: 59px;
|
|
203
|
|
|
204
205
206
|
.layout {
.top-nav-header-index {
.header-index-wide {
|
|
207
|
margin-left: 0px;
|
|
208
|
|
|
209
210
211
|
.ant-menu.ant-menu-horizontal {
height: @height;
line-height: @height;
|
|
212
213
214
|
}
}
|
|
215
|
.trigger {
|
|
216
217
|
height: 59px;
line-height: 59px;
|
|
218
|
|
|
219
|
&:hover {
|
|
220
221
222
223
224
|
background: rgba(0, 0, 0, 0.05);
}
}
}
|
|
225
226
227
|
.header {
z-index: 2;
color: white;
|
|
228
|
height: @height;
|
|
229
|
background-color: #111;
|
|
230
231
232
233
234
235
236
237
238
|
transition: background 300ms;
/* dark 样式 */
&.dark {
color: #000000;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
background-color: white !important;
}
|
|
239
240
|
}
|
谭毅彬
authored
|
241
242
|
.header,
.top-nav-header-index {
|
|
243
244
245
246
247
248
249
250
251
252
253
254
|
&.dark .trigger:hover {
background: rgba(0, 0, 0, 0.05);
}
}
}
.ant-layout-header {
height: @height;
line-height: @height;
}
/* update_end author:scott date:20190220 for: 缩小首页布局顶部的高度*/
|
|
255
|
</style>
|