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 0ad7d0c0
authored
Aug 18, 2021
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交员工
1 parent
1ffcdf4f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
282 additions
and
70 deletions
html/employee/add.html
html/employee/detail.html
html/employee/index.html
html/merchant/index.html
html/role/detail.html
html/role/index.html
js/load.js
js/treeTab.js
html/employee/add.html
View file @
0ad7d0c
This diff is collapsed.
Click to expand it.
html/employee/detail.html
View file @
0ad7d0c
...
@@ -11,14 +11,14 @@
...
@@ -11,14 +11,14 @@
<title>
员工管理
</title>
<title>
员工管理
</title>
</head>
</head>
<style>
<style>
.sub-bg-white
{
.sub-bg-white
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
background-color
:
#fff
;
background-color
:
#fff
;
}
}
.sub-title
{
.sub-title
{
margin-top
:
21px
;
margin-top
:
21px
;
}
}
</style>
</style>
<body>
<body>
<div
id=
"app"
>
<div
id=
"app"
>
...
@@ -27,9 +27,15 @@
...
@@ -27,9 +27,15 @@
<div>
<div>
<h3
class=
"content-title"
>
<h3
class=
"content-title"
>
员工基本信息
员工基本信息
<
div
class=
"title-right"
id=
"merchantName"
></div>
<
!-- <div class="title-right" id="merchantName"></div> -->
</h3>
</h3>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label required"
>
所属商户:
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-form-mid layui-word-aux"
id=
"merchantName"
></div>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label required"
>
姓名:
</label>
<label
class=
"layui-form-label required"
>
姓名:
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-input-block"
>
<div
class=
"layui-form-mid layui-word-aux"
id=
"staffName"
></div>
<div
class=
"layui-form-mid layui-word-aux"
id=
"staffName"
></div>
...
@@ -56,33 +62,48 @@
...
@@ -56,33 +62,48 @@
</div>
</div>
<div>
<div>
<h3
class=
"content-title sub-title"
>
可见下级商户
</h3>
<h3
class=
"content-title sub-title"
>
可见下级商户
</h3>
<ul
id=
"tree"
class=
"ztree wrapper-tree"
></ul>
<!-- <ul id="merchantTree" class="ztree wrapper-tree"></ul> -->
<div
class=
"layui-input-block"
>
<ul
id=
"visibleInferiorMerName"
></ul>
</div>
</div>
<div>
<h3
class=
"content-title sub-title"
>
角色权限
</h3>
<div
class=
"layui-tab tabmutiple-content"
style=
"padding: 0 20px;background-color: #fff;"
lay-filter=
"roleAuth"
>
<ul
class=
"layui-tab-title"
></ul>
<div
class=
"layui-tab-content"
></div>
</div>
</div>
</div>
<div
class=
"footer-close"
>
<div
class=
"footer-close"
>
<button
type=
"button"
class=
"layui-btn layui-btn-normal"
id=
"return"
>
关闭
</button>
<button
type=
"button"
class=
"layui-btn layui-btn-normal"
id=
"return"
>
关闭
</button>
</div>
</div>
</div>
</div>
</main>
</main>
</div>
</div>
<script
src=
"https://www.layuicdn.com/layui/layui.js"
></script>
<script
src=
"https://www.layuicdn.com/layui/layui.js"
></script>
<script
src=
"/js/load.js"
></script>
<script
src=
"/js/load.js"
></script>
<script>
<script>
layui
.
use
([
'request'
,
'gtree'
,
'element'
,
'helper'
],
function
()
{
layui
.
use
([
'request'
,
'gtree'
,
'helper'
,
'treeTab'
],
function
()
{
/** 变量 */
var
$
=
layui
.
$
var
$
=
layui
.
$
var
request
=
layui
.
request
var
request
=
layui
.
request
var
tree
=
layui
.
gtree
var
tree
=
layui
.
gtree
var
helper
=
layui
.
helper
var
helper
=
layui
.
helper
var
id
=
qs
(
'id'
)
var
id
=
qs
(
'id'
)
var
treeTab
=
layui
.
treeTab
var
merchantId
=
qs
(
'merchantId'
)
var
merchantId
=
qs
(
'merchantId'
)
var
basicArr
=
[
'staffName'
,
'staffPhone'
,
'roleName'
,
'roleIds'
,
'merchantName'
]
var
basicArr
=
[
'staffName'
,
'staffPhone'
,
'roleName'
,
'roleIds'
,
'merchantName'
]
var
employeeData
=
{}
var
employeeData
=
{}
var
visibleInferiorMerName
=
$
(
'#visibleInferiorMerName'
)
/** 调用方法 */
getById
()
getById
()
/** 触发事件 */
$
(
'#return'
).
on
(
'click'
,
function
()
{
$
(
'#return'
).
on
(
'click'
,
function
()
{
window
.
history
.
back
()
window
.
history
.
back
()
})
})
/** 定义方法 */
// 查询员工详情
// 查询员工详情
function
getById
()
{
function
getById
()
{
var
params
=
{
id
:
id
,
method
:
'cn.com.glsx.merchants.staff.staffSearchRequest'
}
var
params
=
{
id
:
id
,
method
:
'cn.com.glsx.merchants.staff.staffSearchRequest'
}
...
@@ -92,7 +113,39 @@
...
@@ -92,7 +113,39 @@
for
(
var
i
in
basicArr
)
{
for
(
var
i
in
basicArr
)
{
$
(
'#'
+
[
basicArr
[
i
]]).
text
(
employeeData
[
basicArr
[
i
]])
$
(
'#'
+
[
basicArr
[
i
]]).
text
(
employeeData
[
basicArr
[
i
]])
}
}
getMerchant
()
var
visibleName
=
employeeData
.
visibleInferiorMerName
.
split
(
','
)
console
.
log
(
visibleName
,
'---'
)
$
.
each
(
visibleName
,
function
(
idx
,
i
)
{
console
.
log
(
i
)
visibleInferiorMerName
.
append
(
'<li class="visibleMerchant">'
+
i
+
'</li>'
)
})
// getMerchant()
// 账户权限
var
authList
=
employeeData
.
accountTypeTreeResponseList
console
.
log
(
authList
)
if
(
authList
&&
authList
.
length
!=
0
)
{
$
.
each
(
authList
,
function
(
index
,
item
)
{
treeTab
.
tabAdd
({
title
:
item
.
accounttypeName
,
value
:
item
.
accounttypeId
},
true
)
var
menuData
=
[]
// for (var i = 0; i < item.products)
if
(
item
.
products
&&
item
.
products
.
length
!=
0
)
{
$
.
each
(
item
.
products
,
function
(
idx
,
m
)
{
treeTab
.
treeTabDetail
({
name
:
m
.
productName
,
value
:
m
.
productId
},
item
.
accounttypeId
,
m
.
merchantProTreeResponses
)
})
var
filterName
=
'treeTab'
+
item
.
accounttypeId
var
productId
=
'tab_'
+
item
.
accounttypeId
+
'_'
+
item
.
products
[
0
].
productId
treeTab
.
tabChange
(
filterName
,
productId
)
}
})
console
.
log
(
authList
)
treeTab
.
tabChange
(
'roleAuth'
,
authList
[
0
].
accounttypeId
)
}
}
}
})
})
}
}
...
@@ -107,12 +160,10 @@
...
@@ -107,12 +160,10 @@
$
.
each
(
arr
,
function
(
index
,
item
)
{
$
.
each
(
arr
,
function
(
index
,
item
)
{
arr
[
index
]
=
+
item
arr
[
index
]
=
+
item
})
})
merchants
=
tree
.
create
(
'
t
ree'
,
res
.
data
,
{
checkedList
:
arr
,
chkDisabled
:
true
})
merchants
=
tree
.
create
(
'
merchantT
ree'
,
res
.
data
,
{
checkedList
:
arr
,
chkDisabled
:
true
})
}
}
})
})
}
}
// 账户权限
})
})
</script>
</script>
</body>
</body>
...
...
html/employee/index.html
View file @
0ad7d0c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<body>
<body>
<div
id=
"app"
>
<div
id=
"app"
>
<main
class=
"bg-white"
>
<main>
<div>
<div>
<div
class=
"search-block"
>
<div
class=
"search-block"
>
<form
action=
""
class=
"layui-form layui-form-pane"
lay-filter=
"employeeForm"
>
<form
action=
""
class=
"layui-form layui-form-pane"
lay-filter=
"employeeForm"
>
...
@@ -55,17 +55,12 @@
...
@@ -55,17 +55,12 @@
<label
class=
"layui-form-label "
>
状态
</label>
<label
class=
"layui-form-label "
>
状态
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-input-block"
>
<select
name=
"status"
id=
"status"
lay-verify=
"required"
placeholder=
"请选择状态"
>
<select
name=
"status"
id=
"status"
lay-verify=
"required"
placeholder=
"请选择状态"
>
<!-- <option value="">全部</option>
<option value="0">存草稿</option>
<option value="1">启用</option>
<option value="2">已注销</option> -->
</select>
</select>
</div>
</div>
</div>
</div>
<div
class=
"layui-inline"
pane
>
<div
class=
"layui-inline"
pane
>
<div
class=
"layui-input-inline selector"
>
<div
class=
"layui-input-inline selector"
>
<select
name=
"type"
lay-verify=
"required"
placeholder=
"员工姓名/手机号"
>
<select
name=
"type"
lay-verify=
"required"
placeholder=
"员工姓名/手机号"
>
<option
value=
""
></option>
<option
value=
"0"
>
员工姓名
</option>
<option
value=
"0"
>
员工姓名
</option>
<option
value=
"1"
>
手机号
</option>
<option
value=
"1"
>
手机号
</option>
</select>
</select>
...
@@ -101,8 +96,7 @@
...
@@ -101,8 +96,7 @@
// 商户名称列表
// 商户名称列表
var
merchantName
=
$
(
"#merchantName"
)
var
merchantName
=
$
(
"#merchantName"
)
var
status
=
$
(
'#status'
)
var
status
=
$
(
'#status'
)
findAllMerchant
()
findAllDictData
()
//创建table实例
//创建table实例
var
employeeTable
=
table
.
render
({
var
employeeTable
=
table
.
render
({
elem
:
'#employeeTable'
,
elem
:
'#employeeTable'
,
...
@@ -115,7 +109,6 @@
...
@@ -115,7 +109,6 @@
{
field
:
'staffCode'
,
title
:
'员工号'
,
align
:
'center'
},
{
field
:
'staffCode'
,
title
:
'员工号'
,
align
:
'center'
},
{
field
:
'roleName'
,
title
:
'角色'
,
align
:
'center'
},
{
field
:
'roleName'
,
title
:
'角色'
,
align
:
'center'
},
{
field
:
'staffPhone'
,
title
:
'登录手机号'
,
align
:
'center'
,
width
:
125
},
{
field
:
'staffPhone'
,
title
:
'登录手机号'
,
align
:
'center'
,
width
:
125
},
{
field
:
'password'
,
title
:
'登录密码'
,
align
:
'center'
},
{
field
:
'statusName'
,
title
:
'状态'
,
align
:
'center'
},
{
field
:
'statusName'
,
title
:
'状态'
,
align
:
'center'
},
{
field
:
'createdAccount'
,
title
:
'创建者'
,
align
:
'center'
},
{
field
:
'createdAccount'
,
title
:
'创建者'
,
align
:
'center'
},
{
field
:
'merchantName'
,
title
:
'商户名(商户号)'
,
align
:
'center'
,
width
:
160
},
{
field
:
'merchantName'
,
title
:
'商户名(商户号)'
,
align
:
'center'
,
width
:
160
},
...
@@ -124,11 +117,13 @@
...
@@ -124,11 +117,13 @@
]
]
]
]
})
})
// 分页配置
// 分页配置
var
page
=
{
var
page
=
{
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
pageSize
:
10
}
}
var
pageOptions
=
{
var
pageOptions
=
{
elem
:
'employeePage'
,
elem
:
'employeePage'
,
groups
:
5
,
groups
:
5
,
...
@@ -141,40 +136,15 @@
...
@@ -141,40 +136,15 @@
page
.
pageSize
=
obj
.
limit
page
.
pageSize
=
obj
.
limit
//首次不执行
//首次不执行
if
(
!
first
)
{
if
(
!
first
)
{
getTabelList
(
employeeTable
)
getTabelList
(
employeeTable
,
getSearch
())
}
}
}
getTabelList
(
employeeTable
)
// 获取table列表接口
function
getTabelList
(
table
,
search
,
isResetPageNum
)
{
search
=
search
||
{}
var
params
=
helper
.
clone
(
false
,
{
pageNum
:
page
.
pageNum
,
pageSize
:
page
.
pageSize
,
method
:
'cn.com.glsx.merchants.staff.findStaffByPage'
},
search
)
request
(
params
,
function
(
res
)
{
console
.
log
(
res
)
// table.reload('testReload', {
// data: res.data.data
// })
// var data = res.data
var
data
=
helper
.
formateNullFieldData
(
res
.
data
)
var
options
=
{
data
:
data
.
data
}
}
pageOptions
.
count
=
data
.
count
if
(
isResetPageNum
)
{
pageOptions
.
curr
=
1
}
}
laypage
.
render
(
pageOptions
)
employeeTable
.
reload
(
options
)
}
)
}
}
// table工具条事件
// 初始化
init
()
/** table工具条事件 */
table
.
on
(
'tool(employeeTool)'
,
function
(
obj
)
{
table
.
on
(
'tool(employeeTool)'
,
function
(
obj
)
{
var
data
=
obj
.
data
var
data
=
obj
.
data
var
layEvent
=
obj
.
event
var
layEvent
=
obj
.
event
...
@@ -182,7 +152,7 @@
...
@@ -182,7 +152,7 @@
if
(
layEvent
===
'detail'
)
{
if
(
layEvent
===
'detail'
)
{
go
(
'employee'
,
'detail'
,
{
id
:
data
.
id
,
merchantId
:
data
.
merchantId
})
go
(
'employee'
,
'detail'
,
{
id
:
data
.
id
,
merchantId
:
data
.
merchantId
})
}
else
if
(
layEvent
===
'edit'
)
{
}
else
if
(
layEvent
===
'edit'
)
{
go
(
'employee'
,
'add'
,
{
id
:
data
.
id
,
merchantId
:
data
.
merchantId
})
go
(
'employee'
,
'add'
,
{
id
:
data
.
id
,
merchantId
:
data
.
merchantId
,
merchantName
:
data
.
merchantName
})
}
else
if
(
layEvent
===
'del'
)
{
}
else
if
(
layEvent
===
'del'
)
{
layer
.
confirm
(
'是否确认删除该员工?'
,
function
(
index
)
{
layer
.
confirm
(
'是否确认删除该员工?'
,
function
(
index
)
{
// obj.del() //删除对应行(tr)的DOM结构,并更新缓存
// obj.del() //删除对应行(tr)的DOM结构,并更新缓存
...
@@ -226,21 +196,24 @@
...
@@ -226,21 +196,24 @@
})
})
}
}
})
})
/** 手动触发事件 */
// 查询事件
// 查询事件
$
(
'#employeeSearch'
).
on
(
'click'
,
function
()
{
$
(
'#employeeSearch'
).
on
(
'click'
,
function
()
{
var
searchData
=
getSearch
()
var
searchData
=
getSearch
()
getTabelList
(
employeeTable
,
searchData
,
true
)
getTabelList
(
employeeTable
,
searchData
,
true
)
})
})
// 新增点击事件
// 新增点击事件
$
(
'#addEmployee'
).
on
(
'click'
,
function
()
{
$
(
'#addEmployee'
).
on
(
'click'
,
function
()
{
//
go('employee', 'add')
go
(
'employee'
,
'add'
)
var
value
=
merchantName
.
val
()
//
var value = merchantName.val()
if
(
value
)
{
//
if (value) {
go
(
'employee'
,
'add'
,
{
merchantId
:
value
})
//
go('employee', 'add', { merchantId: value })
}
else
{
//
} else {
layer
.
msg
(
'请选择商户'
)
//
layer.msg('请选择商户')
}
//
}
})
})
// 导出
// 导出
$
(
'#employeeExport'
).
on
(
'click'
,
function
()
{
$
(
'#employeeExport'
).
on
(
'click'
,
function
()
{
var
searchData
=
getSearch
()
var
searchData
=
getSearch
()
...
@@ -251,12 +224,44 @@
...
@@ -251,12 +224,44 @@
}
}
})
})
})
})
/** 定义方法 */
// 初始化方法
function
init
()
{
findAllMerchant
()
findAllDictData
()
getTabelList
(
employeeTable
)
}
// 获取table列表接口
function
getTabelList
(
table
,
search
,
isResetPageNum
)
{
search
=
search
||
{}
var
params
=
helper
.
clone
(
false
,
{
pageNum
:
page
.
pageNum
,
pageSize
:
page
.
pageSize
,
method
:
'cn.com.glsx.merchants.staff.findStaffByPage'
},
search
)
request
(
params
,
function
(
res
)
{
var
data
=
helper
.
formateNullFieldData
(
res
.
data
)
var
options
=
{
data
:
data
.
data
}
pageOptions
.
count
=
data
.
count
if
(
isResetPageNum
)
{
pageOptions
.
curr
=
1
}
laypage
.
render
(
pageOptions
)
employeeTable
.
reload
(
options
)
}
)
}
// 查询所有商户
// 查询所有商户
function
findAllMerchant
()
{
function
findAllMerchant
()
{
var
params
=
{
method
:
'cn.com.glsx.merchants.menu.findAllMerchant'
}
var
params
=
{
method
:
'cn.com.glsx.merchants.menu.findAllMerchant'
}
request
(
params
,
function
(
result
)
{
request
(
params
,
function
(
result
)
{
if
(
result
.
code
==
'0'
)
{
if
(
result
.
code
==
'0'
)
{
console
.
log
(
result
)
var
list
=
result
.
data
var
list
=
result
.
data
list
.
unshift
(
''
)
list
.
unshift
(
''
)
$
.
each
(
list
,
function
(
index
,
item
)
{
$
.
each
(
list
,
function
(
index
,
item
)
{
...
@@ -267,10 +272,10 @@
...
@@ -267,10 +272,10 @@
})
})
}
}
// 搜索
function
getSearch
()
{
function
getSearch
()
{
var
formVal
=
form
.
val
(
'employeeForm'
)
var
formVal
=
form
.
val
(
'employeeForm'
)
var
searchData
=
helper
.
clone
(
false
,
formVal
)
var
searchData
=
helper
.
clone
(
false
,
formVal
)
console
.
log
(
formVal
)
if
(
searchData
.
type
==
0
)
{
if
(
searchData
.
type
==
0
)
{
searchData
.
staffName
=
formVal
.
keywords
searchData
.
staffName
=
formVal
.
keywords
searchData
.
staffPhone
=
''
searchData
.
staffPhone
=
''
...
@@ -285,6 +290,7 @@
...
@@ -285,6 +290,7 @@
delete
searchData
.
keywords
delete
searchData
.
keywords
return
searchData
return
searchData
}
}
function
findAllDictData
()
{
function
findAllDictData
()
{
var
params
=
{
var
params
=
{
method
:
'cn.com.glsx.merchants.menu.findAllDictData'
,
method
:
'cn.com.glsx.merchants.menu.findAllDictData'
,
...
...
html/merchant/index.html
View file @
0ad7d0c
...
@@ -311,7 +311,8 @@
...
@@ -311,7 +311,8 @@
case
'handleAddStaff'
:
case
'handleAddStaff'
:
go
(
'employee'
,
'add'
,
{
go
(
'employee'
,
'add'
,
{
merchantId
:
row
.
id
,
merchantId
:
row
.
id
,
merchantName
:
row
.
merchantName
merchantName
:
row
.
merchantName
,
channel
:
'merchant'
})
})
break
break
// 修改账户有效期
// 修改账户有效期
...
...
html/role/detail.html
View file @
0ad7d0c
...
@@ -211,11 +211,12 @@
...
@@ -211,11 +211,12 @@
value
:
menuData
.
productId
value
:
menuData
.
productId
},
item
.
accounttypeId
,
item
.
products
,
menuData
.
idList
)
},
item
.
accounttypeId
,
item
.
products
,
menuData
.
idList
)
}
}
}
var
filterName
=
'treeTab'
+
item
.
accounttypeId
var
filterName
=
'treeTab'
+
item
.
accounttypeId
var
productId
=
'tab_'
+
item
.
accounttypeId
+
'_'
+
item
.
products
[
0
].
productId
var
productId
=
'tab_'
+
item
.
accounttypeId
+
'_'
+
item
.
products
[
0
].
productId
active
.
tabChange
(
filterName
,
productId
)
active
.
tabChange
(
filterName
,
productId
)
}
}
}
// break
// break
}
}
})
})
...
...
html/role/index.html
View file @
0ad7d0c
...
@@ -65,7 +65,6 @@
...
@@ -65,7 +65,6 @@
var
$
=
layui
.
$
var
$
=
layui
.
$
// 商户名称列表
// 商户名称列表
var
merchantName
=
$
(
"#merchantName"
)
var
merchantName
=
$
(
"#merchantName"
)
findAllMerchant
()
//创建table实例
//创建table实例
var
roleTable
=
table
.
render
({
var
roleTable
=
table
.
render
({
elem
:
'#roleTable'
,
elem
:
'#roleTable'
,
...
@@ -99,16 +98,18 @@
...
@@ -99,16 +98,18 @@
console
.
log
(
obj
.
limit
);
//得到每页显示的条数
console
.
log
(
obj
.
limit
);
//得到每页显示的条数
page
.
pageNum
=
obj
.
curr
page
.
pageNum
=
obj
.
curr
page
.
pageSize
=
obj
.
limit
page
.
pageSize
=
obj
.
limit
// getTabelList()
//首次不执行
//首次不执行
if
(
!
first
)
{
if
(
!
first
)
{
//do something
//do something
getTabelList
()
getTabelList
(
roleTable
,
form
.
val
(
'roleForm'
)
)
}
}
}
}
}
}
init
()
function
init
()
{
findAllMerchant
()
getTabelList
(
roleTable
)
getTabelList
(
roleTable
)
}
// 获取table列表接口
// 获取table列表接口
function
getTabelList
(
table
,
search
,
isResetPageNum
)
{
function
getTabelList
(
table
,
search
,
isResetPageNum
)
{
var
params
=
helper
.
clone
(
false
,
{
var
params
=
helper
.
clone
(
false
,
{
...
@@ -186,7 +187,7 @@
...
@@ -186,7 +187,7 @@
}
}
})
})
// 查询事件
// 查询事件
$
(
document
).
on
(
'click'
,
'#roleSearch
'
,
function
()
{
$
(
'#roleSearch'
).
on
(
'click
'
,
function
()
{
var
searchData
=
form
.
val
(
'roleForm'
)
var
searchData
=
form
.
val
(
'roleForm'
)
console
.
log
(
searchData
)
console
.
log
(
searchData
)
getTabelList
(
roleTable
,
searchData
,
true
)
getTabelList
(
roleTable
,
searchData
,
true
)
...
...
js/load.js
View file @
0ad7d0c
...
@@ -107,6 +107,9 @@ function genurl(param, key, encode) {
...
@@ -107,6 +107,9 @@ function genurl(param, key, encode) {
function
qs
(
name
)
{
function
qs
(
name
)
{
var
reg
=
new
RegExp
(
'(^|&)'
+
name
+
'=([^&]*)(&|$)'
,
'i'
)
var
reg
=
new
RegExp
(
'(^|&)'
+
name
+
'=([^&]*)(&|$)'
,
'i'
)
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
)
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
)
if
(
r
!=
null
)
return
unescape
(
r
[
2
])
if
(
r
!=
null
)
{
return
decodeURI
(
r
[
2
])
// return unescape(r[2])
}
return
null
return
null
}
}
js/treeTab.js
0 → 100644
View file @
0ad7d0c
layui
.
define
([
'element'
,
'laytpl'
,
'gtree'
,
'xmSelect'
],
function
(
exports
)
{
var
element
=
layui
.
element
var
laytpl
=
layui
.
laytpl
var
tree
=
layui
.
gtree
var
xmSelect
=
layui
.
xmSelect
var
menuFunTreeData
=
[]
var
templateData
=
{}
var
treeData
=
{}
var
selectEl
=
{}
// 树相关的方法
var
treeTab
=
{
/**
* 第一级tab添加
* item: {title: 选项卡名称, value: 选项卡值}
* isDetail:判断是否是详情,不是则显示多选框
* roleAuth: 选项卡过滤器的名称 lay-filter绑定的名字
* content: 一个放置模板的视图容器,用于呈现渲染结果 带有id的div
* id:选项卡标题的lay-id属性值
* 需要引入laytpl gtree element模块,若需要多选框则需引入xmSelect模块
* view 放置模板的视图容器的dom
* templateData:用于渲染模板的数据
* productList:复选下拉框的list,修改过的数据{name: '', value: ''}
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/
tabAdd
:
function
(
item
,
isDetail
)
{
var
isDetail
=
isDetail
||
false
// 渠道的id,一层选项卡的id
var
id
=
item
.
value
// roleAuth 一层选项卡过滤器的名称
element
.
tabAdd
(
'roleAuth'
,
{
title
:
item
.
title
,
// 放置模板视图的上一级div
content
:
'<div id="role'
+
id
+
'"></div>'
,
// 选项卡标题的lay-id属性值
id
:
id
})
var
getTpl
=
'<div class="layui-tab layui-tab-card" lay-filter="treeTab{{d.id}}"><ul class="layui-tab-title"></ul> <div class="layui-tab-content"></div></div>'
view
=
document
.
getElementById
(
'role'
+
id
)
templateData
.
id
=
id
// 渲染模版的数据
laytpl
(
getTpl
).
render
(
templateData
,
function
(
html
)
{
view
.
innerHTML
=
html
})
if
(
!
isDetail
)
{
var
productList
=
[]
var
products
=
[]
$
.
each
(
menuFunTreeData
,
function
(
index
,
item
)
{
if
(
item
.
accounttypeId
==
id
)
{
products
=
item
.
products
$
.
each
(
item
.
products
,
function
(
idx
,
i
)
{
productList
.
push
({
name
:
i
.
productName
,
value
:
i
.
productId
})
})
}
})
selectEl
[
id
]
=
xmSelect
.
render
({
el
:
'#select'
+
id
,
data
:
productList
,
on
:
function
(
data
)
{
// arr: 当前多选已选中的数据
var
arr
=
data
.
arr
// change, 此次选择变化的数据,数组
var
change
=
data
.
change
// isAdd, 此次操作是新增还是删除
var
isAdd
=
data
.
isAdd
var
filterName
=
'treeTab'
+
id
if
(
isAdd
)
{
active
.
treeTabAdd
(
change
[
0
],
id
,
products
)
}
else
{
var
productId
=
'tab_'
+
id
+
'_'
+
change
[
0
].
value
active
.
tabDelete
(
filterName
,
productId
)
}
if
(
arr
.
length
!=
0
)
{
var
productId
=
'tab_'
+
id
+
'_'
+
arr
[
0
].
value
active
.
tabChange
(
filterName
,
productId
)
}
}
})
}
},
// 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
=
'<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
})
},
treeTabDetail
:
function
(
item
,
id
,
productTreeList
)
{
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
=
'<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
treedom
=
'tree_'
+
productId
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
productTreeList
,
null
,
false
)
}
}
exports
(
'treeTab'
,
treeTab
)
})
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