Blame view

ant-design-vue-jeecg/src/components/page/GlobalHeader.vue 6.7 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<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
        v-if="device==='mobile'"
        class="trigger"
        :type="collapsed ? 'menu-fold' : 'menu-unfold'"
        @click="toggle"></a-icon>
      <a-icon
        v-else
        class="trigger"
        :type="collapsed ? 'menu-unfold' : 'menu-fold'"
        @click="toggle"/>
陈翱 authored
20
      <span style="height:59;line-height:59px;" v-if="device === 'desktop'">欢迎进入武汉飞浦通用设备公司仓储管理系统</span>
puff authored
21
<!--      <a v-bind:href="url.downLoad" style="height:59;line-height:59px;color: #d71345" v-if="manual === 'desktop'">  WMS操作手册</a>-->
陈翱 authored
22
      <span v-else>武汉飞浦通用设备公司仓储管理系统</span>
肖超群 authored
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

      <user-menu :theme="theme"/>
    </div>
    <!-- 顶部导航栏模式 -->
    <div v-else :class="['top-nav-header-index', theme]">
      <div class="header-index-wide">
        <div class="header-index-left" :style="topMenuStyle.headerIndexLeft">
          <logo class="top-nav-header" :show-title="device !== 'mobile'" :style="topMenuStyle.topNavHeader"/>
          <div v-if="device !== 'mobile'" :style="topMenuStyle.topSmenuStyle">
            <s-menu
              mode="horizontal"
              :menu="menus"
              :theme="theme"
              @updateMenuTitle="handleUpdateMenuTitle"
            ></s-menu>
          </div>
          <a-icon
            v-else
            class="trigger"
            :type="collapsed ? 'menu-fold' : 'menu-unfold'"
            @click="toggle"></a-icon>
        </div>
        <user-menu class="header-index-right" :theme="theme" :style="topMenuStyle.headerIndexRight"/>
      </div>
    </div>

  </a-layout-header>
</template>

<script>
肖超群 authored
53
54
55
import UserMenu from '../tools/UserMenu'
import SMenu from '../menu/'
import Logo from '../tools/Logo'
唐高鑫 authored
56
import {downLoad} from '@/api/api'
肖超群 authored
57
import {mixin} from '@/utils/mixin.js'
唐高鑫 authored
58
import {axios} from '@/utils/axios.js'
肖超群 authored
59
60
61
62
63
64
65
66
67
68
69
70
71
export default {
  name: 'GlobalHeader',
  components: {
    UserMenu,
    SMenu,
    Logo,
  },
  mixins: [mixin],
  props: {
    mode: {
      type: String,
      // sidemenu, topmenu
      default: 'sidemenu'
肖超群 authored
72
    },
肖超群 authored
73
74
75
    menus: {
      type: Array,
      required: true
肖超群 authored
76
    },
肖超群 authored
77
78
79
80
    theme: {
      type: String,
      required: false,
      default: 'dark'
肖超群 authored
81
    },
肖超群 authored
82
83
84
85
    collapsed: {
      type: Boolean,
      required: false,
      default: false
肖超群 authored
86
    },
肖超群 authored
87
88
89
90
    device: {
      type: String,
      required: false,
      default: 'desktop'
唐高鑫 authored
91
92
93
94
95
96
97
    },
    manual:{
      type: String,
      required: false,
      default: 'desktop'
    },
肖超群 authored
98
99
100
101
  },
  data() {
    return {
      headerBarFixed: false,
肖超群 authored
102
      //update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
肖超群 authored
103
104
105
106
107
108
109
      topMenuStyle: {
        headerIndexLeft: {},
        topNavHeader: {},
        headerIndexRight: {},
        topSmenuStyle: {}
      },
      chatStatus: '',
唐高鑫 authored
110
111
112
      url:{
        downLoad:"/wms/sys/common/downLoad"
      }
肖超群 authored
113
114
115
116
117
    }
  },
  watch: {
    /** 监听设备变化 */
    device() {
肖超群 authored
118
119
120
121
      if (this.mode === 'topmenu') {
        this.buildTopMenuStyle()
      }
    },
肖超群 authored
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
    /** 监听导航栏模式变化 */
    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
        if (scrollTop > 100) {
          this.headerBarFixed = true
肖超群 authored
144
145
146
        } else {
          this.headerBarFixed = false
        }
肖超群 authored
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
      } else {
        this.headerBarFixed = false
      }
    },
    toggle() {
      this.$emit('toggle')
    },
    //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 {
谭毅彬 authored
164
165
166
          let rightWidth = '356px'
          this.topMenuStyle.topNavHeader = {'min-width': '208px'}
          this.topMenuStyle.topSmenuStyle = {'width': 'calc(100% - 208px)'}
肖超群 authored
167
168
          this.topMenuStyle.headerIndexRight = {'min-width': rightWidth, 'white-space': 'nowrap'}
          this.topMenuStyle.headerIndexLeft = {'width': `calc(100% - ${rightWidth})`}
肖超群 authored
169
        }
肖超群 authored
170
171
172
      }
    },
    //update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮-----
肖超群 authored
173
肖超群 authored
174
175
176
177
178
    // update-begin-author:sunjianlei date:20210508 for: 修复动态功能测试菜单、带参数菜单标题错误、展开错误的问题
    handleUpdateMenuTitle(value) {
      this.$emit('updateMenuTitle', value)
    },
    // update-end-author:sunjianlei date:20210508 for: 修复动态功能测试菜单、带参数菜单标题错误、展开错误的问题
肖超群 authored
179
180

  }
肖超群 authored
181
}
肖超群 authored
182
183
184
</script>

<style lang="less" scoped>
肖超群 authored
185
/* update_begin author:scott date:20190220 for: 缩小首页布局顶部的高度*/
肖超群 authored
186
肖超群 authored
187
@height: 59px;
肖超群 authored
188
肖超群 authored
189
.layout {
肖超群 authored
190
肖超群 authored
191
  .top-nav-header-index {
肖超群 authored
192
肖超群 authored
193
    .header-index-wide {
谭毅彬 authored
194
      margin-left: 0px;
肖超群 authored
195
肖超群 authored
196
197
198
      .ant-menu.ant-menu-horizontal {
        height: @height;
        line-height: @height;
肖超群 authored
199
200
201
      }
    }
肖超群 authored
202
    .trigger {
谭毅彬 authored
203
204
      height: 59px;
      line-height: 59px;
肖超群 authored
205
      &:hover {
肖超群 authored
206
207
208
209
210
        background: rgba(0, 0, 0, 0.05);
      }
    }
  }
肖超群 authored
211
212
213
  .header {
    z-index: 2;
    color: white;
肖超群 authored
214
    height: @height;
谭毅彬 authored
215
    background-color: #111;
肖超群 authored
216
217
218
219
220
221
222
223
224
    transition: background 300ms;

    /* dark 样式 */

    &.dark {
      color: #000000;
      box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
      background-color: white !important;
    }
肖超群 authored
225
226
  }
肖超群 authored
227
228
229
230
231
232
233
234
235
236
237
238
239
  .header, .top-nav-header-index {
    &.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: 缩小首页布局顶部的高度*/
肖超群 authored
240
241

</style>