lw-cdp-ui 1.3.70 → 1.4.0
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/dist/components/lwLayout/index.vue +56 -0
- package/dist/components/lwLogin/index.vue +126 -76
- package/dist/lw-cdp-ui.esm.js +3349 -3277
- package/dist/lw-cdp-ui.umd.js +6 -6
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -265,6 +265,62 @@ export default {
|
|
|
265
265
|
this.$tool.data.set('tenantId', user.userAuthInfo.tenantId)
|
|
266
266
|
this.$tool.data.set('userAuthInfo', userAuthInfo)
|
|
267
267
|
this.$store.state.user = userAuthInfo
|
|
268
|
+
|
|
269
|
+
// 动态菜单
|
|
270
|
+
if (this.$config.MENU_DYNAMIC) {
|
|
271
|
+
let MENU_LIST = this.$tool.data.get('MENU_LIST') || {}
|
|
272
|
+
let menu = await this.$api.auth.menu()
|
|
273
|
+
MENU_LIST['DYNAMIC_MENU'] = this.exportMenu(menu)
|
|
274
|
+
this.$tool.data.set('MENU_LIST', MENU_LIST)
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
// 处理动态菜单
|
|
278
|
+
exportMenu(originData) {
|
|
279
|
+
// 主处理函数
|
|
280
|
+
const processNode = (node, parentRoute = null) => {
|
|
281
|
+
// 创建基础路由结构
|
|
282
|
+
const route = {
|
|
283
|
+
name: node.pageName,
|
|
284
|
+
path: node.path,
|
|
285
|
+
component: node.component, // 组件由外部处理
|
|
286
|
+
sort: node.sort, // 组件由外部处理
|
|
287
|
+
meta: {
|
|
288
|
+
...node.meta,
|
|
289
|
+
code: node.applications[0],
|
|
290
|
+
roles: [...node.authority, node.menuId]
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// 处理子节点
|
|
295
|
+
if (node.children && node.children.length) {
|
|
296
|
+
route.children = node.children.sort((a, b) => a.sort - b.sort).map(child => processNode(child, route))
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return route
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 按applications分组
|
|
303
|
+
const groupedData = {}
|
|
304
|
+
|
|
305
|
+
originData.forEach(item => {
|
|
306
|
+
// 获取应用类型(如ec、cdp等)
|
|
307
|
+
const appType = item.applications[0]
|
|
308
|
+
|
|
309
|
+
if (!groupedData[appType]) {
|
|
310
|
+
groupedData[appType] = []
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// 处理当前节点
|
|
314
|
+
const processedNode = processNode(item)
|
|
315
|
+
groupedData[appType].push(processedNode)
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
// 对每个应用类型的菜单进行排序
|
|
319
|
+
Object.keys(groupedData).forEach(appType => {
|
|
320
|
+
groupedData[appType].sort((a, b) => a.sort - b.sort)
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
return groupedData
|
|
268
324
|
},
|
|
269
325
|
onLayoutResize() {
|
|
270
326
|
this.$store.commit('SET_ismobile', document.body.clientWidth < 992)
|
|
@@ -177,129 +177,126 @@ export default {
|
|
|
177
177
|
isEncryption: {
|
|
178
178
|
type: Boolean,
|
|
179
179
|
default: true
|
|
180
|
-
}
|
|
181
|
-
|
|
180
|
+
}
|
|
182
181
|
},
|
|
183
182
|
components: {
|
|
184
|
-
Lang
|
|
183
|
+
Lang
|
|
185
184
|
},
|
|
186
185
|
data() {
|
|
187
186
|
return {
|
|
188
187
|
isRegistered: false,
|
|
189
188
|
ruleForm: {
|
|
190
|
-
user:
|
|
191
|
-
password:
|
|
189
|
+
user: '',
|
|
190
|
+
password: '',
|
|
192
191
|
role: 0,
|
|
193
|
-
autologin: false
|
|
194
|
-
},
|
|
195
|
-
registForm: {
|
|
192
|
+
autologin: false
|
|
196
193
|
},
|
|
194
|
+
registForm: {},
|
|
197
195
|
rules: {
|
|
198
196
|
user: [
|
|
199
197
|
{
|
|
200
198
|
required: true,
|
|
201
|
-
message: this.t(
|
|
202
|
-
trigger:
|
|
203
|
-
}
|
|
199
|
+
message: this.t('loginPage.userError'),
|
|
200
|
+
trigger: 'blur'
|
|
201
|
+
}
|
|
204
202
|
],
|
|
205
203
|
password: [
|
|
206
204
|
{
|
|
207
205
|
required: true,
|
|
208
|
-
message: this.t(
|
|
209
|
-
trigger:
|
|
210
|
-
}
|
|
206
|
+
message: this.t('loginPage.PWError'),
|
|
207
|
+
trigger: 'blur'
|
|
208
|
+
}
|
|
211
209
|
],
|
|
212
210
|
name: [
|
|
213
211
|
{
|
|
214
212
|
required: true,
|
|
215
213
|
message: this.t('loginPage.enterTitle'),
|
|
216
|
-
trigger:
|
|
217
|
-
}
|
|
214
|
+
trigger: 'blur'
|
|
215
|
+
}
|
|
218
216
|
],
|
|
219
217
|
phone: [
|
|
220
218
|
{
|
|
221
219
|
required: true,
|
|
222
220
|
message: this.t('loginPage.enterPhone'),
|
|
223
|
-
trigger:
|
|
221
|
+
trigger: 'blur'
|
|
224
222
|
},
|
|
225
223
|
{
|
|
226
224
|
pattern: /^[1]([3-9])[0-9]{9}$/,
|
|
227
225
|
message: this.t('loginPage.correctPhone'),
|
|
228
|
-
trigger:
|
|
229
|
-
}
|
|
226
|
+
trigger: 'blur'
|
|
227
|
+
}
|
|
230
228
|
],
|
|
231
229
|
company: [
|
|
232
230
|
{
|
|
233
231
|
required: true,
|
|
234
232
|
message: this.t('loginPage.enterCompany'),
|
|
235
|
-
trigger:
|
|
236
|
-
}
|
|
233
|
+
trigger: 'blur'
|
|
234
|
+
}
|
|
237
235
|
],
|
|
238
236
|
position: [
|
|
239
237
|
{
|
|
240
238
|
required: true,
|
|
241
239
|
message: this.t('loginPage.selectPosition'),
|
|
242
|
-
trigger:
|
|
243
|
-
}
|
|
240
|
+
trigger: 'change'
|
|
241
|
+
}
|
|
244
242
|
],
|
|
245
243
|
description: [
|
|
246
244
|
{
|
|
247
245
|
required: true,
|
|
248
246
|
message: this.t('loginPage.selectPurpose'),
|
|
249
|
-
trigger:
|
|
250
|
-
}
|
|
251
|
-
]
|
|
247
|
+
trigger: 'change'
|
|
248
|
+
}
|
|
249
|
+
]
|
|
252
250
|
},
|
|
253
251
|
optionsDescription: [
|
|
254
252
|
{
|
|
255
253
|
name: this.t('purposes.findSolution'),
|
|
256
|
-
id:
|
|
254
|
+
id: '1'
|
|
257
255
|
},
|
|
258
256
|
{
|
|
259
257
|
name: this.t('purposes.compareProducts'),
|
|
260
|
-
id:
|
|
258
|
+
id: '2'
|
|
261
259
|
},
|
|
262
260
|
{
|
|
263
261
|
name: this.t('purposes.other'),
|
|
264
|
-
id:
|
|
265
|
-
}
|
|
262
|
+
id: '3'
|
|
263
|
+
}
|
|
266
264
|
],
|
|
267
265
|
optionsCompany: [
|
|
268
266
|
{
|
|
269
267
|
name: this.t('positions.techStaff'),
|
|
270
|
-
id:
|
|
268
|
+
id: '1'
|
|
271
269
|
},
|
|
272
270
|
{
|
|
273
271
|
name: this.t('positions.businessStaff'),
|
|
274
|
-
id:
|
|
272
|
+
id: '2'
|
|
275
273
|
},
|
|
276
274
|
{
|
|
277
275
|
name: this.t('positions.researchStaff'),
|
|
278
|
-
id:
|
|
276
|
+
id: '3'
|
|
279
277
|
},
|
|
280
278
|
{
|
|
281
279
|
name: this.t('positions.marketingStaff'),
|
|
282
|
-
id:
|
|
280
|
+
id: '4'
|
|
283
281
|
},
|
|
284
282
|
{
|
|
285
283
|
name: this.t('positions.operationStaff'),
|
|
286
|
-
id:
|
|
284
|
+
id: '5'
|
|
287
285
|
},
|
|
288
286
|
{
|
|
289
287
|
name: this.t('positions.otherStaff'),
|
|
290
|
-
id:
|
|
291
|
-
}
|
|
288
|
+
id: '6'
|
|
289
|
+
}
|
|
292
290
|
],
|
|
293
|
-
islogin: false
|
|
294
|
-
|
|
295
|
-
};
|
|
291
|
+
islogin: false
|
|
292
|
+
}
|
|
296
293
|
},
|
|
297
294
|
|
|
298
295
|
created: function () {
|
|
299
|
-
this.$store.commit(
|
|
300
|
-
this.$store.commit(
|
|
301
|
-
this.$store.commit(
|
|
302
|
-
this.$tool.data.remove(
|
|
296
|
+
this.$store.commit('clearViewTags')
|
|
297
|
+
this.$store.commit('clearKeepLive')
|
|
298
|
+
this.$store.commit('clearIframeList')
|
|
299
|
+
this.$tool.data.remove('MENU_LIST')
|
|
303
300
|
},
|
|
304
301
|
methods: {
|
|
305
302
|
// 加密
|
|
@@ -309,42 +306,42 @@ export default {
|
|
|
309
306
|
return encryptor.encrypt(txt) // 对数据进行加密
|
|
310
307
|
},
|
|
311
308
|
async login() {
|
|
312
|
-
let validate = await this.$refs.loginForm
|
|
313
|
-
.validate()
|
|
314
|
-
.catch(() => { });
|
|
309
|
+
let validate = await this.$refs.loginForm.validate().catch(() => {})
|
|
315
310
|
if (!validate) {
|
|
316
|
-
return false
|
|
311
|
+
return false
|
|
317
312
|
}
|
|
318
313
|
|
|
319
314
|
let data = {
|
|
320
315
|
username: this.ruleForm.user,
|
|
321
|
-
password: this.ruleForm.password
|
|
322
|
-
}
|
|
316
|
+
password: this.ruleForm.password
|
|
317
|
+
}
|
|
323
318
|
|
|
324
319
|
if (this.isEncryption) {
|
|
325
320
|
const publicKey = await this.$api.auth.key()
|
|
326
321
|
if (publicKey) {
|
|
327
322
|
data = {
|
|
328
323
|
username: this.encrypt(publicKey, this.ruleForm.user),
|
|
329
|
-
password: this.encrypt(publicKey, this.ruleForm.password)
|
|
330
|
-
}
|
|
324
|
+
password: this.encrypt(publicKey, this.ruleForm.password)
|
|
325
|
+
}
|
|
331
326
|
}
|
|
332
327
|
}
|
|
333
328
|
|
|
334
329
|
//获取token
|
|
335
330
|
let token = await this.$api.auth.token(data)
|
|
336
|
-
this.$tool.data.set(
|
|
331
|
+
this.$tool.data.set('TOKEN', token)
|
|
337
332
|
|
|
338
|
-
this.islogin = true
|
|
333
|
+
this.islogin = true
|
|
339
334
|
// 获取所有bu
|
|
340
335
|
let bu = await this.$api.auth.bu()
|
|
341
336
|
if (bu.length == 0) {
|
|
342
|
-
this.$message.warning('用户没有应用权限')
|
|
337
|
+
this.$message.warning('用户没有应用权限')
|
|
343
338
|
return false
|
|
344
339
|
}
|
|
345
340
|
this.$tool.data.set('buList', bu)
|
|
346
341
|
let code = this.$tool.data.get('buCode')
|
|
347
|
-
let item = bu.find(x => {
|
|
342
|
+
let item = bu.find(x => {
|
|
343
|
+
return x.code == code
|
|
344
|
+
})
|
|
348
345
|
if (!item) {
|
|
349
346
|
this.$tool.data.set('buCode', bu[0].code)
|
|
350
347
|
}
|
|
@@ -353,57 +350,110 @@ export default {
|
|
|
353
350
|
let user = await this.$api.auth.user()
|
|
354
351
|
// 处理应用显示逻辑
|
|
355
352
|
let application = [...new Set(user.userAuthInfo.menus.map(permission => permission.split('.')[0].split('_')[0]))]
|
|
356
|
-
user.userAuthInfo.grantedApplications = user.userAuthInfo.grantedApplications.filter(x =>
|
|
353
|
+
user.userAuthInfo.grantedApplications = user.userAuthInfo.grantedApplications.filter(x =>
|
|
354
|
+
application.includes(x.code)
|
|
355
|
+
)
|
|
357
356
|
|
|
358
357
|
let userAuthInfo = {
|
|
359
358
|
...user.userAuthInfo,
|
|
360
359
|
combined: user.combined,
|
|
361
360
|
loginPage: user.loginPage,
|
|
362
|
-
menuContent: user.menuContent
|
|
361
|
+
menuContent: user.menuContent
|
|
363
362
|
}
|
|
364
363
|
this.$tool.data.set('tenantId', user.userAuthInfo.tenantId)
|
|
365
364
|
this.$tool.data.set('userAuthInfo', userAuthInfo)
|
|
366
365
|
// 用与应用菜单显示
|
|
367
366
|
this.$store.state.user = userAuthInfo
|
|
368
367
|
|
|
368
|
+
// 动态菜单
|
|
369
|
+
if (this.$config.MENU_DYNAMIC) {
|
|
370
|
+
let MENU_LIST = this.$tool.data.get('MENU_LIST') || {}
|
|
371
|
+
let menu = await this.$api.auth.menu()
|
|
372
|
+
MENU_LIST['DYNAMIC_MENU'] = this.exportMenu(menu)
|
|
373
|
+
this.$tool.data.set('MENU_LIST', MENU_LIST)
|
|
374
|
+
}
|
|
369
375
|
|
|
370
376
|
// 兼容旧项目设置信息
|
|
371
|
-
sessionStorage.setItem('easyweb_session_passport_current_user', JSON.stringify({
|
|
372
|
-
sessionStorage.setItem('easyweb_session_passport_bu', JSON.stringify({
|
|
373
|
-
sessionStorage.setItem('easyweb_session_passport_bu_list', JSON.stringify({
|
|
374
|
-
document.cookie = `Authorization=Bearer ${token}
|
|
375
|
-
|
|
377
|
+
sessionStorage.setItem('easyweb_session_passport_current_user', JSON.stringify({v: user}))
|
|
378
|
+
sessionStorage.setItem('easyweb_session_passport_bu', JSON.stringify({v: bu[0]}))
|
|
379
|
+
sessionStorage.setItem('easyweb_session_passport_bu_list', JSON.stringify({v: bu}))
|
|
380
|
+
document.cookie = `Authorization=Bearer ${token}`
|
|
376
381
|
|
|
377
382
|
// 检验是否初始化
|
|
378
383
|
if (this.isInitialized) {
|
|
379
384
|
let initialized = await this.$api.auth.initialized()
|
|
380
385
|
this.$tool.data.set('zoneInitialized', initialized)
|
|
381
386
|
if (initialized) {
|
|
382
|
-
this.$router.push(this.$config.DASHBOARD_URL)
|
|
387
|
+
this.$router.push(this.$config.DASHBOARD_URL)
|
|
383
388
|
} else {
|
|
384
|
-
this.$router.push(this.$config.INIT_URL)
|
|
389
|
+
this.$router.push(this.$config.INIT_URL)
|
|
385
390
|
}
|
|
386
391
|
} else {
|
|
387
|
-
this.$router.push(this.$config.DASHBOARD_URL)
|
|
392
|
+
this.$router.push(this.$config.DASHBOARD_URL)
|
|
388
393
|
}
|
|
389
394
|
|
|
390
|
-
|
|
391
|
-
this
|
|
392
|
-
this.islogin = false;
|
|
395
|
+
this.$message.success(this.t('loginPage.loginSuccess'))
|
|
396
|
+
this.islogin = false
|
|
393
397
|
},
|
|
394
398
|
// 申请试用
|
|
395
399
|
async apply() {
|
|
396
|
-
let validate = await this.$refs.registForm
|
|
397
|
-
.validate()
|
|
398
|
-
.catch(() => { });
|
|
400
|
+
let validate = await this.$refs.registForm.validate().catch(() => {})
|
|
399
401
|
if (!validate) {
|
|
400
|
-
return false
|
|
402
|
+
return false
|
|
401
403
|
}
|
|
402
404
|
await this.$api.auth.apply(this.registForm)
|
|
403
|
-
this.$message.success(this.t('loginPage.applySuccess'))
|
|
405
|
+
this.$message.success(this.t('loginPage.applySuccess'))
|
|
406
|
+
},
|
|
407
|
+
// 处理动态菜单
|
|
408
|
+
exportMenu(originData) {
|
|
409
|
+
// 主处理函数
|
|
410
|
+
const processNode = (node, parentRoute = null) => {
|
|
411
|
+
// 创建基础路由结构
|
|
412
|
+
const route = {
|
|
413
|
+
name: node.pageName,
|
|
414
|
+
path: node.path,
|
|
415
|
+
component: node.component, // 组件由外部处理
|
|
416
|
+
sort: node.sort, // 组件由外部处理
|
|
417
|
+
meta: {
|
|
418
|
+
...node.meta,
|
|
419
|
+
code: node.applications[0],
|
|
420
|
+
roles: [...node.authority, node.menuId]
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// 处理子节点
|
|
425
|
+
if (node.children && node.children.length) {
|
|
426
|
+
route.children = node.children.sort((a, b) => a.sort - b.sort).map(child => processNode(child, route))
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return route
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// 按applications分组
|
|
433
|
+
const groupedData = {}
|
|
434
|
+
|
|
435
|
+
originData.forEach(item => {
|
|
436
|
+
// 获取应用类型(如ec、cdp等)
|
|
437
|
+
const appType = item.applications[0]
|
|
438
|
+
|
|
439
|
+
if (!groupedData[appType]) {
|
|
440
|
+
groupedData[appType] = []
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// 处理当前节点
|
|
444
|
+
const processedNode = processNode(item)
|
|
445
|
+
groupedData[appType].push(processedNode)
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
// 对每个应用类型的菜单进行排序
|
|
449
|
+
Object.keys(groupedData).forEach(appType => {
|
|
450
|
+
groupedData[appType].sort((a, b) => a.sort - b.sort)
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
return groupedData
|
|
404
454
|
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
407
457
|
</script>
|
|
408
458
|
|
|
409
459
|
<style lang="scss" scoped>
|