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
f5b76818
Commit
f5b76818
authored
Jul 21, 2021
by
shuiluo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化代码
parent
0a73a4bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
48 deletions
+53
-48
src/pages/system/role/RoleManagement.vue
src/pages/system/role/RoleManagement.vue
+15
-21
src/pages/system/role/form.vue
src/pages/system/role/form.vue
+38
-27
No files found.
src/pages/system/role/RoleManagement.vue
View file @
f5b76818
<
template
>
<
template
>
<
my-table
url=
"/api/v1/roles"
rowKey=
"roleId"
:addBtn=
"addBtn"
ref=
"table"
noPage
>
<
Table
url=
"/api/v1/roles"
rowKey=
"roleId"
addBtn
ref=
"table"
noPage
:buttons=
"buttons"
>
<template
#drawer
>
<template
#drawer
="
drawer
"
>
<Form
ref=
"form
"
/>
<Form
v-bind=
"drawer
"
/>
</
template
>
</
template
>
<a-table-column
title=
"角色名称"
data-index=
"roleName"
/>
<a-table-column
title=
"角色名称"
data-index=
"roleName"
/>
<a-table-column
title=
"角色编码"
data-index=
"roleCode"
/>
<a-table-column
title=
"角色编码"
data-index=
"roleCode"
/>
<a-table-column
title=
"角色说明"
data-index=
"remark"
/>
<a-table-column
title=
"角色说明"
data-index=
"remark"
/>
<a-table-column
title=
"操作"
>
</Table>
<
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
>
<
script
>
import
Form
from
'
./form.vue
'
;
import
Form
from
'
./form.vue
'
;
import
PopconfirmDelete
from
'
@/components/popconfirm_delete/index.vu
e
'
;
import
{
Table
}
from
'
@/components/tabl
e
'
;
export
default
{
export
default
{
components
:
{
Form
,
PopconfirmDelet
e
},
components
:
{
Form
,
Tabl
e
},
data
()
{
data
()
{
return
{
return
{
addBtn
:
{
onOk
:
()
=>
this
.
$refs
[
'
form
'
]?.
submit
()
},
buttons
:
[
{
label
:
this
.
$t
(
'
table.edit
'
),
click
:
this
.
edit
,
},
{
type
:
'
confirm
'
,
url
:
(
row
)
=>
`/api/v1/roles/
${
row
.
roleId
}
`
,
after
:
this
.
refreshTable
},
],
};
};
},
},
methods
:
{
methods
:
{
refreshTable
()
{
refreshTable
()
{
this
.
$refs
[
'
table
'
]?.
getData
();
this
.
$refs
[
'
table
'
]?.
getData
();
},
},
view
(
data
,
type
)
{
edit
(
row
)
{
this
.
$refs
[
'
table
'
]?.
show
({
type
,
noFooter
:
type
===
2
});
this
.
$refs
.
table
.
show
({
row
,
title
:
this
.
$t
(
'
table.edit
'
),
type
:
'
edit
'
});
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'
form
'
].
setData
({
...
data
},
type
);
});
},
},
},
},
};
};
...
...
src/pages/system/role/form.vue
View file @
f5b76818
<
template
>
<
template
>
<a-form-model
layout=
"vertical"
:model=
"form"
:rules=
"rules"
ref=
"DrawerForm"
>
<Wraper
:hidden=
"hidden"
:refresh=
"refresh"
:onOk=
"sumit"
>
<a-form-model-item
label=
"角色名称"
>
<a-form-model
layout=
"vertical"
:model=
"form"
:rules=
"rules"
ref=
"DrawerForm"
>
<a-input
v-model=
"form.roleName"
:disabled=
"isView"
/>
<a-form-model-item
label=
"角色名称"
>
</a-form-model-item>
<a-input
v-model=
"form.roleName"
:disabled=
"isView"
/>
<a-form-model-item
label=
"角色编码"
>
</a-form-model-item>
<a-input
v-model=
"form.roleCode"
:disabled=
"isView"
/>
<a-form-model-item
label=
"角色编码"
>
</a-form-model-item>
<a-input
v-model=
"form.roleCode"
:disabled=
"isView"
/>
<a-form-model-item
label=
"角色说明"
prop=
"remark"
>
</a-form-model-item>
<a-input
v-model=
"form.remark"
:disabled=
"isView"
/>
<a-form-model-item
label=
"角色说明"
prop=
"remark"
>
</a-form-model-item>
<a-input
v-model=
"form.remark"
:disabled=
"isView"
/>
</a-form-model-item>
<a-form-model-item
label=
"菜单权限"
>
<a-form-model-item
label=
"菜单权限"
>
<MenuTree
<MenuTree
v-model=
"checkedKeys"
v-model=
"checkedKeys"
:defaultCheckedKeys=
"defaultCheckedKeys"
:defaultCheckedKeys=
"defaultCheckedKeys"
showMenu
showMenu
ref=
"menuTree"
ref=
"menuTree"
:disabled=
"isView"
:disabled=
"isView"
/>
/>
</a-form-model-item>
</a-form-model-item>
</a-form-model>
</a-form-model>
</Wraper>
</
template
>
</
template
>
<
script
>
<
script
>
import
MenuTree
from
'
@/components/menu_tree/index.vue
'
;
import
MenuTree
from
'
@/components/menu_tree/index.vue
'
;
import
{
addRoleApi
,
getRoleApi
,
updateRoleApi
}
from
'
@/api
'
;
import
{
addRoleApi
,
getRoleApi
,
updateRoleApi
}
from
'
@/api
'
;
import
FormMixin
from
'
@/components/FormMixin
'
;
import
FormMixin
from
'
@/components/FormMixin
'
;
import
{
WraperMixins
}
from
'
@/components/table
'
;
export
default
{
export
default
{
mixins
:
[
FormMixin
],
mixins
:
[
FormMixin
,
WraperMixins
],
components
:
{
MenuTree
},
components
:
{
MenuTree
},
data
()
{
data
()
{
return
{
return
{
...
@@ -38,11 +41,22 @@ export default {
...
@@ -38,11 +41,22 @@ export default {
defaultCheckedKeys
:
[],
defaultCheckedKeys
:
[],
};
};
},
},
computed
:
{
isEdit
()
{
return
this
.
type
===
'
edit
'
;
},
},
mounted
()
{
if
(
this
.
type
)
{
this
.
getData
(
this
.
row
.
rowId
);
}
},
methods
:
{
methods
:
{
submit
()
{
submit
()
{
const
query
=
{
const
query
=
{
...
this
.
form
,
...
this
.
form
,
authorityList
:
this
.
$refs
[
'
menuTree
'
].
get
().
map
(
i
=>
({
authorityList
:
this
.
$refs
[
'
menuTree
'
].
get
().
map
(
(
i
)
=>
({
...
i
,
...
i
,
nodeId
:
i
.
menuId
,
nodeId
:
i
.
menuId
,
parentNodeId
:
i
.
parentMenuId
,
parentNodeId
:
i
.
parentMenuId
,
...
@@ -51,14 +65,11 @@ export default {
...
@@ -51,14 +65,11 @@ export default {
};
};
return
this
.
isEdit
?
updateRoleApi
(
query
)
:
addRoleApi
(
query
);
return
this
.
isEdit
?
updateRoleApi
(
query
)
:
addRoleApi
(
query
);
},
},
setData
(
data
,
type
)
{
this
.
getData
(
data
.
roleId
);
this
.
type
=
type
;
},
async
getData
(
id
)
{
async
getData
(
id
)
{
const
res
=
await
getRoleApi
(
id
);
const
res
=
await
getRoleApi
(
id
);
this
.
form
=
res
;
this
.
form
=
res
;
this
.
defaultCheckedKeys
=
res
.
menuComponentKeys
.
map
(
i
=>
parseInt
(
i
.
split
(
'
-
'
)[
0
]));
this
.
defaultCheckedKeys
=
res
.
menuComponentKeys
.
map
(
(
i
)
=>
parseInt
(
i
.
split
(
'
-
'
)[
0
]));
},
},
},
},
};
};
...
...
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