Blame view

src/views/layout/layout.vue 13.8 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
2
3
4
5
    <el-container class="app-wrapper">
      <!-- 顶部导航 -->
      <el-header height="60px" class="app-header">
        <div class="header-left">
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
6
          <div class="logo" @click="_toIndex">{{ systemInfo.systemSimpleTitle }}</div>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
7
8
          <el-menu mode="horizontal" :default-active="activeMenu" class="header-menu" background-color="#1e2132"
            text-color="#fff" active-text-color="#409EFF">
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
9
10
11
12
            <template v-for="(item, index) in catalogs">
              <el-menu-item :index="item.caId" v-if="!item.privId || hasPrivilege(item.privId)" :key="index"
                @click="_changeMenuCatalog(item, true)">{{ item.name }}</el-menu-item>
            </template>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
13
14
15
          </el-menu>
        </div>
        <div class="header-right">
0e3df9ef   wuxw   优化物业账号下切换小区功能
16
17
18
19
20
21
          <el-dropdown @command="changeCommunity" v-if="storeInfo.storeTypeCd == '800900000003'" class="margin-right">
            <span class="user-info">
              {{ curCommunityName }}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
0f149ba1   wuxw   优化代码
22
23
              <el-dropdown-item :command="c" v-for="(c, index) in communitys" :key="index">{{ c.name }}</el-dropdown-item>
              <el-dropdown-item command="moreCommunity" class="moreCommunity">{{ $t('layout.moreCommunity')
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
24
                }}</el-dropdown-item>
0e3df9ef   wuxw   优化物业账号下切换小区功能
25
26
            </el-dropdown-menu>
          </el-dropdown>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
27
28
29
30
31
32
33
34
35
          <el-dropdown @command="handleCommand">
            <span class="user-info">
              {{ username }}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="logout">{{ $t('layout.logout') }}</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
36
          <span class="margin-left">{{ systemInfo.version }}</span>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
  
        </div>
      </el-header>
  
      <el-container>
        <!-- 左侧菜单 width="64px"-->
        <el-aside class="app-aside" width="80">
          <div class="vc-menu flex justify-start" id="menu-nav">
            <div class="vc-menu-main">
              <ul>
                <template v-for="(menu, index) in menuTree">
                  <li :key="index" v-if="menu.childs && menu.childs.length > 0" :class="{ active: menu.active }"
                    @click="switchMenu(menu)">
                    <i class="fa " v-bind:class="menu.icon"></i><span class="margin-left-xs">{{ menu.name }}</span>
                  </li>
                </template>
              </ul>
            </div>
            <div class="vc-menu-sub" v-if="subMenus && subMenus.length > 0">
              <ul>
                <li class="title">{{ curMenuName }}</li>
                <template v-for="(subMenu, index) in subMenus">
                  <li :key="index" v-if="subMenu.isShow == 'Y'" :class="{ active: subMenu.active }"
                    v-on:click="_gotoPage(subMenu.href, subMenu.name)">
                    {{ subMenu.name }}
                  </li>
                </template>
                <li class="sub-footer" @click="_closeSubMenu()"><i class="fa fa-dedent"></i></li>
              </ul>
            </div>
          </div>
        </el-aside>
  
        <!-- 主要内容区 -->
        <el-main class="app-main">
          <router-view />
        </el-main>
      </el-container>
0f149ba1   wuxw   优化代码
75
      <more-community ref="moreCommunity" />
1db0a60c   wuxw   优化常用菜单 和搜索功能
76
77
      <view-menu-user-list ref="viewMenuUserModel" />
      <search-community-data-list ref="searchCommunityDataModel" />
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
78
79
80
81
    </el-container>
  </template>
  
  <script>
c89819f7   wuxw   支持跳转至物联网和商城
82
  import { _getMenuCatalog, getMenuTree, jumpToMall, jumpToIot } from '@/api/user/menuApi'
0e3df9ef   wuxw   优化物业账号下切换小区功能
83
  import { getStoreInfo } from "@/api/user/indexApi"
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
84
  import { listSystemInfo } from '@/api/system/systemInfoManageApi'
