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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<template>
  <a-layout class="layout" :class="[device]"
            :style="{backgroundImage:$route.meta.title==='首页'?`url(${require('../../assets/page/index/background.svg')}) !important`:`url(${require('../../assets/page/background.svg')})!important`}">
 
    <!--<a-drawer-->
    <!--v-if="device === 'mobile'"-->
    <!--:wrapClassName="'drawer-sider ' + navTheme"-->
    <!--placement="left"-->
    <!--@close="() => this.collapsed = false"-->
    <!--:closable="false"-->
    <!--:visible="collapsed"-->
    <!--width="200px"-->
    <!--&gt;-->
    <!--<side-menu-->
    <!--mode="inline"-->
    <!--v-if="device === 'mobile'"-->
    <!--:menus="menus"-->
    <!--@menuSelect="menuSelect"-->
    <!--@updateMenuTitle="handleUpdateMenuTitle"-->
    <!--:theme="navTheme"-->
    <!--:collapsed="false"-->
    <!--:collapsible="true"></side-menu>-->
    <!--</a-drawer>-->
 
    <side-menu
      mode="inline"
      :menus="menus"
      @menuSelect="myMenuSelect"
      @updateMenuTitle="handleUpdateMenuTitle"
      :collapsed="true"
      :collapsible="true"></side-menu>
 
 
    <a-layout
      :class="[layoutMode, `content-width-${contentWidth}`]">
      <!--<global-header></global-header>-->
 
      <!-- layout content -->
      <a-layout-content :style="{ height: '100%' }">
        <slot></slot>
      </a-layout-content>
 
      <!-- layout footer -->
      <a-layout-footer style="padding: 0px;background-color: transparent">
        <global-footer/>
      </a-layout-footer>
    </a-layout>
 
    <!-- update-start---- author:os_chengtgen -- date:20190830 --  for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ---- -->
    <!--<setting-drawer></setting-drawer>-->
    <!-- update-end---- author:os_chengtgen -- date:20190830 --  for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ---- -->
  </a-layout>
</template>
 
