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
56e2f21d
authored
Mar 26, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vue3 重构:REVIEW 菜单
parent
d72101b1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
53 deletions
+63
-53
src/api/system/menu/index.ts
+5
-10
src/views/infra/codegen/components/BasicInfoForm.vue
+2
-2
src/views/system/menu/MenuForm.vue
+0
-0
src/views/system/menu/index.vue
+52
-37
src/views/system/role/index.vue
+2
-2
src/views/system/tenantPackage/index.vue
+2
-2
No files found.
src/api/system/menu/index.ts
View file @
56e2f21d
...
...
@@ -18,18 +18,13 @@ export interface MenuVO {
createTime
:
Date
}
export
interface
MenuPageReqVO
{
name
?:
string
status
?:
number
}
// 查询菜单(精简)列表
export
const
listSimpleMenusApi
=
()
=>
{
export
const
getSimpleMenusList
=
()
=>
{
return
request
.
get
({
url
:
'/system/menu/list-all-simple'
})
}
// 查询菜单列表
export
const
getMenuList
Api
=
(
params
:
MenuPageReqVO
)
=>
{
export
const
getMenuList
=
(
params
)
=>
{
return
request
.
get
({
url
:
'/system/menu/list'
,
params
})
}
...
...
@@ -39,16 +34,16 @@ export const getMenuApi = (id: number) => {
}
// 新增菜单
export
const
createMenu
Api
=
(
data
:
MenuVO
)
=>
{
export
const
createMenu
=
(
data
:
MenuVO
)
=>
{
return
request
.
post
({
url
:
'/system/menu/create'
,
data
})
}
// 修改菜单
export
const
updateMenu
Api
=
(
data
:
MenuVO
)
=>
{
export
const
updateMenu
=
(
data
:
MenuVO
)
=>
{
return
request
.
put
({
url
:
'/system/menu/update'
,
data
})
}
// 删除菜单
export
const
deleteMenu
Api
=
(
id
:
number
)
=>
{
export
const
deleteMenu
=
(
id
:
number
)
=>
{
return
request
.
delete
({
url
:
'/system/menu/delete?id='
+
id
})
}
src/views/infra/codegen/components/BasicInfoForm.vue
View file @
56e2f21d
...
...
@@ -6,7 +6,7 @@ import { useForm } from '@/hooks/web/useForm'
import
{
FormSchema
}
from
'@/types/form'
import
{
CodegenTableVO
}
from
'@/api/infra/codegen/types'
import
{
getIntDictOptions
}
from
'@/utils/dict'
import
{
listSimpleMenusApi
}
from
'@/api/system/menu'
import
{
getSimpleMenusList
}
from
'@/api/system/menu'
import
{
handleTree
,
defaultProps
}
from
'@/utils/tree'
import
{
PropType
}
from
'vue'
...
...
@@ -21,7 +21,7 @@ const templateTypeOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_T
const
sceneOptions
=
getIntDictOptions
(
DICT_TYPE
.
INFRA_CODEGEN_SCENE
)
const
menuOptions
=
ref
<
any
>
([])
// 树形结构
const
getTree
=
async
()
=>
{
const
res
=
await
listSimpleMenusApi
()
const
res
=
await
getSimpleMenusList
()
menuOptions
.
value
=
handleTree
(
res
)
}
...
...
src/views/system/menu/
f
orm.vue
→
src/views/system/menu/
MenuF
orm.vue
View file @
56e2f21d
This diff is collapsed.
Click to expand it.
src/views/system/menu/index.vue
View file @
56e2f21d
<
template
>
<!-- 搜索工作栏 -->
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
>
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"菜单名称"
prop=
"name"
>
<el-input
v-model=
"queryParams.name"
placeholder=
"请输入菜单名称"
clearable
@
keyup
.
enter=
"handleQuery"
class=
"!w-240px"
/>
</el-form-item>
<el-form-item
label=
"状态"
prop=
"status"
>
<el-select
v-model=
"queryParams.status"
placeholder=
"菜单状态"
clearable
>
<el-select
v-model=
"queryParams.status"
placeholder=
"请选择菜单状态"
clearable
class=
"!w-240px"
>
<el-option
v-for=
"dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
:key=
"
parseInt(dict.value)
"
v-for=
"dict in get
Int
DictOptions(DICT_TYPE.COMMON_STATUS)"
:key=
"
dict.value
"
:label=
"dict.label"
:value=
"
parseInt(dict.value)
"
:value=
"
dict.value
"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
@
click=
"openModal('create')"
v-hasPermi=
"['system:menu:create']"
>
<el-button
type=
"primary"
plain
@
click=
"openForm('create')"
v-hasPermi=
"['system:menu:create']"
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
</el-button>
<el-button
type=
"danger"
plain
@
click=
"toggleExpandAll"
>
<Icon
icon=
"ep:sort"
class=
"mr-5px"
/>
展开/折叠
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<el-row
:gutter=
"10"
class=
"mb8"
>
<el-col
:span=
"1.5"
>
<el-button
type=
"info"
plain
icon=
"el-icon-sort"
@
click=
"toggleExpandAll"
>
展开/折叠
</el-button
>
</el-col>
</el-row>
<!-- 列表 -->
<ContentWrap>
<el-table
v-loading=
"loading"
:data=
"list"
v-if=
"refreshTable"
row-key=
"id"
v-if=
"refreshTable"
:default-expand-all=
"isExpandAll"
:tree-props=
"
{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column
prop=
"name"
label=
"菜单名称"
:show-overflow-tooltip=
"true"
width=
"250"
/>
<el-table-column
prop=
"icon"
label=
"图标"
align=
"center"
width=
"100"
>
...
...
@@ -60,62 +74,63 @@
<dict-tag
:type=
"DICT_TYPE.COMMON_STATUS"
:value=
"scope.row.status"
/>
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<el-table-column
label=
"操作"
align=
"center"
>
<
template
#
default=
"scope"
>
<el-button
link
type=
"primary"
@
click=
"open
Modal
('update', scope.row.id)"
@
click=
"open
Form
('update', scope.row.id)"
v-hasPermi=
"['system:menu:update']"
>
修改
</el-button
>
修改
</el-button>
<el-button
link
type=
"primary"
@
click=
"open
Modal('create'
, scope.row.id)"
@
click=
"open
Form('create', undefined
, scope.row.id)"
v-hasPermi=
"['system:menu:create']"
>
新增
</el-button
>
新增
</el-button>
<el-button
link
type=
"
primary
"
type=
"
danger
"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['system:menu:delete']"
>
删除
</el-button
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<
menu-form
ref=
"modal
Ref"
@
success=
"getList"
/>
<
MenuForm
ref=
"form
Ref"
@
success=
"getList"
/>
</template>
<
script
setup
lang=
"ts"
name=
"Menu"
>
// 业务相关的 import
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
handleTree
}
from
'@/utils/tree'
import
*
as
MenuApi
from
'@/api/system/menu'
import
MenuForm
from
'./
f
orm.vue'
import
MenuForm
from
'./
MenuF
orm.vue'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
loading
=
ref
(
true
)
// 列表的加载中
const
list
=
ref
<
any
>
([])
// 列表的数据
const
isExpandAll
=
ref
(
false
)
// 是否展开,默认全部折叠
const
refreshTable
=
ref
(
true
)
// 重新渲染表格状态
const
queryParams
=
reactive
({
name
:
undefined
,
status
:
undefined
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
isExpandAll
=
ref
(
false
)
// 是否展开,默认全部折叠
const
refreshTable
=
ref
(
true
)
// 重新渲染表格状态
/** 查询参数列表 */
const
getList
=
async
()
=>
{
loading
.
value
=
true
try
{
const
data
=
await
MenuApi
.
getMenuList
Api
(
queryParams
)
const
data
=
await
MenuApi
.
getMenuList
(
queryParams
)
list
.
value
=
handleTree
(
data
)
}
finally
{
loading
.
value
=
false
...
...
@@ -134,9 +149,9 @@ const resetQuery = () => {
}
/** 添加/修改操作 */
const
modal
Ref
=
ref
()
const
open
Modal
=
async
(
type
:
string
,
i
d
?:
number
)
=>
{
modalRef
.
value
.
openModal
(
type
,
i
d
)
const
form
Ref
=
ref
()
const
open
Form
=
(
type
:
string
,
id
?:
number
,
parentI
d
?:
number
)
=>
{
formRef
.
value
.
open
(
type
,
id
,
parentI
d
)
}
/** 展开/折叠操作 */
...
...
@@ -154,7 +169,7 @@ const handleDelete = async (id: number) => {
// 删除的二次确认
await
message
.
delConfirm
()
// 发起删除
await
MenuApi
.
deleteMenu
Api
(
id
)
await
MenuApi
.
deleteMenu
(
id
)
message
.
success
(
t
(
'common.delSuccess'
))
// 刷新列表
await
getList
()
...
...
src/views/system/role/index.vue
View file @
56e2f21d
...
...
@@ -164,7 +164,7 @@ import { SystemDataScopeEnum } from '@/utils/constants'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
rules
,
allSchemas
}
from
'./role.data'
import
*
as
RoleApi
from
'@/api/system/role'
import
{
listSimpleMenusApi
}
from
'@/api/system/menu'
import
{
getSimpleMenusList
}
from
'@/api/system/menu'
import
{
getSimpleDeptList
}
from
'@/api/system/dept'
import
*
as
PermissionApi
from
'@/api/system/permission'
...
...
@@ -269,7 +269,7 @@ const handleScope = async (type: string, row: RoleApi.RoleVO) => {
actionScopeType
.
value
=
type
dialogScopeVisible
.
value
=
true
if
(
type
===
'menu'
)
{
const
menuRes
=
await
listSimpleMenusApi
()
const
menuRes
=
await
getSimpleMenusList
()
treeOptions
.
value
=
handleTree
(
menuRes
)
const
role
=
await
PermissionApi
.
listRoleMenusApi
(
row
.
id
)
if
(
role
)
{
...
...
src/views/system/tenantPackage/index.vue
View file @
56e2f21d
...
...
@@ -71,7 +71,7 @@ import type { ElTree } from 'element-plus'
// 业务相关的 import
import
{
rules
,
allSchemas
}
from
'./tenantPackage.data'
import
*
as
TenantPackageApi
from
'@/api/system/tenantPackage'
import
{
listSimpleMenusApi
}
from
'@/api/system/menu'
import
{
getSimpleMenusList
}
from
'@/api/system/menu'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
...
...
@@ -102,7 +102,7 @@ const validateCategory = (rule: any, value: any, callback: any) => {
rules
.
menuIds
=
[{
required
:
true
,
validator
:
validateCategory
,
trigger
:
'blur'
}]
const
getTree
=
async
()
=>
{
const
res
=
await
listSimpleMenusApi
()
const
res
=
await
getSimpleMenusList
()
menuOptions
.
value
=
handleTree
(
res
)
}
...
...
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