Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
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
tianzhuanghu
ant-design-pro-vue
Commits
fb67e6e2
Commit
fb67e6e2
authored
Dec 14, 2018
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add action check
parent
e6cb6a1a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
4 deletions
+62
-4
main.js
src/main.js
+2
-0
permission.js
src/utils/helper/permission.js
+54
-0
TableList.vue
src/views/list/TableList.vue
+6
-4
No files found.
src/main.js
View file @
fb67e6e2
...
@@ -12,6 +12,7 @@ import 'ant-design-vue/dist/antd.less'; // or 'ant-design-vue/dist/antd.less'
...
@@ -12,6 +12,7 @@ import 'ant-design-vue/dist/antd.less'; // or 'ant-design-vue/dist/antd.less'
import
'@/permission'
// permission control
import
'@/permission'
// permission control
import
'@/utils/filter'
// base filter
import
'@/utils/filter'
// base filter
import
PermissionHelper
from
'@/utils/helper/permission'
import
{
import
{
ACCESS_TOKEN
,
ACCESS_TOKEN
,
...
@@ -33,6 +34,7 @@ Vue.use(Storage, config.storageOptions)
...
@@ -33,6 +34,7 @@ Vue.use(Storage, config.storageOptions)
Vue
.
use
(
Antd
)
Vue
.
use
(
Antd
)
Vue
.
use
(
VueAxios
,
router
)
Vue
.
use
(
VueAxios
,
router
)
Vue
.
use
(
Viser
)
Vue
.
use
(
Viser
)
Vue
.
use
(
PermissionHelper
)
new
Vue
({
new
Vue
({
router
,
router
,
...
...
src/utils/helper/permission.js
0 → 100644
View file @
fb67e6e2
const
PERMISSION_ENUM
=
{
'add'
:
{
key
:
'add'
,
label
:
'新增'
},
'delete'
:
{
key
:
'delete'
,
label
:
'删除'
},
'edit'
:
{
key
:
'edit'
,
label
:
'修改'
},
'query'
:
{
key
:
'query'
,
label
:
'查询'
},
'get'
:
{
key
:
'get'
,
label
:
'详情'
},
'enable'
:
{
key
:
'enable'
,
label
:
'启用'
},
'disable'
:
{
key
:
'disable'
,
label
:
'禁用'
},
'import'
:
{
key
:
'import'
,
label
:
'导入'
},
'export'
:
{
key
:
'import'
,
label
:
'导入'
},
};
function
plugin
(
Vue
)
{
if
(
plugin
.
installed
)
{
return
;
}
!
Vue
.
prototype
.
$auth
&&
Object
.
defineProperties
(
Vue
.
prototype
,
{
$auth
:
{
get
()
{
const
_this
=
this
;
return
(
permissions
)
=>
{
let
[
permission
,
action
]
=
permissions
.
split
(
'.'
);
const
permissionList
=
_this
.
$store
.
getters
.
roles
.
permissions
;
permissionList
.
find
((
val
)
=>
{
return
val
.
permissionId
===
permission
}).
actionList
.
findIndex
((
val
)
=>
{
return
val
===
action
});
return
false
}
}
}
});
!
Vue
.
prototype
.
$enum
&&
Object
.
defineProperties
(
Vue
.
prototype
,
{
$enum
:
{
get
()
{
// const _this = this;
return
(
val
)
=>
{
let
result
=
PERMISSION_ENUM
;
val
&&
val
.
split
(
'.'
).
forEach
(
v
=>
{
result
=
result
&&
result
[
v
]
||
null
});
return
result
}
}
}
});
}
export
default
plugin
\ No newline at end of file
src/views/list/TableList.vue
View file @
fb67e6e2
...
@@ -62,8 +62,8 @@
...
@@ -62,8 +62,8 @@
</div>
</div>
<div
class=
"table-operator"
>
<div
class=
"table-operator"
>
<a-button
type=
"primary"
icon=
"plus"
>
新建
</a-button>
<a-button
type=
"primary"
icon=
"plus"
v-if=
"$auth('table.add')"
>
新建
</a-button>
<a-dropdown
v-if=
"
selectedRowKeys.length > 0"
>
<a-dropdown
v-if=
"
$auth('table.edit') && selectedRowKeys.length > 0"
>
<a-menu
slot=
"overlay"
>
<a-menu
slot=
"overlay"
>
<a-menu-item
key=
"1"
><a-icon
type=
"delete"
/>
删除
</a-menu-item>
<a-menu-item
key=
"1"
><a-icon
type=
"delete"
/>
删除
</a-menu-item>
<!-- lock | unlock -->
<!-- lock | unlock -->
...
@@ -84,8 +84,10 @@
...
@@ -84,8 +84,10 @@
@
onSelect=
"onChange"
@
onSelect=
"onChange"
>
>
<span
slot=
"action"
slot-scope=
"text, record"
>
<span
slot=
"action"
slot-scope=
"text, record"
>
<
template
v-if=
"$auth('table.update')"
>
<a
@
click=
"handleEdit(record)"
>
编辑
</a>
<a
@
click=
"handleEdit(record)"
>
编辑
</a>
<a-divider
type=
"vertical"
/>
<a-divider
type=
"vertical"
/>
</
template
>
<a-dropdown>
<a-dropdown>
<a
class=
"ant-dropdown-link"
>
<a
class=
"ant-dropdown-link"
>
更多
<a-icon
type=
"down"
/>
更多
<a-icon
type=
"down"
/>
...
@@ -94,10 +96,10 @@
...
@@ -94,10 +96,10 @@
<a-menu-item>
<a-menu-item>
<a
href=
"javascript:;"
>
详情
</a>
<a
href=
"javascript:;"
>
详情
</a>
</a-menu-item>
</a-menu-item>
<a-menu-item
>
<a-menu-item
v-if=
"$auth('table.disable')"
>
<a
href=
"javascript:;"
>
禁用
</a>
<a
href=
"javascript:;"
>
禁用
</a>
</a-menu-item>
</a-menu-item>
<a-menu-item
>
<a-menu-item
v-if=
"$auth('table.delete')"
>
<a
href=
"javascript:;"
>
删除
</a>
<a
href=
"javascript:;"
>
删除
</a>
</a-menu-item>
</a-menu-item>
</a-menu>
</a-menu>
...
...
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