Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Starter Web Vue
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
product
kim3-web-vue
Starter Web Vue
Commits
9df83c42
Commit
9df83c42
authored
Jun 27, 2021
by
水落(YangLei)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 完善角色管理
parent
8846a011
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
166 additions
and
44 deletions
+166
-44
src/api/menu.js
src/api/menu.js
+4
-0
src/components/menu_tree/index.vue
src/components/menu_tree/index.vue
+49
-0
src/components/popconfirm_delete/index.vue
src/components/popconfirm_delete/index.vue
+10
-3
src/components/table/index.vue
src/components/table/index.vue
+1
-3
src/pages/system/view/menu/MenuManagement.vue
src/pages/system/view/menu/MenuManagement.vue
+3
-10
src/pages/system/view/menu/form.vue
src/pages/system/view/menu/form.vue
+6
-26
src/pages/system/view/role/RoleManagement.vue
src/pages/system/view/role/RoleManagement.vue
+42
-2
src/pages/system/view/role/form.vue
src/pages/system/view/role/form.vue
+51
-0
No files found.
src/api/menu.js
View file @
9df83c42
...
...
@@ -11,3 +11,7 @@ export function getMenuDataApi() {
export
function
addMenuApi
(
data
)
{
return
postReq
(
'
/api/v1/menus
'
,
data
);
}
export
function
addRoleApi
(
data
)
{
return
postReq
(
'
/api/v1/roles
'
,
data
);
}
src/components/menu_tree/index.vue
0 → 100644
View file @
9df83c42
<
template
>
<a-tree
:checkedKeys=
"value"
:selectable=
"false"
checkable
:replaceFields=
"replaceFields"
:tree-data=
"treeData"
style=
"max-height:400px"
class=
"tw-overflow-y-auto"
v-bind=
"$attrs"
v-on=
"$listeners"
/>
</
template
>
<
script
>
import
{
getMenuDataApi
}
from
'
@/api
'
;
import
{
convertListToTree
}
from
'
@/utils
'
;
export
default
{
model
:
{
prop
:
'
value
'
,
event
:
'
check
'
,
},
props
:
{
value
:
[
Object
,
Array
],
showMenu
:
Boolean
,
},
data
()
{
return
{
treeData
:
[],
replaceFields
:
{
title
:
'
menuName
'
,
key
:
'
menuId
'
,
},
};
},
async
mounted
()
{
this
.
rawData
=
await
getMenuDataApi
();
this
.
treeData
=
convertListToTree
(
this
.
rawData
,
!
this
.
showMenu
);
},
methods
:
{
get
()
{
if
(
Array
.
isArray
(
this
.
value
))
return
this
.
rawData
.
filter
(
m
=>
this
.
value
.
includes
(
m
.
menuId
));
return
[];
},
},
};
</
script
>
src/components/popconfirm_delete/index.vue
View file @
9df83c42
<
template
>
<a-popconfirm
title=
"确认是否删除"
ok-text=
"确认"
cancel-text=
"取消"
@
confirm=
"onOk"
@
cancel=
"onCancel"
>
<a-popconfirm
title=
"确认是否删除"
ok-text=
"确认"
cancel-text=
"取消"
@
confirm=
"onOk"
>
<a>
删除
</a>
</a-popconfirm>
</
template
>
<
script
>
import
{
EMPTY_FUN
}
from
'
@/utils
'
;
import
{
delReq
}
from
'
@/utils
'
;
export
default
{
props
:
{
onOk
:
Function
,
onCancel
:
{
url
:
String
,
cb
:
{
type
:
Function
,
default
:
EMPTY_FUN
,
},
},
methods
:
{
async
onOk
()
{
await
delReq
(
this
.
url
);
this
.
cb
();
},
},
};
</
script
>
src/components/table/index.vue
View file @
9df83c42
...
...
@@ -124,6 +124,7 @@ export default {
this
.
submitLoading
=
true
;
try
{
await
this
.
addBtn
?.
onOk
();
this
.
getData
();
}
catch
(
error
)
{
// todo
}
...
...
@@ -133,9 +134,6 @@ export default {
showAdd
()
{
this
.
addVisible
=
true
;
},
refresh
()
{
this
.
getData
();
},
},
};
</
script
>
...
...
src/pages/system/view/menu/MenuManagement.vue
View file @
9df83c42
...
...
@@ -7,12 +7,6 @@
noPage
ref=
"table"
>
<template
#search
="
{query}">
<a-form-model-item
label=
"菜单、目录名称"
>
<a-input
v-model=
"query.name"
/>
</a-form-model-item>
</
template
>
<template
#add
>
<Form
ref=
"addForm"
/>
</
template
>
...
...
@@ -44,9 +38,8 @@ export default {
text
:
'
新建
'
,
title
:
'
菜单配置
'
,
width
:
400
,
async
onOk
()
{
await
vm
.
$refs
[
'
addForm
'
]?.
submit
();
vm
.
refreshTable
();
onOk
()
{
return
vm
.
$refs
[
'
addForm
'
]?.
submit
();
},
},
sortOrder
:
'
ascend
'
,
...
...
@@ -57,7 +50,7 @@ export default {
methods
:
{
formatData
:
convertListToTree
,
refreshTable
()
{
this
.
$refs
[
'
table
'
].
refresh
();
this
.
$refs
[
'
table
'
].
getData
();
},
async
delMenu
(
id
)
{
await
delMenuApi
(
id
);
...
...
src/pages/system/view/menu/form.vue
View file @
9df83c42
<
template
>
<a-form-model
layout=
"vertical"
:model=
"form"
:rules=
"rules"
>
<a-form-model-item
label=
"父级"
v-if=
"isAdd"
>
<a-tree
v-model=
"checkedKeys"
:selectable=
"false"
checkable
checkStrictly
:replaceFields=
"replaceFields"
:tree-data=
"treeData"
@
check=
"onCheck"
style=
"max-height:400px"
class=
"tw-overflow-y-auto"
/>
<MenuTree
@
check=
"onCheck"
:value=
"checkedKeys"
checkStrictly
/>
</a-form-model-item>
<a-form-model-item
label=
"类型"
>
<a-radio-group
v-model=
"form.menuType"
:disabled=
"isEdit"
>
...
...
@@ -41,10 +31,11 @@
</
template
>
<
script
>
import
{
getMenuDataApi
,
addMenuApi
}
from
'
@/api
'
;
import
{
convertListToTree
}
from
'
@/utils
'
;
import
{
addMenuApi
}
from
'
@/api
'
;
import
MenuTree
from
'
@/components/menu_tree/index.vue
'
;
export
default
{
components
:
{
MenuTree
},
data
:
()
=>
({
type
:
0
,
form
:
{
...
...
@@ -55,19 +46,11 @@ export default {
rules
:
{
menuUrl
:
[{
required
:
true
}],
},
replaceFields
:
{
title
:
'
menuName
'
,
key
:
'
menuId
'
,
},
checkedKeys
:
{
checked
:
[],
halfChecked
:
[],
},
treeData
:
[],
}),
mounted
()
{
this
.
getMenuData
();
},
computed
:
{
isAdd
()
{
return
this
.
type
===
0
;
...
...
@@ -77,15 +60,12 @@ export default {
},
},
methods
:
{
async
getMenuData
()
{
this
.
treeData
=
convertListToTree
(
await
getMenuDataApi
(),
true
);
console
.
log
(
this
.
treeData
);
},
submit
()
{
return
addMenuApi
({
...
this
.
form
,
parentMenuId
:
this
.
checkedKeys
.
checked
[
0
]
??
0
});
},
onCheck
(
checkedKeys
)
{
this
.
checkedKeys
.
checked
=
checkedKeys
.
checked
.
slice
(
-
1
);
const
checked
=
checkedKeys
.
checked
.
slice
(
-
1
);
this
.
checkedKeys
=
{
checked
};
},
setEdit
(
data
)
{
this
.
type
=
1
;
...
...
src/pages/system/view/role/RoleManagement.vue
View file @
9df83c42
<
template
>
<h1>
Menu Management
</h1>
<my-table
url=
"/api/v1/roles"
rowKey=
"roleId"
:addBtn=
"addBtn"
ref=
"table"
>
<template
#add
>
<Form
ref=
"form"
/>
</
template
>
<a-table-column
title=
"名称"
data-index=
"roleName"
/>
<a-table-column
title=
"说明"
data-index=
"remark"
/>
<a-table-column
title=
"操作"
>
<
template
#default=
"row"
>
<a
@
click=
"() => view(row, 2)"
>
查看
</a>
<a-divider
type=
"vertical"
/>
<a
@
click=
"() => view(row, 1)"
>
编辑
</a>
<a-divider
type=
"vertical"
/>
<PopconfirmDelete
:url=
"`/api/v1/roles/$
{row.roleId}`" :cb="refreshTable" />
</
template
>
</a-table-column>
</my-table>
</template>
<
script
>
import
Form
from
'
./form.vue
'
;
import
PopconfirmDelete
from
'
@/components/popconfirm_delete/index.vue
'
;
export
default
{
components
:
{
Form
,
PopconfirmDelete
},
data
()
{
return
{
addBtn
:
{
width
:
400
,
onOk
:
()
=>
this
.
$refs
[
'
form
'
]?.
submit
()
},
};
},
methods
:
{
refreshTable
()
{
this
.
$refs
[
'
table
'
]?.
getData
();
},
view
(
data
,
type
)
{
this
.
$refs
[
'
table
'
]?.
showAdd
();
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'
form
'
].
setData
(
data
,
type
);
});
},
},
};
</
script
>
src/pages/system/view/role/form.vue
0 → 100644
View file @
9df83c42
<
template
>
<a-form-model
layout=
"vertical"
:model=
"form"
:rules=
"rules"
>
<a-form-model-item
label=
"角色名称"
>
<a-input
v-model=
"form.roleName"
:disabled=
"isView"
/>
</a-form-model-item>
<a-form-model-item
label=
"角色编码"
>
<a-input
v-model=
"form.roleCode"
:disabled=
"isView"
/>
</a-form-model-item>
<a-form-model-item
label=
"角色说明"
prop=
"remark"
>
<a-input
v-model=
"form.remark"
:disabled=
"isView"
/>
</a-form-model-item>
<a-form-model-item
label=
"菜单权限"
>
<MenuTree
v-model=
"checkedKeys"
showMenu
ref=
"menuTree"
:disabled=
"isView"
/>
</a-form-model-item>
</a-form-model>
</
template
>
<
script
>
import
MenuTree
from
'
@/components/menu_tree/index.vue
'
;
import
{
addRoleApi
}
from
'
@/api
'
;
export
default
{
components
:
{
MenuTree
},
data
()
{
return
{
type
:
0
,
form
:
{},
rules
:
{},
checkedKeys
:
[],
};
},
computed
:
{
isEdit
()
{
return
this
.
type
===
1
;
},
isView
()
{
return
this
.
type
===
2
;
},
},
methods
:
{
submit
()
{
return
addRoleApi
({
...
this
.
form
,
authorityList
:
this
.
$refs
[
'
menuTree
'
].
get
()
});
},
setData
(
data
,
type
)
{
this
.
form
=
data
;
this
.
type
=
type
;
},
},
};
</
script
>
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