0f149ba1   wuxw   优化代码
85
86
  import { deepCopy, setCurrentCommunity } from "@/utils/vc"
  import { getCommunityName, _loadCommunityInfo } from '@/api/community/communityApi'
0e3df9ef   wuxw   优化物业账号下切换小区功能
87
  import moreCommunity from '@/components/community/moreCommunity.vue'
1db0a60c   wuxw   优化常用菜单 和搜索功能
88
89
  import viewMenuUserList from '@/components/system/viewMenuUserList.vue'
  import searchCommunityDataList from '@/components/system/searchCommunityDataList.vue'
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
90
  import { initSystem } from '@/api/util/vcApi'
37593bd5   wuxw   优化
91
  import config from '@/conf/config'
4ead63f9   wuxw   优化房屋创建费用 国际化问题
92
  
0e3df9ef   wuxw   优化物业账号下切换小区功能
93
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
94
95
96
97
98
99
100
  export default {
    name: 'Layout',
    data() {
      return {
        catalogs: [],
        menuTree: [],
        subMenus: [],
0e3df9ef   wuxw   优化物业账号下切换小区功能
101
        menuWidth: 80,
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
102
103
104
105
106
107
        menuId: '',
        curMenuName: '',
        activeMenu: '',
        activeSubMenu: 'communityList',
        searchText: '',
        username: '',
0f149ba1   wuxw   优化代码
108
109
        curCommunityName: '',
        communitys: [],
0e3df9ef   wuxw   优化物业账号下切换小区功能
110
111
112
113
        storeInfo: {
          storeTypeCd: '',
          storeId: ''
        },
f9988111   wuxw   优化系统
114
115
116
        systemInfo: {
          systemSimpleTitle: '',
          companyName: '',
37593bd5   wuxw   优化
117
118
          logoUrl: '',
          version: ''
f9988111   wuxw   优化系统
119
        }
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
120
121
122
123
124
      }
    },
    created() {
      let _user = JSON.parse(localStorage.getItem('user'));
      this.username = _user.name
37593bd5   wuxw   优化
125
      this.systemInfo.version = config.version
f9988111   wuxw   优化系统
126
      this.getSystemInfo()
0e3df9ef   wuxw   优化物业账号下切换小区功能
127
      this._loadStoreInfo()
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
128
      this.loadCatalogs()
0e3df9ef   wuxw   优化物业账号下切换小区功能
129
130
      this.curCommunityName = getCommunityName()
      this.loadCommunity()
4ead63f9   wuxw   优化房屋创建费用 国际化问题
131
      initSystem()
0e3df9ef   wuxw   优化物业账号下切换小区功能
132
    },
0f149ba1   wuxw   优化代码
133
    components: {
1db0a60c   wuxw   优化常用菜单 和搜索功能
134
135
136
      moreCommunity,
      viewMenuUserList,
      searchCommunityDataList
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
137
138
    },
    methods: {
f9988111   wuxw   优化系统
139
140
141
142
143
144
      async getSystemInfo() {
        const { data } = await listSystemInfo({ page: 1, row: 1 });
        this.systemInfo.systemSimpleTitle = data[0].systemSimpleTitle
        this.systemInfo.companyName = data[0].companyName
        this.systemInfo.logoUrl = data[0].logoUrl
      },
0f149ba1   wuxw   优化代码
145
146
      async loadCommunity() {
        const { communitys } = await _loadCommunityInfo()
0e3df9ef   wuxw   优化物业账号下切换小区功能
147
        this.communitys = communitys
c412a802   wuxw   优化采购申请
148
149
        this.curCommunityName = getCommunityName()
  
0e3df9ef   wuxw   优化物业账号下切换小区功能
150
151
152
153
154
155
156
157
158
159
160
161
162
      },
      async _loadStoreInfo() {
        this.loading = true
        try {
          const res = await getStoreInfo()
          deepCopy(res, this.storeInfo);
        } catch (error) {
          console.error('登录失败:', error)
        } finally {
          this.loading = false
        }
  
      },
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
163
164
165
166
167
168
169
170
      async loadCatalogs() {
        this.loading = true
        try {
          const res = await _getMenuCatalog()
          if (res.code != 0) {
            return;
          }
          this.catalogs = res.data;
0e3df9ef   wuxw   优化物业账号下切换小区功能
171
          if (this.catalogs && this.catalogs.length > 0) {
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
172
173
174
175
176
177
178
179
180
            this._changeMenuCatalog(this.catalogs[0])
          }
        } catch (error) {
          console.error('登录失败:', error)
  
        } finally {
          this.loading = false
        }
      },
dd2c2983   wuxw   优化缴费页面
181
      _changeMenuCatalog(_catalog, _isJump) {
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
182
        this.activeMenu = _catalog.caId;
1db0a60c   wuxw   优化常用菜单 和搜索功能
183
184
185
        if (this._showModelDiv(_catalog)) {
          return;
        }
0f149ba1   wuxw   优化代码
186
187
188
189
        if (_catalog.caId === '1') {
          this.$router.push('/#/pages/mall/product');
        }
        if (_catalog.url == 'IOT') {
c89819f7   wuxw   支持跳转至物联网和商城
190
          jumpToIot('/');
0f149ba1   wuxw   优化代码
191
192
193
194
          return;
        }
        if (_catalog.url == 'MALL') {
          //获取用户名
c89819f7   wuxw   支持跳转至物联网和商城
195
          jumpToMall('/');
0f149ba1   wuxw   优化代码
196
197
198
          return;
        }
        console.log(_catalog)
dd2c2983   wuxw   优化缴费页面
199
        if (_catalog.url != '#' && _isJump) {
0f149ba1   wuxw   优化代码
200
201
202
          this._gotoPage(_catalog.url, _catalog.name)
          //return;
        }
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
203
204
        this.loadMenuTree(_catalog)
      },
1db0a60c   wuxw   优化常用菜单 和搜索功能
205
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
206
207
208
209
210
211
212
213
214
215
216
217
218
      handleCommand(command) {
        if (command === 'logout') {
          // 处理退出登录
  
          localStorage.removeItem('token')
          localStorage.clear();
          this.$router.push('/login')
        } else if (command === 'zh' || command === 'en') {
          // 切换语言
          this.$i18n.locale = command
          localStorage.setItem('language', command)
        }
      },
0f149ba1   wuxw   优化代码
219
220
      changeCommunity(community) {
        if (community == 'moreCommunity') {
0e3df9ef   wuxw   优化物业账号下切换小区功能
221
222
223
224
225
          this.$refs.moreCommunity.open()
          return
        }
        setCurrentCommunity(community);
        this.curCommunityName = getCommunityName()
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
226
        window.location.href = "/"
0e3df9ef   wuxw   优化物业账号下切换小区功能
227
      },
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
228
229
230
231
232
233
234
      handleMenuSelect(index) {
        // 处理菜单选择
        this.$router.push({ name: index })
      },
      loadMenuTree(_catalog) {
        getMenuTree(_catalog).then(res => {
          let _menus = res.data;
0e3df9ef   wuxw   优化物业账号下切换小区功能
235
236
237
          _menus.sort(function (a, b) {
            return a.seq - b.seq
          });
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
          this.menuTree = _menus;
        })
      },
      switchMenu(_menu) {
        //设置菜单ID
        this.menuId = _menu.id;
        this.menuTree = this.refreshMenuActive(this.menuTree, _menu.id);
        this.subMenus = _menu.childs;
        console.log(this.subMenus)
        this.curMenuName = _menu.name;
  
        if (!_menu.childs || _menu.childs.length < 1) {
          return;
        }
        //选中第一个
        this._gotoPage(_menu.childs[0].href, _menu.childs[0].name);
        //vc._fix_height()
      },
      refreshMenuActive(jsonArray, _id) {
        for (let menuIndex = 0; menuIndex < jsonArray.length; menuIndex++) {
          if (jsonArray[menuIndex].childs) {
            let _childs = jsonArray[menuIndex].childs;
            _childs.sort(function (_child, _newChild) {
              return _child.seq - _newChild.seq
            });
            jsonArray[menuIndex].childs = _childs;
          }
  
          if (_id === jsonArray[menuIndex].id) {
            //如果当前本身是打开状态,说明 需要关闭
            jsonArray[menuIndex].active = true;
            continue;
          }
          jsonArray[menuIndex].active = false;
        }
        return jsonArray;
      },
      _setSelectedMenusChild(_href) {
        for (var menuIndex = 0; menuIndex < this.menuTree.length; menuIndex++) {
          if (this.menuTree[menuIndex].childs) {
            var _childs = this.menuTree[menuIndex].childs;
            for (var childIndex = 0; childIndex < _childs.length; childIndex++) {
              if (_href == _childs[childIndex].href) {
                this.menuTree[menuIndex].childs[childIndex].active = true;
              } else {
                this.menuTree[menuIndex].childs[childIndex].active = false;
              }
            }
          }
        }
        this.$forceUpdate();
      },
      _gotoPage(_href, _tabName) {
c89819f7   wuxw   支持跳转至物联网和商城
291
        console.log(_href, _tabName)
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
292
293
        // 子菜单默认选中
        this._setSelectedMenusChild(_href);
1db0a60c   wuxw   优化常用菜单 和搜索功能
294
        if (_href.indexOf('.html') > -1) {
c89819f7   wuxw   支持跳转至物联网和商城
295
296
297
          window.open(_href, '_blank')
          return
        }
0e3df9ef   wuxw   优化物业账号下切换小区功能
298
299
        if (_href.indexOf('/#/') > -1) {
          _href = _href.replace('/#/', '/')
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
300
        }
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
301
  
1a0bdbe0   wuxw   优化缴费页面
302
303
304
305
306
307
        this.$router.push(_href).catch(err => {
          // 忽略重复导航错误
          if (err.name !== 'NavigationDuplicated') {
            throw err
          }
        })
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
308
      },
1db0a60c   wuxw   优化常用菜单 和搜索功能
309
310
311
312
313
314
315
316
      _showModelDiv: function (_catalog) {
        console.log(_catalog)
        if (_catalog.url.startsWith('?')) {
          let _modelName = _catalog.url.substring(1, _catalog.url.length);
          this.$refs[_modelName].open()
          return true;
        }
        return false;
e669ff2c   wuxw   点击logo 进入首页bug 修复
317
      },
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
318
      _toIndex() {
e669ff2c   wuxw   点击logo 进入首页bug 修复
319
        location.href = '/'
21d75ed2   wuxw   v1.9 解决张峰提出的问题
320
      },
050d35a0   wuxw   v1.9 业务受理没有加入权限控制...
321
      _closeSubMenu() {
21d75ed2   wuxw   v1.9 解决张峰提出的问题
322
323
        this.subMenus = []
        this.curMenuName = ''
1db0a60c   wuxw   优化常用菜单 和搜索功能
324
325
      }
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
326
327
328
329
330
    }
  }
  </script>
  
  <style lang="scss" scoped>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
  .app-wrapper {
    height: 100vh;
  }
  
  .app-header {
    background-color: #1e2132;
    color: #fff;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .header-left {
    display: flex;
    align-items: center;
  }
  
  .logo {
    width: 100px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #409EFF;
e669ff2c   wuxw   点击logo 进入首页bug 修复
357
    cursor: pointer;
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
  }
  
  .header-menu {
    border: none;
  }
  
  .header-right {
    display: flex;
    align-items: center;
    margin-right: 20px;
  }
  
  .margin-left {
    margin-left: 15px;
    color: #fff;
  }
  
  .user-info {
    color: #fff;
    cursor: pointer;
  }
  
  .app-aside {
    width: auto;
  }
  
  .menu-wrapper {
    height: 100%;
  }
  
  .el-menu-vertical {
    border: none;
  }
  
  .el-menu-vertical:not(.el-menu--collapse) {
    width: 200px;
  }
  
  .app-main {
    background-color: #f5f7fa;
0f149ba1   wuxw   优化代码
398
    height: calc(100vh - 60px);
737b703c   wuxw   添加房屋页面开发完成
399
    padding: 0px;
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
  }
  
  :deep(.el-menu--horizontal) {
    border-bottom: none;
  }
  
  :deep(.el-menu-item) {
    height: 50px;
    line-height: 50px;
  }
  
  :deep(.el-submenu__title) {
    height: 50px;
    line-height: 50px;
    padding: 0 20px !important;
  }
  
  :deep(.el-menu--collapse) {
    width: 64px;
  }
  
  :deep(.el-menu--collapse .el-submenu__title) {
    padding: 0 !important;
    text-align: center;
  }
  
  :deep(.el-menu--collapse .el-submenu__title i) {
    margin: 0;
    font-size: 20px;
  }
  
  :deep(.el-menu--popup) {
    min-width: 200px;
    background-color: #1e2132 !important;
  }
  
  :deep(.el-menu--popup .el-menu-item) {
    background-color: #1e2132;
    color: #fff;
  }
  
  :deep(.el-menu--popup .el-menu-item:hover) {
    background-color: #2a2f45;
  }
  
  :deep(.el-menu--popup .el-menu-item.is-active) {
    color: #409EFF;
  }
  
  .vc-menu {
    border-right: 1px solid #EFEFF0;
  
    .vc-menu-main {
      background-color: #1F2339;
      color: #838A9B;
      text-align: center;
      width: 80px;
      font-size: 14px;
      height: calc(100vh - 60px);
      overflow-x: hidden;
      overflow-y: scroll;
      scrollbar-width: none;
  
      .active {
        background-color: #3E77FC;
        color: #FFFFFF;
      }
    }
  
    .vc-menu-main::-webkit-scrollbar {
      display: none;
    }
  
    ul {
      padding-inline-start: 0px;
      margin: 0;
      padding: 0;
    }
  
    li {
      margin: 0;
      padding: 0;
    }
  }
  
