imatrix-ui 2.7.78-dw → 2.7.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,126 @@
1
+ <template>
2
+ <div class="menu-wrapper">
3
+ <template v-if="!item.children || item.children.lenght === 0">
4
+ <app-link :to="toPath(item)" @click.native="clickMenu(toPath(item))">
5
+ <el-menu-item :index="resolvePath(item.code,item.path,item.pageType)" :class="{'submenu-title-noDropdown':!isNest}">
6
+ <item :icon="item.iconName" :title="item.name" :is-root="true" />
7
+ </el-menu-item>
8
+ </app-link>
9
+ </template>
10
+
11
+ <el-submenu v-else :index="resolvePath(item.code,item.path,item.pageType)" popper-class="sidebar-container-popper">
12
+ <template slot="title">
13
+ <item :icon="item.iconName" :title="item.name" :has-children="item.children.length > 0?true:false" />
14
+ </template>
15
+
16
+ <template v-for="child in item.children">
17
+ <sidebar-item
18
+ v-if="child.children&&child.children.length>0"
19
+ :key="child.code"
20
+ :is-nest="true"
21
+ :item="child"
22
+ class="nest-menu"
23
+ />
24
+ <app-link v-else :key="child.code" :to="toPath(child)" @click.native="clickMenu(toPath(child))">
25
+ <el-menu-item :index="resolvePath(child.code,child.path,child.pageType)">
26
+ <item :icon="child.iconName" :title="child.name" />
27
+ </el-menu-item>
28
+ </app-link>
29
+ </template>
30
+ </el-submenu>
31
+ </div>
32
+ </template>
33
+
34
+ <script>
35
+ // import { isExternal } from 'imatrix-ui/src/utils'
36
+ import Item from './Item'
37
+ import AppLink from './Link'
38
+ import Vue from 'vue'
39
+ import tabJs from '../../../api/tab'
40
+ export default {
41
+ name: 'SidebarItem',
42
+ components: { Item, AppLink },
43
+ props: {
44
+ // route object
45
+ item: {
46
+ type: Object,
47
+ required: true
48
+ },
49
+ isNest: {
50
+ type: Boolean,
51
+ default: false
52
+ }
53
+ // basePath: {
54
+ // type: String,
55
+ // default: ''
56
+ // }
57
+ },
58
+ data() {
59
+ return {
60
+ onlyOneChild: null
61
+ }
62
+ },
63
+ methods: {
64
+ ...tabJs,
65
+ hasOneShowingChild(children, parent) {
66
+ if (children && children.length > 0) {
67
+ this.onlyOneChild = children[0]
68
+ }
69
+ // When there is only one child router, the child router is displayed by default
70
+ if (children.length === 1) {
71
+ return true
72
+ }
73
+
74
+ // Show parent if there are no child router to display
75
+ if (!children || children.length === 0) {
76
+ // children不存在
77
+ this.onlyOneChild = { ... parent, path: '', noShowingChildren: true }
78
+ return true
79
+ }
80
+
81
+ return false
82
+ },
83
+ resolvePath(menuCode, pageCode, pageType) {
84
+ if (this.isExternalLink(pageType)) {
85
+ return '/dsc/' + menuCode + '~~'
86
+ } else {
87
+ return '/dsc/' + menuCode + '~~' + pageCode
88
+ }
89
+ },
90
+ toPath(menu) {
91
+ const toPathObj = {}
92
+ const routePath = menu.path
93
+ if (this.isExternalLink(menu.pageType)) {
94
+ toPathObj.path = '/dsc-index/iframe-page'
95
+ toPathObj.tabPath = '/dsc/iframe-page'
96
+ toPathObj.query = {}
97
+ toPathObj.query.src = routePath
98
+ toPathObj.isExternal = true
99
+ toPathObj.query.customSystem = Vue.prototype.customSystem
100
+ toPathObj.query._menuCode = menu.code
101
+ toPathObj.query._menuName = menu.name
102
+ } else {
103
+ const pageCode = routePath
104
+ toPathObj.path = '/dsc-index/page'
105
+ toPathObj.tabPath = '/dsc/page'
106
+ toPathObj.query = {}
107
+ toPathObj.query.pageCode = pageCode
108
+ toPathObj.query.customSystem = Vue.prototype.customSystem
109
+ toPathObj.query._menuCode = menu.code
110
+ toPathObj.query._menuName = menu.name
111
+ }
112
+ return toPathObj
113
+ },
114
+ clickMenu(toPathObj) {
115
+ console.log('clickMenu----toPathObj=', toPathObj)
116
+ this.addTabs(toPathObj.query, this.$store.state.tabContent.openTab, toPathObj.tabPath)
117
+ },
118
+ isExternalLink(pageType) {
119
+ if (pageType && pageType === 'iframe') {
120
+ return true
121
+ }
122
+ return false
123
+ }
124
+ }
125
+ }
126
+ </script>
@@ -0,0 +1,179 @@
1
+ <template>
2
+ <div>
3
+ <el-scrollbar wrap-class="scrollbar-wrapper">
4
+ <el-menu
5
+ :show-timeout="200"
6
+ :default-active="getDefaultActive()"
7
+ :collapse="isCollapse"
8
+ mode="vertical"
9
+ @select="selectMenu"
10
+ >
11
+ <sidebar-item v-for="menu in menus" :key="menu.code" :item="menu" />
12
+ </el-menu>
13
+ </el-scrollbar>
14
+ <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import { mapGetters } from 'vuex'
20
+ import SidebarItem from './SidebarItem'
21
+ import Cookies from 'js-cookie'
22
+ import tabJs from '../../../api/tab'
23
+ export default {
24
+ name: 'Sidebar',
25
+ components: {
26
+ SidebarItem
27
+ },
28
+ props: {
29
+ systemCode: {
30
+ type: String,
31
+ default: null
32
+ },
33
+ collapse: {
34
+ type: Boolean,
35
+ default: false
36
+ }
37
+ },
38
+ data() {
39
+ return {
40
+ }
41
+ },
42
+ computed: {
43
+ ...mapGetters([
44
+ 'sidebar',
45
+ 'menus'
46
+ ]),
47
+ isCollapse() {
48
+ if (this.collapse === false) {
49
+ return !this.sidebar.opened
50
+ }
51
+ return true
52
+ }
53
+ },
54
+ created() {
55
+ this.firstLeafMenu = this.getMyFirstMenu(this.menus)
56
+ if (this.firstLeafMenu && this.firstLeafMenu.fullPath) {
57
+ // 跳转到第一个页面
58
+ if (this.firstLeafMenu.pageType && this.firstLeafMenu.pageType === 'iframe') {
59
+ const iframeSrc = this.firstLeafMenu.fullPath
60
+ this.$router.push({ path: '/dsc-index/iframe-page', query: { src: iframeSrc }})
61
+ } else {
62
+ const pageCode = this.firstLeafMenu.path
63
+ const query = { customSystem: this.systemCode, pageCode: pageCode, _menuCode: this.firstLeafMenu.code, _menuName: this.firstLeafMenu.name }
64
+ this.addTabs(query, this.$store.state.tabContent.openTab, '/dsc/page', '/dsc/page')
65
+ this.$router.push({ path: '/dsc-index/page', query: query })
66
+ // this.$router.push({ path: this.firstLeafMenu.fullPath })
67
+ }
68
+ }
69
+ },
70
+ methods: {
71
+ ...tabJs,
72
+ getDefaultActive() {
73
+ if (this.firstLeafMenu && this.firstLeafMenu.pageType !== 'iframe') {
74
+ const pageCode = this.firstLeafMenu.path
75
+ return '/dsc/' + this.firstLeafMenu.code + '~~' + pageCode
76
+ } else if (this.firstLeafMenu && this.firstLeafMenu.pageType === 'iframe') {
77
+ return '/dsc/' + this.firstLeafMenu.code + '~~'
78
+ } else {
79
+ return ''
80
+ }
81
+ },
82
+ toggleSideBar() {
83
+ this.$store.dispatch('toggleSidebar')
84
+ },
85
+ selectMenu(index, indexPath) {
86
+ console.log('selectMenu----indexPath=', indexPath, 'index=', index)
87
+ Cookies.set('selectMenu', index)
88
+ },
89
+ getMyFirstMenu(menus) {
90
+ if (menus && menus.length > 0) {
91
+ let shouldSelectMenu = this.getFirstMenuWithCookie(menus)
92
+ if (!shouldSelectMenu) {
93
+ shouldSelectMenu = this.getFirstMenu(menus)
94
+ }
95
+ return shouldSelectMenu
96
+ }
97
+ },
98
+ getFirstMenu(menus) {
99
+ if (menus && menus.length > 0) {
100
+ let shouldSelectMenu
101
+ for (let i = 0; i < menus.length; i++) {
102
+ const menu = menus[i]
103
+ shouldSelectMenu = this.getShouldSelectMenu(menu)
104
+ if (shouldSelectMenu) {
105
+ // 表示获得到了应该选中的菜单
106
+ break
107
+ }
108
+ }
109
+ if (!shouldSelectMenu) {
110
+ // 如果没有获得默认选中的菜单,则默认选中第一个菜单
111
+ shouldSelectMenu = this.getSelectMenuWithFirstMenu(menus[0])
112
+ }
113
+ return shouldSelectMenu
114
+ }
115
+ },
116
+ getShouldSelectMenu(menu) {
117
+ if (menu) {
118
+ console.log('dsc--getShouldSelectMenu--this.$route=', this.$route)
119
+ let shouldSelectMenu
120
+ const children = menu.children
121
+ const currentRoute = this.$route.path
122
+ if (children && children.length > 0) {
123
+ shouldSelectMenu = this.getFirstMenu(children)
124
+ } else if (menu.fullPath && menu.fullPath === currentRoute) {
125
+ shouldSelectMenu = menu
126
+ }
127
+ return shouldSelectMenu
128
+ }
129
+ },
130
+ getSelectMenuWithFirstMenu(menu) {
131
+ console.log('dsc--getSelectMenuWithFirstMenu--this.$route=', this.$route)
132
+ if (menu) {
133
+ let shouldSelectMenu
134
+ const children = menu.children
135
+ if (children && children.length > 0) {
136
+ shouldSelectMenu = this.getFirstMenu(children)
137
+ } else {
138
+ shouldSelectMenu = menu
139
+ }
140
+ return shouldSelectMenu
141
+ }
142
+ },
143
+ getFirstMenuWithCookie(menus) {
144
+ if (menus && menus.length > 0) {
145
+ const cookieMenu = Cookies.set('selectMenu')
146
+ if (cookieMenu) {
147
+ // // 表示缓存中存储了menu,格式为:/dsc/菜单编码~~pageCode
148
+ const prefix = '/dsc/'
149
+ const menuCode = cookieMenu.substring(cookieMenu.indexOf(prefix) + prefix.length, cookieMenu.lastIndexOf('~~'))
150
+
151
+ let shouldSelectMenu
152
+ for (let i = 0; i < menus.length; i++) {
153
+ const menu = menus[i]
154
+ shouldSelectMenu = this.getShouldSelectMenuWithCookie(menu, menuCode)
155
+ if (shouldSelectMenu) {
156
+ // 表示获得到了应该选中的菜单
157
+ break
158
+ }
159
+ }
160
+ return shouldSelectMenu
161
+ }
162
+ }
163
+ },
164
+ getShouldSelectMenuWithCookie(menu, menuCode) {
165
+ if (menu) {
166
+ console.log('dsc--getShouldSelectMenuWithCookie--this.$route=', this.$route)
167
+ let shouldSelectMenu
168
+ const children = menu.children
169
+ if (children && children.length > 0) {
170
+ shouldSelectMenu = this.getFirstMenuWithCookie(children)
171
+ } else if (menu.code && menu.code === menuCode) {
172
+ shouldSelectMenu = menu
173
+ }
174
+ return shouldSelectMenu
175
+ }
176
+ }
177
+ }
178
+ }
179
+ </script>
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <el-tabs v-model="activeIndex" class="nav-tab menu-tab-container" closable @tab-remove="closeSelectedTag">
3
+ <el-tab-pane v-for="tag in openTab" :key="tag.code" :label="tag.name" :name="tag.code">
4
+ <iframe ref="tabMainContent" :src="getFullPath(tag)" class="tab-main-content" name="tab-main-content" frameborder="0" />
5
+ </el-tab-pane>
6
+ </el-tabs>
7
+ </template>
8
+ <style rel="stylesheet/scss" lang="scss" scoped>
9
+ iframe.tab-main-content{
10
+ width: 100%;
11
+ height: calc(100vh - 10px);
12
+ }
13
+ </style>
14
+ <script>
15
+ import { mapGetters } from 'vuex'
16
+ export default {
17
+ name: 'TabContent',
18
+ data() {
19
+ return {
20
+ }
21
+ },
22
+ computed: {
23
+ ...mapGetters([
24
+ 'openTab'
25
+ ]),
26
+ activeIndex: {
27
+ get() {
28
+ return this.$store.state.tabContent.activeIndex
29
+ },
30
+ set(val) {
31
+ this.$store.commit('set_active_index', val)
32
+ }
33
+ }
34
+ },
35
+ methods: {
36
+ closeSelectedTag(tagName) {
37
+ const index = this.$store.state.tabContent.openTab.findIndex((item) => item.code === tagName)
38
+ const view = this.$store.state.tabContent.openTab[index]
39
+ this.$store.commit('delete_tabs', view)
40
+ if (tagName === this.activeIndex) {
41
+ // 表示删除的是当前选中的菜单,选中前面的菜单
42
+ this.toLastView(this.$store.state.tabContent.openTab, index > 0 ? (index - 1) : 0)
43
+ }
44
+ },
45
+ toLastView(visitedViews, lastIndex) {
46
+ if (visitedViews && visitedViews.length > 0 && visitedViews.length > lastIndex) {
47
+ const latestView = visitedViews[lastIndex]
48
+ if (latestView) {
49
+ this.$store.commit('set_active_index', latestView.code)
50
+ }
51
+ }
52
+ },
53
+ getFullPath(tag) {
54
+ let path = '#' + tag.routePath + '?'
55
+ if (tag.routeQuery) {
56
+ for (const key in tag.routeQuery) {
57
+ path += key + '=' + tag.routeQuery[key] + '&'
58
+ }
59
+ }
60
+ return path
61
+ }
62
+ }
63
+ }
64
+ </script>
65
+
66
+ <style>
67
+ .nav-tab {
68
+ margin-top: 5px;
69
+ margin-left: 5px;
70
+ }
71
+ .nav-tab .el-tabs__header{
72
+ margin: 0;
73
+ /* border-bottom: 0px; */
74
+ }
75
+ .menu-tab-container .el-tabs__content{
76
+ padding: 0;
77
+ }
78
+ </style>
@@ -41,7 +41,7 @@
41
41
  </template>
42
42
 
43
43
  <script>
44
- import { Message } from '@gcommon/gcommon-ui'
44
+ import { Message } from 'element-ui'
45
45
  export default {
46
46
  name: 'Login',
47
47
  data() {