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() {
...
@@ -11,3 +11,7 @@ export function getMenuDataApi() {
export
function
addMenuApi
(
data
)
{
export
function
addMenuApi
(
data
)
{
return
postReq
(
'
/api/v1/menus
'
,
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
>
<
template
>
<a-popconfirm
title=
"确认是否删除"
ok-text=
"确认"
cancel-text=
"取消"
@
confirm=
"onOk"
@
cancel=
"onCancel"
>
<a-popconfirm
title=
"确认是否删除"
ok-text=
"确认"
cancel-text=
"取消"
@
confirm=
"onOk"
>
<a>
删除
</a>
<a>
删除
</a>
</a-popconfirm>
</a-popconfirm>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
EMPTY_FUN
}
from
'
@/utils
'
;
import
{
EMPTY_FUN
}
from
'
@/utils
'
;
import
{
delReq
}
from
'
@/utils
'
;
export
default
{
export
default
{
props
:
{
props
:
{
onOk
:
Function
,
url
:
String
,
onCancel
:
{
cb
:
{
type
:
Function
,
type
:
Function
,
default
:
EMPTY_FUN
,
default
:
EMPTY_FUN
,
},
},
},
},
methods
:
{
async
onOk
()
{
await
delReq
(
this
.
url
);
this
.
cb
();
},
},
};
};
</
script
>
</
script
>
src/components/table/index.vue
View file @
9df83c42
...
@@ -124,6 +124,7 @@ export default {
...
@@ -124,6 +124,7 @@ export default {
this
.
submitLoading
=
true
;
this
.
submitLoading
=
true
;
try
{
try
{
await
this
.
addBtn
?.
onOk
();
await
this
.
addBtn
?.
onOk
();
this
.
getData
();
}
catch
(
error
)
{
}
catch
(
error
)
{
// todo
// todo
}
}
...
@@ -133,9 +134,6 @@ export default {
...
@@ -133,9 +134,6 @@ export default {
showAdd
()
{
showAdd
()
{
this
.
addVisible
=
true
;
this
.
addVisible
=
true
;
},
},
refresh
()
{
this
.
getData
();
},
},
},
};
};
</
script
>
</
script
>
...
...
src/pages/system/view/menu/MenuManagement.vue
View file @
9df83c42
...
@@ -7,12 +7,6 @@
...
@@ -7,12 +7,6 @@
noPage
noPage
ref=
"table"
ref=
"table"
>
>
<template
#search
="
{query}">
<a-form-model-item
label=
"菜单、目录名称"
>
<a-input
v-model=
"query.name"
/>
</a-form-model-item>
</
template
>
<template
#add
>
<template
#add
>
<Form
ref=
"addForm"
/>
<Form
ref=
"addForm"
/>
</
template
>
</
template
>
...
@@ -44,9 +38,8 @@ export default {
...
@@ -44,9 +38,8 @@ export default {
text
:
'
新建
'
,
text
:
'
新建
'
,
title
:
'
菜单配置
'
,
title
:
'
菜单配置
'
,
width
:
400
,
width
:
400
,
async
onOk
()
{
onOk
()
{
await
vm
.
$refs
[
'
addForm
'
]?.
submit
();
return
vm
.
$refs
[
'
addForm
'
]?.
submit
();
vm
.
refreshTable
();
},
},
},
},
sortOrder
:
'
ascend
'
,
sortOrder
:
'
ascend
'
,
...
@@ -57,7 +50,7 @@ export default {
...
@@ -57,7 +50,7 @@ export default {
methods
:
{
methods
:
{
formatData
:
convertListToTree
,
formatData
:
convertListToTree
,
refreshTable
()
{
refreshTable
()
{
this
.
$refs
[
'
table
'
].
refresh
();
this
.
$refs
[
'
table
'
].
getData
();
},
},
async
delMenu
(
id
)
{
async
delMenu
(
id
)
{
await
delMenuApi
(
id
);
await
delMenuApi
(
id
);
...
...
src/pages/system/view/menu/form.vue
View file @
9df83c42
<
template
>
<
template
>
<a-form-model
layout=
"vertical"
:model=
"form"
:rules=
"rules"
>
<a-form-model
layout=
"vertical"
:model=
"form"
:rules=
"rules"
>
<a-form-model-item
label=
"父级"
v-if=
"isAdd"
>
<a-form-model-item
label=
"父级"
v-if=
"isAdd"
>
<a-tree
<MenuTree
@
check=
"onCheck"
:value=
"checkedKeys"
checkStrictly
/>
v-model=
"checkedKeys"
:selectable=
"false"
checkable
checkStrictly
:replaceFields=
"replaceFields"
:tree-data=
"treeData"
@
check=
"onCheck"
style=
"max-height:400px"
class=
"tw-overflow-y-auto"
/>
</a-form-model-item>
</a-form-model-item>
<a-form-model-item
label=
"类型"
>
<a-form-model-item
label=
"类型"
>
<a-radio-group
v-model=
"form.menuType"
:disabled=
"isEdit"
>
<a-radio-group
v-model=
"form.menuType"
:disabled=
"isEdit"
>
...
@@ -41,10 +31,11 @@
...
@@ -41,10 +31,11 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
getMenuDataApi
,
addMenuApi
}
from
'
@/api
'
;
import
{
addMenuApi
}
from
'
@/api
'
;
import
{
convertListToTree
}
from
'
@/utils
'
;
import
MenuTree
from
'
@/components/menu_tree/index.vue
'
;
export
default
{
export
default
{
components
:
{
MenuTree
},
data
:
()
=>
({
data
:
()
=>
({
type
:
0
,
type
:
0
,
form
:
{
form
:
{
...
@@ -55,19 +46,11 @@ export default {
...
@@ -55,19 +46,11 @@ export default {
rules
:
{
rules
:
{
menuUrl
:
[{
required
:
true
}],
menuUrl
:
[{
required
:
true
}],
},
},
replaceFields
:
{
title
:
'
menuName
'
,
key
:
'
menuId
'
,
},
checkedKeys
:
{
checkedKeys
:
{
checked
:
[],
checked
:
[],
halfChecked
:
[],
halfChecked
:
[],
},
},
treeData
:
[],
}),
}),
mounted
()
{
this
.
getMenuData
();
},
computed
:
{
computed
:
{
isAdd
()
{
isAdd
()
{
return
this
.
type
===
0
;
return
this
.
type
===
0
;
...
@@ -77,15 +60,12 @@ export default {
...
@@ -77,15 +60,12 @@ export default {
},
},
},
},
methods
:
{
methods
:
{
async
getMenuData
()
{
this
.
treeData
=
convertListToTree
(
await
getMenuDataApi
(),
true
);
console
.
log
(
this
.
treeData
);
},
submit
()
{
submit
()
{
return
addMenuApi
({
...
this
.
form
,
parentMenuId
:
this
.
checkedKeys
.
checked
[
0
]
??
0
});
return
addMenuApi
({
...
this
.
form
,
parentMenuId
:
this
.
checkedKeys
.
checked
[
0
]
??
0
});
},
},
onCheck
(
checkedKeys
)
{
onCheck
(
checkedKeys
)
{
this
.
checkedKeys
.
checked
=
checkedKeys
.
checked
.
slice
(
-
1
);
const
checked
=
checkedKeys
.
checked
.
slice
(
-
1
);
this
.
checkedKeys
=
{
checked
};
},
},
setEdit
(
data
)
{
setEdit
(
data
)
{
this
.
type
=
1
;
this
.
type
=
1
;
...
...
src/pages/system/view/role/RoleManagement.vue
View file @
9df83c42
<
template
>
<
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>
</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