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
fd6fd9e5
authored
Sep 06, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】SYSTEM:快速开关菜单的按钮
parent
15ed1cf5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
src/views/system/menu/index.vue
+11
-5
No files found.
src/views/system/menu/index.vue
View file @
fd6fd9e5
...
@@ -84,9 +84,8 @@
...
@@ -84,9 +84,8 @@
<el-table-column
:show-overflow-tooltip=
"true"
label=
"权限标识"
prop=
"permission"
/>
<el-table-column
:show-overflow-tooltip=
"true"
label=
"权限标识"
prop=
"permission"
/>
<el-table-column
:show-overflow-tooltip=
"true"
label=
"组件路径"
prop=
"component"
/>
<el-table-column
:show-overflow-tooltip=
"true"
label=
"组件路径"
prop=
"component"
/>
<el-table-column
:show-overflow-tooltip=
"true"
label=
"组件名称"
prop=
"componentName"
/>
<el-table-column
:show-overflow-tooltip=
"true"
label=
"组件名称"
prop=
"componentName"
/>
<el-table-column
label=
"状态"
prop=
"status"
width=
"160"
>
<el-table-column
label=
"状态"
prop=
"status"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.COMMON_STATUS"
:value=
"scope.row.status"
/>
<el-switch
<el-switch
class=
"ml-4px"
class=
"ml-4px"
v-model=
"scope.row.status"
v-model=
"scope.row.status"
...
@@ -94,7 +93,7 @@
...
@@ -94,7 +93,7 @@
:active-value=
"CommonStatusEnum.ENABLE"
:active-value=
"CommonStatusEnum.ENABLE"
:inactive-value=
"CommonStatusEnum.DISABLE"
:inactive-value=
"CommonStatusEnum.DISABLE"
:loading=
"menuStatusUpdating[scope.row.id]"
:loading=
"menuStatusUpdating[scope.row.id]"
@
change=
"(val) =>
onMenu
StatusChanged(scope.row, val as number)"
@
change=
"(val) =>
handle
StatusChanged(scope.row, val as number)"
/>
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -148,7 +147,6 @@ const { t } = useI18n() // 国际化
...
@@ -148,7 +147,6 @@ const { t } = useI18n() // 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
loading
=
ref
(
true
)
// 列表的加载中
const
loading
=
ref
(
true
)
// 列表的加载中
const
menuStatusUpdating
=
ref
({})
// 列表的加载中
const
list
=
ref
<
any
>
([])
// 列表的数据
const
list
=
ref
<
any
>
([])
// 列表的数据
const
queryParams
=
reactive
({
const
queryParams
=
reactive
({
name
:
undefined
,
name
:
undefined
,
...
@@ -220,11 +218,19 @@ const handleDelete = async (id: number) => {
...
@@ -220,11 +218,19 @@ const handleDelete = async (id: number) => {
}
catch
{}
}
catch
{}
}
}
const
onMenuStatusChanged
=
async
(
menu
:
MenuVO
,
val
:
number
)
=>
{
/** 开启/关闭菜单的状态 */
const
menuStatusUpdating
=
ref
({})
// 菜单状态更新中的 menu 映射。key:菜单编号,value:是否更新中
const
handleStatusChanged
=
async
(
menu
:
MenuVO
,
val
:
number
)
=>
{
// 1. 标记 menu.id 更新中
menuStatusUpdating
.
value
[
menu
.
id
]
=
true
menuStatusUpdating
.
value
[
menu
.
id
]
=
true
try
{
// 2. 发起更新状态
menu
.
status
=
val
menu
.
status
=
val
await
MenuApi
.
updateMenu
(
menu
)
await
MenuApi
.
updateMenu
(
menu
)
}
finally
{
// 3. 标记 menu.id 更新完成
menuStatusUpdating
.
value
[
menu
.
id
]
=
false
menuStatusUpdating
.
value
[
menu
.
id
]
=
false
}
}
}
/** 初始化 **/
/** 初始化 **/
...
...
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