Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
58455cd0
authored
Jan 23, 2025
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码评审】Bpm:模型列表的优化
parent
bf437421
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
18 deletions
+17
-18
src/directives/permission/hasPermi.ts
+10
-5
src/store/modules/user.ts
+5
-8
src/views/bpm/model/CategoryDraggableModel.vue
+2
-5
No files found.
src/directives/permission/hasPermi.ts
View file @
58455cd0
import
type
{
App
}
from
'vue'
import
type
{
App
}
from
'vue'
import
{
useUserStore
}
from
"@/store/modules/user"
;
import
{
useUserStore
}
from
'@/store/modules/user'
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
/** 判断权限的指令 directive */
export
function
hasPermi
(
app
:
App
<
Element
>
)
{
export
function
hasPermi
(
app
:
App
<
Element
>
)
{
app
.
directive
(
'hasPermi'
,
(
el
,
binding
)
=>
{
app
.
directive
(
'hasPermi'
,
(
el
,
binding
)
=>
{
const
{
value
}
=
binding
const
{
value
}
=
binding
...
@@ -18,9 +19,13 @@ export function hasPermi(app: App<Element>) {
...
@@ -18,9 +19,13 @@ export function hasPermi(app: App<Element>) {
}
}
})
})
}
}
const
userStore
=
useUserStore
();
/** 判断权限的方法 function */
const
userStore
=
useUserStore
()
const
all_permission
=
'*:*:*'
const
all_permission
=
'*:*:*'
export
const
hasPermission
=
(
permission
:
string
[])
=>
{
export
const
hasPermission
=
(
permission
:
string
[])
=>
{
return
userStore
.
permissionsSet
.
has
(
all_permission
)
||
return
(
permission
.
some
(
permission
=>
userStore
.
permissionsSet
.
has
(
permission
))
userStore
.
permissions
.
has
(
all_permission
)
||
permission
.
some
((
permission
)
=>
userStore
.
permissions
.
has
(
permission
))
)
}
}
src/store/modules/user.ts
View file @
58455cd0
...
@@ -15,8 +15,7 @@ interface UserVO {
...
@@ -15,8 +15,7 @@ interface UserVO {
interface
UserInfoVO
{
interface
UserInfoVO
{
// USER 缓存
// USER 缓存
permissions
:
string
[]
permissions
:
Set
<
string
>
permissionsSet
:
Set
<
string
>
roles
:
string
[]
roles
:
string
[]
isSetUser
:
boolean
isSetUser
:
boolean
user
:
UserVO
user
:
UserVO
...
@@ -24,8 +23,7 @@ interface UserInfoVO {
...
@@ -24,8 +23,7 @@ interface UserInfoVO {
export
const
useUserStore
=
defineStore
(
'admin-user'
,
{
export
const
useUserStore
=
defineStore
(
'admin-user'
,
{
state
:
():
UserInfoVO
=>
({
state
:
():
UserInfoVO
=>
({
permissions
:
[],
permissions
:
new
Set
<
string
>
(),
permissionsSet
:
new
Set
<
string
>
(),
roles
:
[],
roles
:
[],
isSetUser
:
false
,
isSetUser
:
false
,
user
:
{
user
:
{
...
@@ -36,7 +34,7 @@ export const useUserStore = defineStore('admin-user', {
...
@@ -36,7 +34,7 @@ export const useUserStore = defineStore('admin-user', {
}
}
}),
}),
getters
:
{
getters
:
{
getPermissions
():
string
[]
{
getPermissions
():
Set
<
string
>
{
return
this
.
permissions
return
this
.
permissions
},
},
getRoles
():
string
[]
{
getRoles
():
string
[]
{
...
@@ -59,8 +57,7 @@ export const useUserStore = defineStore('admin-user', {
...
@@ -59,8 +57,7 @@ export const useUserStore = defineStore('admin-user', {
if
(
!
userInfo
)
{
if
(
!
userInfo
)
{
userInfo
=
await
getInfo
()
userInfo
=
await
getInfo
()
}
}
this
.
permissions
=
userInfo
.
permissions
this
.
permissions
=
new
Set
(
userInfo
.
permissions
)
this
.
permissionsSet
=
new
Set
(
userInfo
.
permissions
)
this
.
roles
=
userInfo
.
roles
this
.
roles
=
userInfo
.
roles
this
.
user
=
userInfo
.
user
this
.
user
=
userInfo
.
user
this
.
isSetUser
=
true
this
.
isSetUser
=
true
...
@@ -88,7 +85,7 @@ export const useUserStore = defineStore('admin-user', {
...
@@ -88,7 +85,7 @@ export const useUserStore = defineStore('admin-user', {
this
.
resetState
()
this
.
resetState
()
},
},
resetState
()
{
resetState
()
{
this
.
permissions
=
[]
this
.
permissions
=
new
Set
<
string
>
()
this
.
roles
=
[]
this
.
roles
=
[]
this
.
isSetUser
=
false
this
.
isSetUser
=
false
this
.
user
=
{
this
.
user
=
{
...
...
src/views/bpm/model/CategoryDraggableModel.vue
View file @
58455cd0
...
@@ -190,10 +190,7 @@
...
@@ -190,10 +190,7 @@
<el-button
type=
"primary"
link
>
更多
</el-button>
<el-button
type=
"primary"
link
>
更多
</el-button>
<template
#
dropdown
>
<template
#
dropdown
>
<el-dropdown-menu>
<el-dropdown-menu>
<el-dropdown-item
<el-dropdown-item
command=
"handleDefinitionList"
v-if=
"hasPermiPdQuery"
>
command=
"handleDefinitionList"
v-if=
"hasPermiPdQuery"
>
历史
历史
</el-dropdown-item>
</el-dropdown-item>
<el-dropdown-item
<el-dropdown-item
...
@@ -278,6 +275,7 @@ const originalData: any = ref([]) // 原始数据
...
@@ -278,6 +275,7 @@ const originalData: any = ref([]) // 原始数据
const
modelList
:
any
=
ref
([])
// 模型列表
const
modelList
:
any
=
ref
([])
// 模型列表
const
isExpand
=
ref
(
false
)
// 是否处于展开状态
const
isExpand
=
ref
(
false
)
// 是否处于展开状态
/** 权限校验:通过 computed 解决列表的卡顿问题 */
const
hasPermiUpdate
=
computed
(()
=>
{
const
hasPermiUpdate
=
computed
(()
=>
{
return
checkPermi
([
'bpm:model:update'
])
return
checkPermi
([
'bpm:model:update'
])
})
})
...
@@ -294,7 +292,6 @@ const hasPermiPdQuery = computed(() => {
...
@@ -294,7 +292,6 @@ const hasPermiPdQuery = computed(() => {
return
checkPermi
([
'bpm:process-definition:query'
])
return
checkPermi
([
'bpm:process-definition:query'
])
})
})
/** '更多'操作按钮 */
/** '更多'操作按钮 */
const
handleModelCommand
=
(
command
:
string
,
row
:
any
)
=>
{
const
handleModelCommand
=
(
command
:
string
,
row
:
any
)
=>
{
switch
(
command
)
{
switch
(
command
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment