Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
9
91isoft_web_vue3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
91isoft_web_vue3
Commits
429bab95
Commit
429bab95
authored
Feb 05, 2024
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
角色管理模块功能对接
parent
39860647
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
50 deletions
+143
-50
index.ts
src/api/role/index.ts
+17
-0
types.ts
src/api/role/types.ts
+17
-1
index.vue
src/views/system/role/index.vue
+109
-49
No files found.
src/api/role/index.ts
View file @
429bab95
...
@@ -106,6 +106,23 @@ export function roleMenuTreeSelect(roleId) {
...
@@ -106,6 +106,23 @@ export function roleMenuTreeSelect(roleId) {
url
:
'/system/menu/roleMenuTreeSelect/'
+
roleId
,
url
:
'/system/menu/roleMenuTreeSelect/'
+
roleId
,
method
:
'get'
method
:
'get'
})
})
}
/** 根据角色ID查询菜单下拉树结构 无按钮 */
export
function
roleMenuTreeSelectMC
(
roleId
)
{
return
request
({
url
:
'/system/menu/treeSelectMC/'
+
roleId
,
method
:
'get'
})
}
/**
* 查询角色详细
*
*/
export
function
getRole
(
businessId
:
any
)
{
return
request
({
url
:
'/system/role/detail/'
+
businessId
,
method
:
'get'
})
}
}
/**
/**
* 添加角色
* 添加角色
...
...
src/api/role/types.ts
View file @
429bab95
...
@@ -15,7 +15,23 @@ export interface RoleQuery extends PageQuery {
...
@@ -15,7 +15,23 @@ export interface RoleQuery extends PageQuery {
*/
*/
flag
?:
string
;
flag
?:
string
;
}
}
/**
* 数据权限信息参数
*/
export
interface
permForm
{
/**
* 角色名称
*/
roleName
?:
string
;
/**
* 菜单名称
*/
menuName
?:
string
;
/**
* 权限范围
*/
dataScope
?:
string
;
}
/**
/**
* 角色分页对象
* 角色分页对象
*/
*/
...
...
src/views/system/role/index.vue
View file @
429bab95
...
@@ -9,11 +9,12 @@ import {
...
@@ -9,11 +9,12 @@ import {
updateRoleMenus
,
updateRoleMenus
,
changeRoleStatus
,
changeRoleStatus
,
treeSelect
,
treeSelect
,
roleMenuTreeSelect
roleMenuTreeSelect
,
getRole
,
roleMenuTreeSelectMC
}
from
"@/api/role"
;
}
from
"@/api/role"
;
import
{
getMenuOptions
}
from
"@/api/menu"
;
import
{
getMenuOptions
}
from
"@/api/menu"
;
import
{
handleTree
}
from
'@/utils/common'
import
{
RolePageVO
,
RoleForm
,
RoleQuery
}
from
"@/api/role/types"
;
import
{
RolePageVO
,
RoleForm
,
RoleQuery
,
permForm
}
from
"@/api/role/types"
;
import
{
commonField
}
from
"@/utils/commonField"
;
import
{
commonField
}
from
"@/utils/commonField"
;
defineOptions
({
defineOptions
({
name
:
"Role"
,
name
:
"Role"
,
...
@@ -27,6 +28,7 @@ const hasExportPerm = ref(['sys:role:export']);
...
@@ -27,6 +28,7 @@ const hasExportPerm = ref(['sys:role:export']);
const
queryFormRef
=
ref
(
ElForm
);
const
queryFormRef
=
ref
(
ElForm
);
const
roleFormRef
=
ref
(
ElForm
);
const
roleFormRef
=
ref
(
ElForm
);
const
formRef
=
ref
(
ElForm
);
const
menuRef
=
ref
(
ElTree
);
const
menuRef
=
ref
(
ElTree
);
const
loading
=
ref
(
false
);
const
loading
=
ref
(
false
);
...
@@ -39,6 +41,11 @@ const defaultProps = reactive({
...
@@ -39,6 +41,11 @@ const defaultProps = reactive({
children
:
'children'
,
children
:
'children'
,
label
:
'label'
label
:
'label'
})
})
const
form
=
reactive
<
permForm
>
({
roleName
:
''
,
menuName
:
''
,
dataScope
:
''
,
})
const
queryParams
=
reactive
<
RoleQuery
>
({
const
queryParams
=
reactive
<
RoleQuery
>
({
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
,
pageSize
:
10
,
...
@@ -53,6 +60,28 @@ const statusOptions = reactive([
...
@@ -53,6 +60,28 @@ const statusOptions = reactive([
dictValue
:
'0'
dictValue
:
'0'
}
}
])
])
const
dataScopeOptions
=
reactive
([
{
value
:
'1'
,
label
:
'全部数据权限'
},
{
value
:
'2'
,
label
:
'自定数据权限'
},
{
value
:
'3'
,
label
:
'本部门数据权限'
},
{
value
:
'4'
,
label
:
'本部门及以下数据权限'
},
{
value
:
'5'
,
label
:
'仅本人数据权限'
}
])
const
roleList
=
ref
<
RolePageVO
[]
>
();
const
roleList
=
ref
<
RolePageVO
[]
>
();
const
dialog
=
reactive
({
const
dialog
=
reactive
({
...
@@ -84,7 +113,7 @@ const rules = reactive({
...
@@ -84,7 +113,7 @@ const rules = reactive({
menuIds
:
[{
required
:
true
,
validator
:
validatePass
,
trigger
:
[
"blur"
,
"change"
]
}]
menuIds
:
[{
required
:
true
,
validator
:
validatePass
,
trigger
:
[
"blur"
,
"change"
]
}]
});
});
const
menuDialogVisibl
e
=
ref
(
false
);
const
openDataScop
e
=
ref
(
false
);
const
menuList
=
ref
<
OptionType
[]
>
([]);
const
menuList
=
ref
<
OptionType
[]
>
([]);
...
@@ -280,32 +309,16 @@ function handleDelete(row?: any) {
...
@@ -280,32 +309,16 @@ function handleDelete(row?: any) {
}
}
/** 打开分配菜单弹窗 */
/** 打开分配菜单弹窗 */
function
openMenuDialog
(
row
:
RolePageVO
)
{
function
handleMenu
(
row
:
RolePageVO
)
{
const
roleId
=
row
.
id
;
const
roleId
=
row
.
businessId
;
if
(
roleId
)
{
// 查询菜单列表树形显示
checkedRole
=
{
roleMenuTreeSelectMC
(
roleId
).
then
(
res
=>
{
id
:
roleId
,
menuList
.
value
=
handleTree
(
res
.
data
,
'businessId'
,
''
,
''
,
''
)
name
:
row
.
name
,
getRole
(
roleId
).
then
(
response
=>
{
};
Object
.
assign
(
form
,
response
.
data
);
menuDialogVisible
.
value
=
true
;
openDataScope
.
value
=
true
loading
.
value
=
true
;
})
})
// 获取所有的菜单
getMenuOptions
().
then
((
response
)
=>
{
menuList
.
value
=
response
.
data
;
// 回显角色已拥有的菜单
getRoleMenuIds
(
roleId
)
.
then
(({
data
})
=>
{
const
checkedMenuIds
=
data
;
checkedMenuIds
.
forEach
((
menuId
)
=>
menuRef
.
value
.
setChecked
(
menuId
,
true
,
false
)
);
})
.
finally
(()
=>
{
loading
.
value
=
false
;
});
});
}
}
}
/** 角色分配菜单保存提交 */
/** 角色分配菜单保存提交 */
...
@@ -320,7 +333,7 @@ function handleRoleMenuSubmit() {
...
@@ -320,7 +333,7 @@ function handleRoleMenuSubmit() {
updateRoleMenus
(
roleId
,
checkedMenuIds
)
updateRoleMenus
(
roleId
,
checkedMenuIds
)
.
then
(()
=>
{
.
then
(()
=>
{
ElMessage
.
success
(
"分配权限成功"
);
ElMessage
.
success
(
"分配权限成功"
);
menuDialogVisibl
e
.
value
=
false
;
openDataScop
e
.
value
=
false
;
resetQuery
();
resetQuery
();
})
})
.
finally
(()
=>
{
.
finally
(()
=>
{
...
@@ -446,13 +459,14 @@ onMounted(() => {
...
@@ -446,13 +459,14 @@ onMounted(() => {
:size=
"commonField.size"
:size=
"commonField.size"
@
click=
"openDialog(scope.row.businessId)"
@
click=
"openDialog(scope.row.businessId)"
>
{{
commonField
.
updateName
}}
</el-button>
>
{{
commonField
.
updateName
}}
</el-button>
<!-- //数据权限-->
<el-button
<el-button
v-hasPermi=
"hasDelPerm"
v-hasPermi=
"hasDelPerm"
:class=
"commonField.delClass"
:class=
"commonField.delClass"
:type=
"commonField.typeParent"
:type=
"commonField.typeParent"
link
link
:size=
"commonField.size"
:size=
"commonField.size"
@
click=
"
openMenuDialog
(scope.row)"
@
click=
"
handleMenu
(scope.row)"
>
{{
commonField
.
dataPower
}}
</el-button>
>
{{
commonField
.
dataPower
}}
</el-button>
<!-- //删除-->
<!-- //删除-->
<el-button
<el-button
...
@@ -530,30 +544,76 @@ onMounted(() => {
...
@@ -530,30 +544,76 @@ onMounted(() => {
<!-- 分配菜单弹窗 -->
<!-- 分配菜单弹窗 -->
<el-dialog
<el-dialog
v-model=
"
menuDialogVisibl
e"
v-model=
"
openDataScop
e"
:title=
"'【' + checkedRole.name + '】权限分配'
"
title=
"数据权限信息
"
width=
"800px"
width=
"800px"
@
close=
"handleQuery"
>
>
<el-scrollbar
v-loading=
"loading"
max-height=
"600px"
>
<el-row>
<el-tree
<el-col
:span=
"12"
>
ref=
"menuRef"
<el-form
ref=
"formRef"
:model=
"form"
label-width=
"70px"
>
node-key=
"value"
<el-form-item
label=
"角色名称"
>
show-checkbox
<el-input
v-model
.
trim=
"form.roleName"
placeholder=
"请输入角色名称"
show-word-limit
:maxlength=
"30"
:disabled=
"true"
/>
:data=
"menuList"
</el-form-item>
:default-expand-all=
"true"
<el-table
>
highlight-current-row
<
template
#
default=
"{ data }"
>
:data=
"menuList"
{{
data
.
label
}}
row-key=
"businessId"
</
template
>
:tree-props=
"{children: 'children', hasChildren: 'hasChildren'}"
</el-tree>
default-expand-all
</el-scrollbar>
max-height=
"400px"
>
<el-table-column
prop=
"menuName"
label=
"菜单名称"
:show-overflow-tooltip=
"true"
width=
"230px"
/>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<
template
#
default=
"scope"
>
<el-button
size=
"mini"
type=
"text"
@
click=
"handleDataScope(scope.row)"
>
修改
</el-button>
</
template
>
</el-table-column>
</el-table>
</el-form>
</el-col>
<el-col
:span=
"12"
>
<el-form
:model=
"form"
label-width=
"80px"
>
<el-form-item
label=
"菜单名称"
prop=
"roleName"
>
<el-input
v-model=
"form.menuName"
placeholder=
"未选择菜单名称"
disabled
style=
"width: 300px"
/>
</el-form-item>
<el-form-item
label=
"权限范围"
style=
"width: 300px"
>
<el-select
v-model=
"form.dataScope"
style=
"width: 300px"
>
<el-option
v-for=
"item in dataScopeOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
/>
</el-select>
</el-form-item>
<el-form-item
v-show=
"form.dataScope == 2"
label=
"数据权限"
>
<el-tree
ref=
"dept"
class=
"tree-border"
:data=
"deptOptions"
show-checkbox
node-key=
"id"
check-strictly
empty-text=
"加载中,请稍后"
:props=
"defaultProps"
:default-expanded-keys=
"customSizeTree"
@
check-change=
"handleDeptCheckChange"
/>
</el-form-item>
</el-form>
</el-col>
</el-row>
<
template
#
footer
>
<
template
#
footer
>
<div
class=
"dialog-footer"
>
<div
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"handleRoleMenuSubmit"
<el-button
type=
"primary"
@
click=
"handleRoleMenuSubmit"
>
确 定
</el-button
>
确 定
</el-button
>
>
<el-button
@
click=
"
menuDialogVisibl
e = false"
>
取 消
</el-button>
<el-button
@
click=
"
openDataScop
e = false"
>
取 消
</el-button>
</div>
</div>
</
template
>
</
template
>
</el-dialog>
</el-dialog>
...
...
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