@lambo-design/pro-layout 1.0.0-beta.352 → 1.0.0-beta.354

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/pro-layout",
3
- "version": "1.0.0-beta.352",
3
+ "version": "1.0.0-beta.354",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -10,7 +10,7 @@
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
12
  "devDependencies": {
13
- "@lambo-design/shared": "^1.0.0-beta.228",
13
+ "@lambo-design/shared": "^1.0.0-beta.236",
14
14
  "@lambo-design/core": "^4.7.1-beta.147"
15
15
  },
16
16
  "scripts": {
@@ -70,9 +70,10 @@
70
70
  <script>
71
71
  import Bus from '@lambo-design/shared/utils/bus'
72
72
  import { deepCopy } from '@lambo-design/shared/utils/assist'
73
- import {getSessionStorage} from '@lambo-design/shared/utils/platform'
73
+ import {getAllElements, getSessionStorage} from '@lambo-design/shared/utils/platform'
74
74
  import { mapActions } from 'vuex'
75
75
  import config from '@/config/config'
76
+ import generatorMenuList from "@lambo-design/shared/utils/menu";
76
77
 
77
78
  export default {
78
79
  name: 'pro-layout-tools-quick-search',
@@ -116,15 +117,16 @@ export default {
116
117
  'getNoticeListData'
117
118
  ]),
118
119
  initListener() {
119
- Bus.$on('menu-list', (data) => {
120
- this.initMenu(data);
121
- })
122
120
  Bus.$on('other-datas',(data)=>{
123
121
  this.initNoticeAndMessage(data)
124
122
  });
123
+ Bus.$on('origin-all-menu-list',(data)=>{
124
+ this.initCanSearchMenu(data)
125
+ })
125
126
  },
126
127
  destroyListener() {
127
- Bus.$off('menu-list')
128
+ Bus.$off('other-datas')
129
+ Bus.$off('origin-all-menu-list')
128
130
  },
129
131
  initNoticeAndMessage(data){
130
132
  if (data){
@@ -136,11 +138,22 @@ export default {
136
138
  }
137
139
  }
138
140
  },
139
- initMenu(data){
140
- let self = this
141
- var appList = getSessionStorage('appList')
142
- let permissionStoreKey = config.routerBase+'-permission'
143
- var menuList = getSessionStorage(permissionStoreKey)
141
+ initCanSearchMenu(data){
142
+ let appList = getSessionStorage('appList')
143
+ let appIds = '';
144
+ let appIdList = [];
145
+ if (appList && appList.length > 0) {
146
+ for(let app of appList) {
147
+ appIdList.push(app.appId);
148
+ }
149
+ appIds = appIdList.join(",");
150
+ }
151
+ let treeMenuList = generatorMenuList(data,appIds,'menu');
152
+ let result = []
153
+ getAllElements(treeMenuList,result)
154
+ this.menuList = data.filter(menuItem => menuItem.type == '2' && menuItem.permissionId && result.includes(menuItem.permissionId))
155
+ },
156
+ filterMenu(){
144
157
  if (this.searchTopText){
145
158
  const regex = new RegExp(this.searchTopText, "i");
146
159
  this.menuData = this.menuList.filter(menuItem => {
@@ -148,26 +161,12 @@ export default {
148
161
  });
149
162
  return
150
163
  }
151
- self.menuData = menuList.filter(item => {
152
- let app = appList.find(app => app.appId === item.appId)
153
- //判断每个菜单的名字是否包含搜索内容 && 菜单类型是否为2 && 菜单的appId是否在appList中
154
- if (item.type == '2' && app) {
155
- return true
156
- }
157
- return false
158
- })
159
- self.menuList = self.menuData
160
-
161
164
  },
162
165
  async handleTopInput(){
163
166
  this.searchTopModal = true
164
167
  this.spinShowTop = true
165
168
  if (this.tab === 'menu'){
166
- // 使用 filter 方法找到所有匹配的菜单项
167
- const regex = new RegExp(this.searchTopText, "i");
168
- this.menuData = this.menuList.filter(menuItem => {
169
- return menuItem.label.match(regex) && menuItem.type === 2;
170
- });
169
+ this.filterMenu()
171
170
  }
172
171
  this.spinShowTop = false
173
172
  },
@@ -219,7 +218,7 @@ export default {
219
218
  async tabLabel(e){
220
219
  this.tab = e
221
220
  if (e === 'menu') {
222
- this.initMenu(null)
221
+ this.filterMenu()
223
222
  }
224
223
  },
225
224
  },
@@ -39,6 +39,7 @@
39
39
  import Bus from "@lambo-design/shared/utils/bus";
40
40
  import {deepCopy} from "@lambo-design/shared/utils/assist";
41
41
  import {getThemeVarByKey} from "@lambo-design/shared/utils/theme";
42
+ import {getAllElements} from "@lambo-design/shared/utils/platform"
42
43
  export default {
43
44
  name: "FastSearch",
44
45
  props: {
@@ -81,6 +82,14 @@ export default {
81
82
  return '';
82
83
  }
83
84
  },
85
+ watch:{
86
+ treeMenuList(){
87
+ this.filterMenu();
88
+ },
89
+ originMenuList(){
90
+ this.filterMenu();
91
+ }
92
+ },
84
93
  methods:{
85
94
  initListener(){
86
95
  Bus.$on('system-info',(data)=>{
@@ -89,17 +98,28 @@ export default {
89
98
  Bus.$on('menu-list',(data)=>{
90
99
  this.initMenu(data)
91
100
  });
101
+ Bus.$on('tree-menu-list',(data)=>{
102
+ this.initTreeMenu(data);
103
+ })
92
104
  },
93
105
  destroyListener(){
94
106
  Bus.$off('system-info')
95
107
  Bus.$off('menu-list')
108
+ Bus.$off('tree-menu-list')
96
109
  },
97
110
  initSystemInfo(data){
98
111
  this.systemInfo = deepCopy(data)
99
112
  },
100
113
  initMenu(data){
101
114
  this.originMenuList = deepCopy(data);
102
- this.searchMenuList = this.originMenuList.filter(menuItem => menuItem.type === 2)
115
+ },
116
+ initTreeMenu(data){
117
+ this.treeMenuList = deepCopy(data);
118
+ },
119
+ filterMenu(){
120
+ let result = []
121
+ getAllElements(this.treeMenuList,result)
122
+ this.searchMenuList = this.originMenuList.filter(menuItem => menuItem.type === 2 && menuItem.permissionId && result.includes(menuItem.permissionId))
103
123
  .map(menuItem => {
104
124
  // 检查menuItem对象的icon属性是否为'icon'或'1'
105
125
  if (!menuItem.icon) {
@@ -237,6 +237,7 @@ export default {
237
237
  } else {
238
238
  this.menuList = [];
239
239
  }
240
+ Bus.$emit('tree-menu-list',this.menuList)
240
241
  this.openedNames = this.getOpenedNamesByActiveName();
241
242
  },
242
243
  selectMenu(name,menu) {