<script>
  import SideMenu from '@/components/menu/SideMenu'
  import GlobalHeader from '@/components/page/GlobalHeader'
  import GlobalFooter from '@/components/page/GlobalFooter'
  import { triggerWindowResizeEvent } from '@/utils/util'
  import { mapActions, mapState } from 'vuex'
  import { mixin, mixinDevice } from '@/utils/mixin.js'
  // update-start---- author:os_chengtgen -- date:20190830 --  for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
  // import SettingDrawer from '@/components/setting/SettingDrawer'
  // 注释这个因为在个人设置模块已经加载了SettingDrawer页面
  // update-end ---- author:os_chengtgen -- date:20190830 --  for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
 
  export default {
    name: 'GlobalLayout',
    components: {
      SideMenu,
      GlobalHeader,
      GlobalFooter
      // update-start---- author:os_chengtgen -- date:20190830 --  for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
      // // SettingDrawer
      // 注释这个因为在个人设置模块已经加载了SettingDrawer页面
      // update-end ---- author:os_chengtgen -- date:20190830 --  for:issues/463 -编译主题颜色已生效,但还一直转圈,显示主题 正在编译 ------
 
    },
    mixins: [mixin, mixinDevice],
    data() {
      return {
        collapsed: false,
        activeMenu: {},
        menus: []
      }
    },
    computed: {
      ...mapState({
        // 主路由
        mainRouters: state => state.permission.addRouters,
        // 后台菜单
        permissionMenuList: state => state.user.permissionList
      })
    },
    watch: {
      sidebarOpened(val) {
        this.collapsed = !val
      }
    },
    created() {
      //--update-begin----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
      //this.menus = this.mainRouters.find((item) => item.path === '/').children;
      this.menus = this.permissionMenuList
 
      //--update-begin----author:liusq---date:20210223------for:关于测边菜单遮挡内容问题详细说明 #2255
      this.collapsed = !this.sidebarOpened
      //--update-begin----author:liusq---date:20210223------for:关于测边菜单遮挡内容问题详细说明 #2255
 
      // 根据后台配置菜单,重新排序加载路由信息
      //console.log('----加载菜单逻辑----')
      //console.log(this.mainRouters)
      //console.log(this.permissionMenuList)
      //console.log('----navTheme------'+this.navTheme)
      //--update-end----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------
    },
    methods: {
      ...mapActions(['setSidebar']),
      toggle() {
        this.collapsed = !this.collapsed
        this.setSidebar(!this.collapsed)
        triggerWindowResizeEvent()
      },
      menuSelect() {
        if (!this.isDesktop()) {
          this.collapsed = false
        }
      },
      //update-begin-author:taoyan date:20190430 for:动态路由title显示配置的菜单title而不是其对应路由的title
      myMenuSelect(value) {
        //此处触发动态路由被点击事件
        this.findMenuBykey(this.menus, value.key)
        this.$emit('dynamicRouterShow', value.key, this.activeMenu.meta.title)
      },
      findMenuBykey(menus, key) {
        for (let i of menus) {
          if (i.path == key) {
            this.activeMenu = { ...i }
          } else if (i.children && i.children.length > 0) {
            this.findMenuBykey(i.children, key)
          }
        }
      },
      //update-end-author:taoyan date:20190430 for:动态路由title显示配置的菜单title而不是其对应路由的title
 
      // update-begin-author:sunjianlei date:20210409 for: 修复动态功能测试菜单、带参数菜单标题错误、展开错误的问题
      handleUpdateMenuTitle(value) {
        this.findMenuBykey(this.menus, value.path)
        this.activeMenu.meta.title = value.meta.title
        this.$emit('dynamicRouterShow', value.path, this.activeMenu.meta.title)
      }
      // update-end-author:sunjianlei date:20210409 for: 修复动态功能测试菜单、带参数菜单标题错误、展开错误的问题
 
    }
  }
 
</script>
 
<style lang="less">
  body {
    &.colorWeak {
      filter: invert(80%);
    }
  }
 
  .layout {
    min-height: 100vh !important;
    overflow-x: hidden;
    background-size: cover !important;
    background-repeat: no-repeat !important;
 
    &.mobile {
      .ant-layout-content {
        .content {
          margin: 24px 0 0;
        }
      }
 
      &.ant-layout-has-sider {
        flex-direction: row;
      }
 
      .trigger {
        font-size: 22px;
        line-height: 42px;
        padding: 0 18px;
        cursor: pointer;
        transition: color 300ms, background 300ms;
 
        &:hover {
          background: rgba(255, 255, 255, 0.3);
        }
      }
 
    }
 
    .sidemenu {
      background-color: transparent;
    }
 
  }
 
  // drawer-sider 自定义
  .ant-drawer.drawer-sider {
    .sider {
      box-shadow: none;
    }
 
    &.dark {
      .ant-drawer-content {
        background-color: rgb(0, 21, 41);
      }
    }
    &.light {
      box-shadow: none;
      .ant-drawer-content {
        background-color: #fff;
      }
    }
 
    .ant-drawer-body {
      padding: 0
    }
  }
 
  // 外置的样式控制
  .user-dropdown-menu-wrapper.ant-dropdown-menu {
    padding: 4px 0;
 
    .ant-dropdown-menu-item {
      width: 160px;
    }
 
    .ant-dropdown-menu-item > .anticon:first-child,
    .ant-dropdown-menu-item > a > .anticon:first-child,
    .ant-dropdown-menu-submenu-title > .anticon:first-child
    .ant-dropdown-menu-submenu-title > a > .anticon:first-child {
      min-width: 12px;
      margin-right: 8px;
    }
 
  }
 
  .content {
 
    .table-operator {
      margin-bottom: 18px;
 
      button {
        margin-right: 8px;
      }
    }
  }
</style>