333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
<template>
  <div class="navbar">
    <div class="sys-name"> {{ basicInfo.sysName }} </div>
    <hamburger :toggle-click="toggleSideBar" :is-active="sidebar.opened" class="hamburger-container" />
    <!-- <breadcrumb class="breadcrumb-container" /> -->
 
    <div class="right-menu">
      <template v-if="device!=='mobile'">
        <error-log class="errLog-container right-menu-item" />
 
        <!-- <el-tooltip :content="$t('navbar.screenfull')" class="right-menu-item" effect="dark" placement="bottom">
          <screenfull class="screenfull right-menu-item" />
        </el-tooltip> -->
 
        <!-- <el-tooltip :content="$t('navbar.size')" effect="dark" placement="bottom">
          <size-select class="right-menu-item"/>
        </el-tooltip> -->
 
        <!-- <lang-select class="right-menu-item" /> -->
 
        <!-- <el-tooltip :content="$t('navbar.theme')" effect="dark" placement="bottom">
          <theme-picker class="theme-switch right-menu-item"/>
        </el-tooltip> -->
      </template>
 
      <el-dropdown class="avatar-container right-menu-item" trigger="click">
        <div class="avatar-wrapper">
          <!-- <img :src="common.showFirstImage(basicInfo.icon)" class="user-avatar"> -->
          <span class="user-true-name">欢迎登录: {{ common.getUserInfo().userTrueName }}             </span>
          <i class="el-icon-caret-bottom" />
        </div>
        <el-dropdown-menu slot="dropdown">
          <router-link to="/">
            <el-dropdown-item>
              {{ $t('navbar.dashboard') }}
            </el-dropdown-item>
          </router-link>
          <el-dropdown-item>
            <span style="display:block;" @click="modifypwd">修改密码</span>
          </el-dropdown-item>
          <el-dropdown-item divided>
            <span style="display:block;" @click="logout">{{ $t('navbar.logOut') }}</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
 
    <!--修改密码弹出页面-->
    <modify-pwd ref="modifypwd-dialog" :visible.sync="modifyPwdVisible"></modify-pwd>
  </div>
</template>
 
<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import ErrorLog from '@/components/ErrorLog'
import Screenfull from './Screenfull'
import SizeSelect from './SizeSelect'
import LangSelect from '@/components/LangSelect'
import ModifyPwd from '@/views/sys/permission/components/modify-pwd'
 
export default {
  components: {
    Breadcrumb,
    Hamburger,
    ErrorLog,
    Screenfull,
    SizeSelect,
    LangSelect,
    ModifyPwd
  },
  data() {
    return {
      // 系统信息
      basicInfo: {},
      // 修改密码页面默认不显示
      modifyPwdVisible: false
    }
  },
  computed: {
    VersionName: function() {
      var userInfo = this.common.getUserInfo()
      if (userInfo.VersionName) {
        return '(' + userInfo.VersionName + ')'
      } else {
        return ''
      }
    },
    ...mapGetters(['sidebar', 'name', 'avatar', 'device'])
  },
  created() {
    this.getBasicInfo()
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('toggleSideBar')
    },
    /*
    logout() {
      this.$store.dispatch('LogOut').then(() => {
        var storageKey = '$tokenInfo' + this.$store.getters.userType
        localStorage.removeItem(storageKey)
        location.reload()
      })
    },
    //*/
    logout() {
      //debugger;
      //alert(2);
      var url = "/api/auth/logOut";
      var params={
        userName: this.common.getUserInfo().userName,
        sourceMachine:'WMS'
      }
      var callback = res => {
        if (res.result) {
           this.$store.dispatch('LogOut').then(() => {
             var storageKey = '$tokenInfo' + this.$store.getters.userType
             localStorage.removeItem(storageKey)
             location.reload()
           })
        } else {
          this.$message.error(res.msg);
        }
      };
      this.common.ajax(url, params, callback);
    },
    // 获得系统信息
    getBasicInfo() {
      const href = window.location.href
      const url = '/api/sys/basicInfo/getSysInfo'
      this.common.ajax(url, { href: href }, res => {
        this.basicInfo = res.data
        this.$store.dispatch('setBasicInfo', this.basicInfo)
        this.common.basicInfo = res.data // 记录权限
        document.title = this.basicInfo.sysName
        let $favicon = document.querySelector('link[rel="icon"]')
        const link = this.basicInfo.icon
        if ($favicon !== null) {
          $favicon.href = link
        } else {
          $favicon = document.createElement('link')
          $favicon.rel = 'icon'
          $favicon.href = link
          document.head.appendChild($favicon)
        }
      })
    },
    modifypwd() {
      this.modifyPwdVisible = true
    },
    iconUrl(images) {
      if (images) {
        if (images.indexOf('[') >= 0) {
          const imgs = JSON.parse(images)
          return imgs[0].src
        } else {
          return images
        }
      }
      return ''
    }
  }
}
</script>
 
<style rel="stylesheet/scss" lang="scss" scoped>
.navbar {
  height: 50px;
  border-radius: 0px !important;
  background-color: white;
  .sys-name {
    padding: 13px 10px 10px;
    font-size: 20px;
    display: inline-block;
  }
  .user-true-name {
    position: relative;
    top: -5px;
  }
  .hamburger-container {
    line-height: 58px;
    height: 50px;
    float: left;
    padding: 0 10px;
  }
  .breadcrumb-container {
    float: left;
  }
  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }
  .right-menu {
    float: right;
    height: 100%;
    &:focus {
      outline: none;
    }
    .right-menu-item {
      display: inline-block;
      margin: 0 8px;
      height: 50px;
      vertical-align: text-top;
      padding-top: 15px;
    }
    .theme-switch {
      vertical-align: 15px;
    }
    .avatar-container {
      height: 50px;
      margin-right: 100px;
      .avatar-wrapper {
        cursor: pointer;
        position: relative;
        .user-avatar {
          width: 200px;
          height: 34px;
          border-radius: 24px;
        }
        .el-icon-caret-bottom {
          position: absolute;
          right: 85px;
          top: 10px;
          font-size: 22px;
        }
      }
    }
  }
}
</style>