Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
SHR
/
tFIMS
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 655828a2
authored
Sep 03, 2019
by
cwq0219
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
http://192.168.3.233:8090/glsx-web/tFIMS
2 parents
cf9c18db
6dceac3d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
124 additions
and
85 deletions
src/components/d2-auth/d2-auth-btn.js
src/components/d2-auth/d2-auth-btn.vue
src/components/index.js
src/libs/util.permision.js
src/router/routes.js
src/store/modules/d2admin/modules/auth.js
src/views/userManage/user/index.vue
src/components/d2-auth/d2-auth-btn.js
0 → 100644
View file @
655828a
export
default
{
name
:
'AuthButton'
,
props
:
{
label
:
{
type
:
String
,
default
:
''
},
size
:
{
type
:
String
,
default
:
'mini'
},
// type: {
// type: String,
// default: 'text'
// },
category
:{
type
:
String
,
default
:
'operation'
},
loading
:
{
type
:
Boolean
,
default
:
false
},
disabled
:
{
type
:
Boolean
,
default
:
false
},
id
:
{
type
:
String
,
default
:
null
},
accept
:
{
type
:
String
,
default
:
null
},
mapping
:
{
type
:
Object
,
default
:
null
},
data
:
Object
,
},
functional
:
true
,
// 开启函数化组件
render
:
(
h
,
ctx
)
=>
{
const
_this
=
ctx
.
parent
//获取 vue this 实例
// console.log(ctx);
/**
* 获取传入参数
* category 非必填 button 类别 暂时两种 1 表格操作:operation ,2 Button 按钮: action 默认 operation ----- route 中不标明 视为默认值 operation
* data 点击按钮时 需要得到的参数 比如 table 中的 当前行数据 row
* mapping 非必填 但: 当列表中的操作选项 根据 某个字段 变化的话 必填 且 必须 注明 field: 字段名
* label 当传入label 字段时 标识明确指定渲染该label 的按钮
*/
const
{
category
,
data
,
mapping
,
label
}
=
ctx
.
props
let
curBtns
=
[]
/**
* 判断一个按钮(btn)是否存在与当前行(data) 的映射关系(mapping)中
* @param {*} btn
*/
const
filter
=
btn
=>
mapping
?
mapping
[
data
[
mapping
[
'field'
]]].
includes
(
btn
.
label
):
true
const
$store
=
_this
.
$store
.
getters
[
'd2admin/auth/curBtns'
]
if
(
label
){
//指定label
const
__item
=
$store
.
find
(
btn
=>
(
btn
.
label
===
label
)
&&
filter
(
btn
))
__item
&&
curBtns
.
push
(
__item
)
}
else
{
/**
* 拿到当前模块(页面) 所拥有按钮列表 过滤type属性 与 映射关系 返回需要显示的按钮列表
*/
curBtns
=
$store
.
filter
(
btn
=>
{
if
(
category
===
'operation'
){
return
(
btn
.
category
===
'operation'
||
!
btn
.
category
)
&&
filter
(
btn
)
}
return
(
btn
.
category
===
category
)
&&
filter
(
btn
)
})
}
if
(
curBtns
.
length
===
0
)
return
''
const
__aBtns
=
[]
/**
* 循环最终显示的按钮列表
* 并渲染到页面
*/
curBtns
.
forEach
(
btn
=>
__aBtns
.
push
(
h
(
'el-button'
,
{
props
:
{
type
:
btn
.
type
||
'text'
,
},
style
:{
color
:
btn
.
color
},
on
:
{
click
:
()
=>
btn
.
handle
&&
_this
[
btn
.
handle
](
data
)
}
},
[
btn
.
label
])))
return
h
(
'div'
,
{},
[...
__aBtns
,
ctx
.
children
])
}
}
\ No newline at end of file
src/components/d2-auth/d2-auth-btn.vue
deleted
100644 → 0
View file @
cf9c18d
<
template
>
<el-button
:size=
"size"
:type=
"type"
:loading=
"loading"
v-if=
"isInRole"
@
click=
"handleClick"
>
{{
label
}}
<slot></slot>
</el-button>
</
template
>
<
script
>
import
{
mapGetters
}
from
'vuex'
export
default
{
name
:
'AuthButton'
,
props
:
{
label
:
{
type
:
String
,
default
:
'Button'
},
size
:
{
type
:
String
,
default
:
'mini'
},
type
:
{
type
:
String
,
default
:
'text'
},
loading
:
{
type
:
Boolean
,
default
:
false
},
disabled
:
{
type
:
Boolean
,
default
:
false
},
id
:
{
type
:
String
,
default
:
null
}
},
computed
:
{
...
mapGetters
(
'd2admin/auth'
,
[
'curBtns'
])
},
data
()
{
return
{
isInRole
:
false
}
},
created
()
{
// this.$vrm.setRoles(this.btnIdAll)
if
(
this
.
curBtns
){
// const { action, operation } = this.curBtns
// console.log(this.label);
this
.
isInRole
=
this
.
curBtns
.
find
(
obj
=>
obj
.
id
===
this
.
id
||
obj
.
label
===
this
.
label
)
}
},
methods
:
{
handleClick
:
function
()
{
this
.
$emit
(
'e-auth-click'
,
{})
}
}
}
</
script
>
<
style
scoped
>
</
style
>
src/components/index.js
View file @
655828a
import
Vue
from
'vue'
import
d2Container
from
'./d2-container'
import
authButton
from
'./d2-auth/d2-auth-btn.
vue
'
import
authButton
from
'./d2-auth/d2-auth-btn.
js
'
// 注意 有些组件使用异步加载会有影响
Vue
.
component
(
'd2-container'
,
d2Container
)
...
...
src/libs/util.permision.js
View file @
655828a
...
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-09-0
2 16:20:21
* @Last Modified time: 2019-09-0
3 09:07:46
*/
const
permision
=
{}
/**
...
...
src/router/routes.js
View file @
655828a
...
...
@@ -303,7 +303,8 @@ export const resources = {
auth
:
[{
// 列表操作
id
:
'1070101'
,
pid
:
'10701'
,
label
:
'审核'
label
:
'审核'
,
handle
:
'handleEdit'
},
{
//
id
:
'1070102'
,
pid
:
'10701'
,
...
...
@@ -319,7 +320,8 @@ export const resources = {
},
{
//
id
:
'1070105'
,
pid
:
'10701'
,
label
:
'禁用'
label
:
'禁用'
,
color
:
'#FF0000'
},
{
//
id
:
'1070106'
,
pid
:
'10701'
,
...
...
@@ -327,7 +329,10 @@ export const resources = {
},
{
// 列表操作
id
:
'1070107'
,
pid
:
'10701'
,
label
:
'创建用户'
label
:
'创建用户'
,
category
:
'action'
,
type
:
'button'
,
handle
:
'handleRegister'
}],
component
:
_import
(
'userManage/user'
)
},
...
...
src/store/modules/d2admin/modules/auth.js
View file @
655828a
...
...
@@ -2,7 +2,7 @@
* @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-09-0
2 16:30:11
* @Last Modified time: 2019-09-0
3 09:03:37
*/
import
util
from
'@/libs/util.js'
import
router
from
'@/router'
...
...
@@ -118,7 +118,7 @@ export default {
// 获取权限资源点
const
__source
=
await
dispatch
(
'load'
)
// 过滤资源点 并动态添加到路由
const
{
route
,
btn
}
=
util
.
permision
.
packRoutesBtns
({...
sources
,
'101'
:
home
},
__source
)
const
{
route
,
btn
}
=
util
.
permision
.
packRoutesBtns
({...
sources
,
[
home
.
meta
.
id
]
:
home
},
__source
)
frameInRoutes
[
0
].
children
=
[
home
,
...
route
,
...
sys
]
router
.
addRoutes
(
frameInRoutes
)
state
.
btns
=
btn
...
...
src/views/userManage/user/index.vue
View file @
655828a
...
...
@@ -67,7 +67,7 @@
<el-row
style=
"height: 40px; line-height: 40px"
>
<el-col
:span=
"12"
>
用户列表
</el-col>
<el-col
:span=
"12"
style=
"text-align: right"
>
<
el-button
@
click=
"register()"
>
创建用户
</el
-button>
<
auth-button
category=
"action"
label=
"创建用户"
></auth
-button>
</el-col>
</el-row>
<el-table
:data=
"tableData"
v-loading=
"tableLoading"
border
style=
"margin: 20px 0;"
>
...
...
@@ -87,12 +87,7 @@
</el-table-column>
<el-table-column
align=
"center"
label=
"操作"
>
<
template
slot-scope=
"scope"
>
<auth-button
type=
"text"
label=
"重置密码"
@
click=
"handleEdit(scope.row, scope.$index)"
></auth-button>
<auth-button
type=
"text"
label=
"审核"
@
click=
"handleEdit(scope.row, scope.$index)"
></auth-button>
<auth-button
type=
"text"
label=
"编辑"
@
click=
"handleEdit(scope.row, scope.$index)"
></auth-button>
<auth-button
type=
"text"
label=
"延期"
@
click=
"handleEdit(scope.row, scope.$index)"
></auth-button>
<auth-button
type=
"text"
label=
"禁用"
@
click=
"handleEdit(scope.row, scope.$index)"
></auth-button>
<auth-button
type=
"text"
label=
"激活"
@
click=
"handleEdit(scope.row, scope.$index)"
></auth-button>
<auth-button
:mapping=
"mapping"
:data=
"scope.row"
></auth-button>
</
template
>
</el-table-column>
</el-table>
...
...
@@ -127,6 +122,13 @@ export default {
},
data
()
{
return
{
mapping
:
Object
.
freeze
({
'field'
:
'status'
,
'1'
:[
'重置密码'
,
'编辑'
,
'延期'
,
'禁用'
],
'2'
:[
'重置密码'
,
'编辑'
,
'激活'
],
'3'
:[
'重置密码'
,
'编辑'
,
'激活'
],
'4'
:[
'审核'
]
}),
// 新增/编辑弹窗
editVisible
:
false
,
editForm
:
{
...
...
@@ -173,7 +175,8 @@ export default {
return
{
1
:
"正常"
,
2
:
"已过期"
,
3
:
'禁用'
3
:
'禁用'
,
4
:
'待审核'
}[
cellValue
.
status
];
}
},
...
...
@@ -264,7 +267,9 @@ export default {
this
.
tableLoading
=
false
;
});
},
handleRegister
(){
console
.
log
(
this
.
searchForm
);
},
// 页码
handleSizeChange
(
value
)
{
this
.
page
.
pageSize
=
value
;
...
...
@@ -277,7 +282,9 @@ export default {
// 调接口
this
.
loadUserList
();
},
handleEdit
(
row
){
console
.
log
(
row
);
},
handleDelete
(
index
,
row
)
{
this
.
$confirm
(
"确认删除?"
,
"删除"
,
{
comfirmButtonText
:
"确认"
,
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment