Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
account
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 d82fa804
authored
Aug 08, 2021
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交角色详情
1 parent
14d48b28
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
41 deletions
html/employee/add.html
html/employee/index.html
html/role/add.html
html/role/detail.html
html/employee/add.html
View file @
d82fa80
...
...
@@ -188,14 +188,7 @@
if
(
res
.
code
==
'0'
)
{
if
(
id
)
{
getById
(
function
(
checkedList
)
{
visibleMerchant
=
tree
.
create
(
'visibleInferiorMerTree'
,
res
.
data
,
{
checkedList
:
checkedList
}
// { onNodeCreated: function(event, treeId, treeNode) {
// if (p.indexOf(treeNode.id+'') != -1) {
// treeNode.checked = true
// visibleMerchant.updateNode(treeNode);
// }
// }}
)
visibleMerchant
=
tree
.
create
(
'visibleInferiorMerTree'
,
res
.
data
,
{
checkedList
:
checkedList
})
})
}
else
{
visibleMerchant
=
tree
.
create
(
'visibleInferiorMerTree'
,
res
.
data
)
...
...
@@ -231,6 +224,9 @@
addEl
.
removeClass
(
'show'
)
addEl
.
addClass
(
'hide'
)
var
visibleInferiorMerArr
=
data
.
visibleInferiorMer
.
split
(
','
)
$
.
each
(
visibleInferiorMerArr
,
function
(
index
,
item
)
{
visibleInferiorMerArr
[
index
]
=
+
item
})
// var visibleInferiorMerArr = [32, 38]
callback
(
visibleInferiorMerArr
)
}
...
...
@@ -294,7 +290,7 @@
var
params
=
helper
.
clone
(
true
,
data
.
field
,
otherParams
)
request
(
params
,
function
(
result
)
{
if
(
result
.
code
==
'0'
)
{
//
window.history.back()
window
.
history
.
back
()
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
...
...
html/employee/index.html
View file @
d82fa80
...
...
@@ -103,10 +103,12 @@
getTabelList
(
employeeTable
)
// 获取table列表接口
function
getTabelList
(
table
,
search
,
isResetPageNum
)
{
var
pageNum
=
isResetPageNum
?
1
:
employeeTable
.
config
.
index
var
pageSize
=
employeeTable
.
config
.
limit
search
=
search
||
{}
var
params
=
helper
.
clone
(
false
,
{
pageNum
:
table
.
config
.
index
,
pageSize
:
table
.
config
.
limit
,
pageNum
:
pageNum
,
pageSize
:
pageSize
,
method
:
'cn.com.glsx.merchants.staff.findStaffByPage'
},
search
)
request
(
params
,
...
...
html/role/add.html
View file @
d82fa80
...
...
@@ -100,7 +100,8 @@
// 选项卡标题的lay-id属性值
id
:
id
})
var
getTpl
=
rolesAuth
.
innerHTML
,
// 模板内容
var
getTpl
=
'<div id="select{{d.id}}"></div> <div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}"><ul class="layui-tab-title"></ul> <div class="layui-tab-content"></div></div>'
// var getTpl = tpl//rolesAuth.innerHTML, // 模板内容
view
=
document
.
getElementById
(
'role'
+
id
)
templateData
.
id
=
id
// 渲染模版的数据
laytpl
(
getTpl
).
render
(
templateData
,
function
(
html
)
{
...
...
@@ -404,17 +405,18 @@
})
}
console
.
log
(
requestList
)
}
})
</script>
<script
type=
"text/html"
id=
"rolesAuth"
>
<
div
id
=
"select{{d.id}}"
><
/div
>
`
<div id="select{{d.id}}"></div>
<div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}">
<ul class="layui-tab-title">
</ul>
<div class="layui-tab-content">
</div>
<
/div
>
</div>
`
</script>
<script
type=
"text/html"
id=
"treeAuth"
>
<!--
<
button
class
=
"layui-btn"
data
-
type
=
"d.id"
id
=
"checkedAll"
>
全选
<
/button
>
...
...
html/role/detail.html
View file @
d82fa80
...
...
@@ -34,9 +34,8 @@
</div>
</div>
<h3
class=
"content-title layui-form"
>
角色权限
<select
id=
"accountType"
name=
"accountType"
lay-filter=
"accountSelect"
>
</select>
<!-- <select id="accountType" name="accountType" lay-filter="accountSelect">
</select> -->
</h3>
<div
class=
"layui-tab"
lay-filter=
"roleAuth"
>
<ul
class=
"layui-tab-title"
></ul>
...
...
@@ -48,49 +47,122 @@
<script
src=
"https://www.layuicdn.com/layui/layui.js"
></script>
<script
src=
"/js/load.js"
></script>
<script>
layui
.
use
([
'request'
,
'gtree'
,
'element'
,
'helper'
,
'form'
],
function
()
{
layui
.
use
([
'request'
,
'gtree'
,
'element'
,
'helper'
,
'form'
,
'laytpl'
],
function
()
{
var
request
=
layui
.
request
var
tree
=
layui
.
gtree
var
helper
=
layui
.
helper
var
form
=
layui
.
form
var
element
=
layui
.
element
var
laytpl
=
layui
.
laytpl
var
xmSelect
=
layui
.
xmSelect
var
$
=
layui
.
$
var
id
=
qs
(
'id'
)
var
role
id
=
qs
(
'id'
)
var
merchantId
=
qs
(
'merchantId'
)
var
basicArr
=
[
'roleName'
,
'id'
,
'roleDescription'
]
var
roleData
=
{}
var
menuFunTreeData
=
[]
var
templateData
=
{}
var
treeData
=
{}
// 查询角色详情
getById
()
//
getById()
findMenuFunTreeByMerId
()
form
.
on
(
'select(accountSelect)'
,
function
(
data
){
console
.
log
(
data
.
elem
);
//得到select原始DOM对象
console
.
log
(
data
.
value
);
//得到被选中的值
console
.
log
(
data
.
othis
);
//得到美化后的DOM对象
var
id
=
data
.
value
})
// form.on('select(accountSelect)', function(data){
// console.log(data.elem); //得到select原始DOM对象
// console.log(data.value); //得到被选中的值
// console.log(data.othis); //得到美化后的DOM对象
// var id = data.value
// })
var
active
=
{
tabAdd
:
function
(
item
)
{
/**
* 第一级tab添加
* item: {name: 选项卡名称, value: 选项卡值}
* roleAuth: 选项卡过滤器的名称 lay-filter绑定的名字
* content: 一个放置模板的视图容器,用于呈现渲染结果 带有id的div
* id:选项卡标题的lay-id属性值
* 需要引入laytpl 模块
* rolesAuth:模板的id
* view 放置模板的视图容器的dom
* templateData:用于渲染模板的数据
* productList:复选下拉框的list,修改过的数据{name: '', value: ''}
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/
tabAdd
:
function
(
item
)
{
// 渠道的id,一层选项卡的id
var
id
=
item
.
value
// roleAuth 一层选项卡过滤器的名称
element
.
tabAdd
(
'roleAuth'
,
{
title
:
item
.
title
,
// 放置模板视图的上一级div
content
:
'<div id="role'
+
id
+
'"></div>'
,
id
:
item
.
value
// 选项卡标题的lay-id属性值
id
:
id
})
var
getTpl
=
'<div id="select{{d.id}}"></div> <div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}"><ul class="layui-tab-title"></ul> <div class="layui-tab-content"></div></div>'
// var getTpl = tpl//rolesAuth.innerHTML, // 模板内容
view
=
document
.
getElementById
(
'role'
+
id
)
templateData
.
id
=
id
// 渲染模版的数据
laytpl
(
getTpl
).
render
(
templateData
,
function
(
html
)
{
view
.
innerHTML
=
html
})
},
// tab删除
tabDelete
:
function
(
name
,
id
)
{
element
.
tabDelete
(
name
,
id
)
},
// tab Change
tabChange
:
function
(
name
,
id
)
{
element
.
tabChange
(
name
,
id
)
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd
:
function
(
item
,
id
,
products
,
defaultList
)
{
console
.
log
(
defaultList
)
var
productId
=
'tab_'
+
id
+
'_'
+
item
.
value
var
filterName
=
'treeTab'
+
id
// 过滤器的名称 lay-filter
element
.
tabAdd
(
filterName
,
{
title
:
item
.
name
,
content
:
'<div id="treeTab'
+
productId
+
'"></div>'
,
// 放置模板视图的div
id
:
productId
})
// var getTreeTpl = treeAuth.innerHTML, // 获取的模板的id的内容
var
getTreeTpl
=
'<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>'
treeView
=
document
.
getElementById
(
'treeTab'
+
productId
)
// 放置模板视图的div
treeData
[
id
]
=
treeData
[
id
]
||
{}
treeData
[
id
][
item
.
value
]
=
treeData
[
id
][
item
.
value
]
||
{}
treeData
[
id
][
item
.
value
].
id
=
productId
// 渲染模版的数据
treeData
[
id
][
item
.
value
].
productId
=
item
.
value
laytpl
(
getTreeTpl
).
render
(
treeData
[
id
][
item
.
value
],
function
(
html
)
{
treeView
.
innerHTML
=
html
})
var
treeListData
=
[]
$
.
each
(
products
,
function
(
index
,
i
)
{
if
(
item
.
value
==
i
.
productId
)
{
treeListData
=
i
.
merchantProTreeResponses
}
})
var
treedom
=
'tree_'
+
productId
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
checkedList
:
defaultList
,
chkDisabled
:
true
})
}
}
function
getById
()
{
var
params
=
{
id
:
id
,
method
:
'org.ore.api.role.getById'
}
function
getById
(
callback
)
{
var
params
=
{
id
:
role
id
,
method
:
'org.ore.api.role.getById'
}
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
console
.
log
(
roleData
)
roleData
=
helper
.
clone
(
true
,
res
.
data
)
for
(
var
i
in
basicArr
)
{
$
(
'#'
+
[
basicArr
[
i
]]).
text
(
roleData
[
basicArr
[
i
]])
}
callback
(
roleData
.
responseList
)
}
})
}
...
...
@@ -103,17 +175,60 @@
if
(
res
.
code
==
'0'
)
{
menuFunTreeData
=
res
.
data
console
.
log
(
menuFunTreeData
)
var
select
=
$
(
'#accountType'
)
$
.
each
(
menuFunTreeData
,
function
(
index
,
item
)
{
select
.
append
(
new
Option
(
item
.
accounttypeName
,
item
.
accounttypeId
))
})
form
.
render
(
'select'
)
$
.
each
(
menuFunTreeData
[
0
].
products
,
function
(
index
,
i
)
{
active
.
tabAdd
({
title
:
i
.
productName
,
value
:
i
.
productId
})
// var select = $('#accountType')
// $.each(menuFunTreeData, function (index, item) {
// select.append(new Option(item.accounttypeName, item.accounttypeId))
// })
// form.render('select')
getById
(
function
(
responseList
)
{
console
.
log
(
'responseList:'
,
responseList
)
if
(
responseList
&&
responseList
.
length
!=
0
)
{
$
.
each
(
menuFunTreeData
,
function
(
index
,
item
)
{
for
(
var
i
=
0
;
i
<
responseList
.
length
;
i
++
)
{
var
productData
=
responseList
[
i
]
if
(
item
.
accounttypeId
==
productData
.
accounttypeId
)
{
active
.
tabAdd
({
title
:
item
.
accounttypeName
,
value
:
item
.
accounttypeId
})
var
menuData
=
[]
for
(
var
j
=
0
;
j
<
productData
.
productList
.
length
;
j
++
)
{
menuData
=
productData
.
productList
[
j
]
active
.
treeTabAdd
({
name
:
menuData
.
productName
,
value
:
menuData
.
productId
},
item
.
accounttypeId
,
item
.
products
,
menuData
.
idList
)
}
var
filterName
=
'treeTab'
+
item
.
accounttypeId
var
productId
=
'tab_'
+
item
.
accounttypeId
+
'_'
+
item
.
products
[
0
].
productId
active
.
tabChange
(
filterName
,
productId
)
}
break
}
// $.each(responseList, function (idx, i) {
// if (item.accounttypeId == i.accounttypeId) {
// console.log(i, item)
// detailTreeData.push(i)
// active.tabAdd({
// title: item.accounttypeName,
// value: item.accounttypeId
// })
// var menuData = []
// for(var j = 0; j < i.productList.length; j++) {
// }
// }
// })
})
active
.
tabChange
(
'roleAuth'
,
responseList
[
0
].
accounttypeId
)
}
})
// $.each(menuFunTreeData[0].products, function(index, i) {
// active.tabAdd({
// title: i.productName,
// value: i.productId
// })
// })
}
})
}
...
...
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