0f149ba1   wuxw   优化代码
485
  .moreCommunity {
0e3df9ef   wuxw   优化物业账号下切换小区功能
486
487
488
489
    font-weight: 600;
    color: #212529;
    font-size: 12px;
  }
0f149ba1   wuxw   优化代码
490
  
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
  .vc-menu-main ul li {
    height: 45px;
    line-height: 45px;
    cursor: pointer;
    list-style-type: none;
  }
  
  .vc-menu-main ul li:hover {
    background-color: #3E77FC;
    color: #FFFFFF;
  }
  
  .vc-menu-main ul li.title {
    color: #FFFFFF;
    height: 60px;
    font-size: 24px;
    line-height: 60px;
  }
  
  .vc-menu-main ul li.title a {
    text-decoration: none;
    cursor: pointer;
    color: #FFFFFF;
  }
  
  .vc-menu-sub {
    background-color: #FFFFFF;
    color: #545761;
    text-align: start;
    width: 110px;
    font-size: 14px;
    height: calc(100vh - 60px);
    overflow-x: hidden;
    overflow-y: scroll;
    scrollbar-width: none;
  }
  
  .vc-menu-sub::-webkit-scrollbar {
    display: none;
  }
  
  .vc-menu-sub .active {
    background-color: #EAF0FE;
    color: #3E77FC;
  }
  
  
  
  .vc-menu-sub ul li {
    height: 40px;
    line-height: 40px;
    padding-left: 15px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  
  .vc-menu-sub ul li.title {
    color: #4F525C;
    height: 40px;
    font-size: 14px;
    line-height: 40px;
    text-align: center;
    padding-left: 0px;
    border-bottom: 1px solid #F2F2F3;
    margin-bottom: 10px;
  }
  
  .vc-menu-sub ul li:hover {
    background-color: #EAF0FE;
    color: #3E77FC;
  }
  
  .vc-menu-sub ul li.sub-footer {
    background-color: #F6F6F7;
    text-align: center;
    position: fixed;
    bottom: 0;
    width: 100px;
  }
0f149ba1   wuxw   优化代码
572
  </style>