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 ee24a855
authored
Aug 21, 2021
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of 192.168.3.233:h5/account
2 parents
9c3236e5
4c09faa2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
229 additions
and
129 deletions
html/employee/add.html
html/merchant/detail.html
html/merchant/edit.html
html/merchant/index.html
html/role/add.html
js/gtree.js
js/helper.js
html/employee/add.html
View file @
ee24a85
...
@@ -344,7 +344,7 @@
...
@@ -344,7 +344,7 @@
visibleMerchant
=
tree
.
create
(
'visibleInferiorMerTree'
,
res
.
data
,
{
checkedList
:
checkedList
})
visibleMerchant
=
tree
.
create
(
'visibleInferiorMerTree'
,
res
.
data
,
{
checkedList
:
checkedList
})
// var node = visibleMerchant.getNodesByParam('id', merchantId)
// var node = visibleMerchant.getNodesByParam('id', merchantId)
// visibleMerchant.checkNode(node, true, true)
// visibleMerchant.checkNode(node, true, true)
all_nodes
=
visibleMerchant
.
getNodes
(
)
all_nodes
=
visibleMerchant
.
transformToArray
(
visibleMerchant
.
getNodes
()
)
bindEvent
()
bindEvent
()
})
})
...
@@ -358,7 +358,7 @@
...
@@ -358,7 +358,7 @@
// node.checked = true
// node.checked = true
// visibleMerchant.checkNode(node, true, true)
// visibleMerchant.checkNode(node, true, true)
// visibleMerchant.updateNode(node)
// visibleMerchant.updateNode(node)
all_nodes
=
visibleMerchant
.
getNodes
(
)
all_nodes
=
visibleMerchant
.
transformToArray
(
visibleMerchant
.
getNodes
()
)
bindEvent
()
bindEvent
()
}
}
}
}
...
@@ -436,6 +436,43 @@
...
@@ -436,6 +436,43 @@
})
})
}
}
// 树 - 模糊搜索 - 找父节点
function
findParentNode
(
node
,
idAttr
,
parentAttr
)
{
for
(
var
i
=
0
;
i
<=
all_nodes
.
length
;
i
++
)
{
if
(
all_nodes
[
i
][
idAttr
]
==
node
[
parentAttr
])
{
return
all_nodes
[
i
]
}
}
return
false
}
// 树 - 模糊搜索 - 找所有节点
/**
* nodesList - 当前筛选出的节点列表
* idAttr - 节点的id属性名,默认“tId”
* parentAttr - 节点的父节点属性名,默认“parentTId”
*/
function
findShowNode
(
nodesList
,
idAttr
,
parentAttr
)
{
idAttr
=
idAttr
||
'tId'
parentAttr
=
parentAttr
||
'parentTId'
var
showNodeList
=
[]
var
idx
=
0
var
addNode
=
null
var
exitNode
=
{}
while
(
nodesList
.
length
!=
idx
)
{
var
curNode
=
nodesList
[
idx
]
idx
=
idx
+
1
exitNode
[
curNode
[
idAttr
]]
=
true
showNodeList
.
push
(
curNode
)
if
(
curNode
[
parentAttr
]
&&
!
exitNode
[
curNode
[
parentAttr
]])
{
var
parentNode
=
findParentNode
(
curNode
,
idAttr
,
parentAttr
)
exitNode
[
parentNode
[
idAttr
]]
=
true
nodesList
.
push
(
parentNode
)
}
}
return
showNodeList
}
function
bindEvent
()
{
function
bindEvent
()
{
$
(
'#searchMerchant'
).
on
(
$
(
'#searchMerchant'
).
on
(
'input'
,
'input'
,
...
@@ -444,7 +481,8 @@
...
@@ -444,7 +481,8 @@
if
(
!
txt
)
{
if
(
!
txt
)
{
visibleMerchant
.
showNodes
(
all_nodes
)
visibleMerchant
.
showNodes
(
all_nodes
)
}
else
{
}
else
{
var
show_nodes
=
visibleMerchant
.
getNodesByParamFuzzy
(
'label'
,
txt
)
var
nodesList
=
visibleMerchant
.
getNodesByParamFuzzy
(
'label'
,
txt
)
show_nodes
=
findShowNode
(
nodesList
)
visibleMerchant
.
hideNodes
(
all_nodes
)
visibleMerchant
.
hideNodes
(
all_nodes
)
visibleMerchant
.
showNodes
(
show_nodes
)
visibleMerchant
.
showNodes
(
show_nodes
)
}
}
...
...
html/merchant/detail.html
View file @
ee24a85
...
@@ -187,7 +187,7 @@
...
@@ -187,7 +187,7 @@
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
地址:
</label>
<label
class=
"layui-form-label"
>
地址:
</label>
<div
class=
"layui-input-block"
>
<div
class=
"layui-input-block"
>
<div
class=
"layui-form-mid layui-word-aux"
id=
"merchantAddress"
></div>
<div
class=
"layui-form-mid layui-word-aux"
id=
"merchant
Full
Address"
></div>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
...
@@ -296,7 +296,7 @@
...
@@ -296,7 +296,7 @@
'merchantAbbreviation'
,
'merchantAbbreviation'
,
'merchantTypeName'
,
'merchantTypeName'
,
'merchantOrgcode'
,
'merchantOrgcode'
,
'merchantAddress'
,
'merchant
Full
Address'
,
'merchantLegalPerson'
,
'merchantLegalPerson'
,
'merchantLegalPersonPhone'
,
'merchantLegalPersonPhone'
,
'businessScopName'
,
'businessScopName'
,
...
@@ -448,7 +448,7 @@
...
@@ -448,7 +448,7 @@
}
}
var
all_nodes
=
null
var
all_nodes
=
null
var
merchants
=
null
var
treeObj
=
null
// 上下级商户 - 树
// 上下级商户 - 树
function
getSecondTree
()
{
function
getSecondTree
()
{
var
treeParams
=
{
var
treeParams
=
{
...
@@ -458,28 +458,66 @@
...
@@ -458,28 +458,66 @@
request
(
treeParams
,
function
(
res
)
{
request
(
treeParams
,
function
(
res
)
{
console
.
log
(
res
)
console
.
log
(
res
)
if
(
res
.
code
==
'0'
)
{
if
(
res
.
code
==
'0'
)
{
merchants
=
tree
.
create
(
'merchantTree'
,
res
.
data
,
null
,
false
)
treeObj
=
tree
.
create
(
'merchantTree'
,
res
.
data
,
null
,
false
)
merchants
.
expandAll
(
true
)
treeObj
.
expandAll
(
true
)
all_nodes
=
merchants
.
getNodes
(
)
all_nodes
=
treeObj
.
transformToArray
(
treeObj
.
getNodes
()
)
var
targetNode
=
merchants
.
getNodeByParam
(
'id'
,
merchantId
)
var
targetNode
=
treeObj
.
getNodeByParam
(
'id'
,
merchantId
)
merchants
.
selectNode
(
targetNode
)
treeObj
.
selectNode
(
targetNode
)
bindEvent
()
bindEvent
()
}
}
})
})
}
}
// 树 - 模糊搜索 - 找父节点
function
findParentNode
(
node
,
idAttr
,
parentAttr
)
{
for
(
var
i
=
0
;
i
<=
all_nodes
.
length
;
i
++
)
{
if
(
all_nodes
[
i
][
idAttr
]
==
node
[
parentAttr
])
{
return
all_nodes
[
i
]
}
}
return
false
}
// 树 - 模糊搜索 - 找所有节点
/**
* nodesList - 当前筛选出的节点列表
* idAttr - 节点的id属性名,默认“tId”
* parentAttr - 节点的父节点属性名,默认“parentTId”
*/
function
findShowNode
(
nodesList
,
idAttr
,
parentAttr
)
{
idAttr
=
idAttr
||
'tId'
parentAttr
=
parentAttr
||
'parentTId'
var
showNodeList
=
[]
var
idx
=
0
var
addNode
=
null
var
exitNode
=
{}
while
(
nodesList
.
length
!=
idx
)
{
var
curNode
=
nodesList
[
idx
]
idx
=
idx
+
1
exitNode
[
curNode
[
idAttr
]]
=
true
showNodeList
.
push
(
curNode
)
if
(
curNode
[
parentAttr
]
&&
!
exitNode
[
curNode
[
parentAttr
]])
{
var
parentNode
=
findParentNode
(
curNode
,
idAttr
,
parentAttr
)
exitNode
[
parentNode
[
idAttr
]]
=
true
nodesList
.
push
(
parentNode
)
}
}
return
showNodeList
}
function
bindEvent
()
{
function
bindEvent
()
{
$
(
'#merchantBtn'
).
on
(
'click'
,
function
()
{
$
(
'#merchantBtn'
).
on
(
'click'
,
function
()
{
var
txt
=
$
(
'#treeInput'
).
val
()
var
txt
=
$
(
'#treeInput'
).
val
()
if
(
!
txt
)
{
if
(
!
txt
)
{
merchants
.
showNodes
(
all_nodes
)
treeObj
.
showNodes
(
all_nodes
)
var
targetNode
=
merchants
.
getNodeByParam
(
'id'
,
merchantId
)
var
targetNode
=
treeObj
.
getNodeByParam
(
'id'
,
merchantId
)
merchants
.
selectNode
(
all_nodes
[
0
])
treeObj
.
selectNode
(
all_nodes
[
0
])
}
else
{
}
else
{
var
show_nodes
=
merchants
.
getNodesByParamFuzzy
(
'label'
,
txt
)
var
nodesList
=
treeObj
.
getNodesByParamFuzzy
(
'label'
,
txt
)
merchants
.
hideNodes
(
all_nodes
)
show_nodes
=
findShowNode
(
nodesList
)
merchants
.
showNodes
(
show_nodes
)
treeObj
.
hideNodes
(
all_nodes
)
merchants
.
selectNode
(
show_nodes
[
0
])
treeObj
.
showNodes
(
show_nodes
)
treeObj
.
selectNode
(
nodesList
[
0
])
}
}
})
})
return
false
return
false
...
...
html/merchant/edit.html
View file @
ee24a85
...
@@ -322,7 +322,7 @@
...
@@ -322,7 +322,7 @@
</select>
</select>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
id=
"effectiveShowEl"
>
<label
class=
"layui-form-label required"
>
账户有效期:
</label>
<label
class=
"layui-form-label required"
>
账户有效期:
</label>
<div
class=
"layui-input-inline"
>
<div
class=
"layui-input-inline"
>
<select
id=
"validPeriodEl"
name=
"effectiveTime"
required
lay-vertify=
"required"
lay-search
>
<select
id=
"validPeriodEl"
name=
"effectiveTime"
required
lay-vertify=
"required"
lay-search
>
...
@@ -463,13 +463,6 @@
...
@@ -463,13 +463,6 @@
})
})
init
()
init
()
// helper.store.set('merchantMapObj', {
// lat: '116.397428',
// lng: '39.90923',
// merchantAddress: '深圳'
// })
// helper.store.set('merchantMapObj', merchantForm)
// console.log(validator.PHONEREG)
// console.log(validator.PHONEREG)
// 校验
// 校验
form
.
verify
({
form
.
verify
({
...
@@ -596,23 +589,16 @@
...
@@ -596,23 +589,16 @@
}
}
params
.
method
=
'cn.com.glsx.merchants.merchant.saveMerchant'
params
.
method
=
'cn.com.glsx.merchants.merchant.saveMerchant'
}
}
// else if (editLevel == 3) {
// params.id = merchantId
// if (!isFactory) {
// params.parentId = parentInfo.parentId
// }
// params.method = 'cn.com.glsx.merchants.merchant.updateMerchant'
// }
// 保存状态 1.草稿 2.发布 3.注销 4.过期
// 保存状态 1.草稿 2.发布 3.注销 4.过期
if
(
merchantForm
.
status
)
{
if
(
merchantForm
.
status
)
{
params
.
status
=
merchantForm
.
status
params
.
status
=
merchantForm
.
status
}
else
{
}
else
{
params
.
status
=
1
params
.
status
=
1
}
}
console
.
log
(
editLevel
)
//
console.log(editLevel)
console
.
log
(
params
)
//
console.log(params)
request
(
params
,
function
(
res
)
{
request
(
params
,
function
(
res
)
{
console
.
log
(
res
)
//
console.log(res)
// authorityTree
// authorityTree
if
(
res
.
code
==
'0'
)
{
if
(
res
.
code
==
'0'
)
{
if
(
editLevel
==
3
)
{
if
(
editLevel
==
3
)
{
...
@@ -628,6 +614,7 @@
...
@@ -628,6 +614,7 @@
getMerchantApi
(
merchantId
,
function
(
respone
)
{
getMerchantApi
(
merchantId
,
function
(
respone
)
{
form
.
val
(
'merchantForm'
,
respone
.
data
)
form
.
val
(
'merchantForm'
,
respone
.
data
)
merchantForm
=
respone
.
data
merchantForm
=
respone
.
data
$
(
'#addrEl'
).
text
(
merchantForm
.
merchantAddress
)
accountTypeVisible
=
true
accountTypeVisible
=
true
var
el
=
$
(
'#accountTypeEl'
)
var
el
=
$
(
'#accountTypeEl'
)
el
.
empty
()
el
.
empty
()
...
@@ -800,11 +787,18 @@
...
@@ -800,11 +787,18 @@
// }); //又换了种风格,并且设定最长等待10秒
// }); //又换了种风格,并且设定最长等待10秒
//关闭
//关闭
// layer.close(index);
// layer.close(index);
getPeriod
()
if
(
step
==
1
)
{
if
(
step
==
1
)
{
getPeriod
()
baseIsShow
(
true
)
baseIsShow
(
true
)
treeIsShow
(
false
)
treeIsShow
(
false
)
if
(
merchantId
)
{
resetpsw
.
removeClass
(
'hide'
)
resetpsw
.
addClass
(
'show'
)
}
if
(
isFactory
)
{
$
(
'#subMerchantEl'
).
hide
()
}
}
else
{
}
else
{
baseIsShow
(
false
)
baseIsShow
(
false
)
treeIsShow
(
true
)
treeIsShow
(
true
)
...
@@ -836,12 +830,14 @@
...
@@ -836,12 +830,14 @@
if
(
editLevel
==
3
)
{
if
(
editLevel
==
3
)
{
$
(
'#firstBtn'
).
text
(
'确定'
)
$
(
'#firstBtn'
).
text
(
'确定'
)
$
(
'#preStep'
).
remove
()
$
(
'#preStep'
).
remove
()
$
(
'#validPeriodEl'
).
attr
(
'disabled'
,
true
)
if
(
step
==
1
)
{
$
(
'#merchantLoginAccountEl'
).
attr
(
'disabled'
,
true
)
$
(
'#validPeriodEl'
).
attr
(
'disabled'
,
true
)
accountTypeVisible
=
true
$
(
'#merchantLoginAccountEl'
).
attr
(
'disabled'
,
true
)
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
accountTypeVisible
=
true
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
}
}
else
{
}
else
{
if
(
!
merchantId
)
{
if
(
!
merchantId
&&
step
==
1
)
{
getBusiScope
()
getBusiScope
()
getCarBrandTree
()
getCarBrandTree
()
}
}
...
@@ -855,6 +851,7 @@
...
@@ -855,6 +851,7 @@
parentMerchantId
=
qs
(
'parentId'
)
parentMerchantId
=
qs
(
'parentId'
)
}
}
$
(
'#validPeriodEl'
).
attr
(
'disabled'
,
true
)
$
(
'#validPeriodEl'
).
attr
(
'disabled'
,
true
)
$
(
'#effectiveShowEl'
).
addClass
(
'hide'
)
// $('#channelEl').attr('disabled', true)
// $('#channelEl').attr('disabled', true)
if
(
editLevel
==
3
||
(
editLevel
==
2
&&
!
merchantId
))
{
if
(
editLevel
==
3
||
(
editLevel
==
2
&&
!
merchantId
))
{
getParentInfo
()
getParentInfo
()
...
@@ -864,13 +861,43 @@
...
@@ -864,13 +861,43 @@
}
}
}
}
}
}
if
(
merchantId
)
{
}
resetpsw
.
removeClass
(
'hide'
)
resetpsw
.
addClass
(
'show'
)
// 树 - 模糊搜索 - 找父节点
function
findParentNode
(
node
,
idAttr
,
parentAttr
)
{
for
(
var
i
=
0
;
i
<=
all_nodes
.
length
;
i
++
)
{
if
(
all_nodes
[
i
][
idAttr
]
==
node
[
parentAttr
])
{
return
all_nodes
[
i
]
}
}
}
if
(
isFactory
)
{
return
false
$
(
'#subMerchantEl'
).
hide
()
}
// 树 - 模糊搜索 - 找所有节点
/**
* nodesList - 当前筛选出的节点列表
* idAttr - 节点的id属性名,默认“tId”
* parentAttr - 节点的父节点属性名,默认“parentTId”
*/
function
findShowNode
(
nodesList
,
idAttr
,
parentAttr
)
{
idAttr
=
idAttr
||
'tId'
parentAttr
=
parentAttr
||
'parentTId'
var
showNodeList
=
[]
var
idx
=
0
var
addNode
=
null
var
exitNode
=
{}
while
(
nodesList
.
length
!=
idx
)
{
var
curNode
=
nodesList
[
idx
]
idx
=
idx
+
1
exitNode
[
curNode
[
idAttr
]]
=
true
showNodeList
.
push
(
curNode
)
if
(
curNode
[
parentAttr
]
&&
!
exitNode
[
curNode
[
parentAttr
]])
{
var
parentNode
=
findParentNode
(
curNode
,
idAttr
,
parentAttr
)
exitNode
[
parentNode
[
idAttr
]]
=
true
nodesList
.
push
(
parentNode
)
}
}
}
return
showNodeList
}
}
function
bindEvent
()
{
function
bindEvent
()
{
...
@@ -879,7 +906,8 @@
...
@@ -879,7 +906,8 @@
if
(
!
txt
)
{
if
(
!
txt
)
{
treeObj
.
showNodes
(
all_nodes
)
treeObj
.
showNodes
(
all_nodes
)
}
else
{
}
else
{
var
show_nodes
=
treeObj
.
getNodesByParamFuzzy
(
'label'
,
txt
)
var
nodesList
=
treeObj
.
getNodesByParamFuzzy
(
'label'
,
txt
)
show_nodes
=
findShowNode
(
nodesList
)
treeObj
.
hideNodes
(
all_nodes
)
treeObj
.
hideNodes
(
all_nodes
)
treeObj
.
showNodes
(
show_nodes
)
treeObj
.
showNodes
(
show_nodes
)
}
}
...
@@ -935,9 +963,13 @@
...
@@ -935,9 +963,13 @@
getMerchantInfo
()
getMerchantInfo
()
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
}
else
{
}
else
{
getAccountType
()
if
(
step
==
1
)
{
getAccountType
()
}
}
if
(
step
==
1
)
{
getAccountLevel
()
}
}
getAccountLevel
()
})
})
}
}
...
@@ -946,6 +978,7 @@
...
@@ -946,6 +978,7 @@
getMerchantApi
(
merchantId
,
function
(
res
)
{
getMerchantApi
(
merchantId
,
function
(
res
)
{
form
.
val
(
'merchantForm'
,
res
.
data
)
form
.
val
(
'merchantForm'
,
res
.
data
)
merchantForm
=
res
.
data
merchantForm
=
res
.
data
if
(
merchantForm
.
merchantAddress
)
{
if
(
merchantForm
.
merchantAddress
)
{
$
(
'#addrEl'
).
text
(
merchantForm
.
merchantAddress
)
$
(
'#addrEl'
).
text
(
merchantForm
.
merchantAddress
)
}
}
...
@@ -955,13 +988,16 @@
...
@@ -955,13 +988,16 @@
if
(
merchantForm
.
merchantType
==
2
)
{
if
(
merchantForm
.
merchantType
==
2
)
{
$
(
'#merchantOrgcodeEl'
).
attr
(
'placeholder'
,
'请输入组织机构号码'
)
$
(
'#merchantOrgcodeEl'
).
attr
(
'placeholder'
,
'请输入组织机构号码'
)
}
}
console
.
log
(
merchantForm
)
if
(
step
==
1
)
{
getBusiScope
()
console
.
log
(
merchantForm
)
getCarBrandTree
()
getBusiScope
()
getAccountType
()
getCarBrandTree
()
recoveryBusiScopeCus
()
getAccountType
()
recoveryFile
()
recoveryBusiScopeCus
()
getById
()
recoveryFile
()
}
else
{
getById
()
}
})
})
}
}
...
@@ -990,7 +1026,7 @@
...
@@ -990,7 +1026,7 @@
treeObj
=
tree
.
create
(
'carBrandTree'
,
res
.
data
,
{
treeObj
=
tree
.
create
(
'carBrandTree'
,
res
.
data
,
{
checkedList
:
checkedList
checkedList
:
checkedList
})
})
all_nodes
=
treeObj
.
getNodes
(
)
all_nodes
=
treeObj
.
transformToArray
(
treeObj
.
getNodes
()
)
bindEvent
()
bindEvent
()
})
})
}
}
...
@@ -1305,6 +1341,7 @@
...
@@ -1305,6 +1341,7 @@
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
checkedList
:
defaultList
checkedList
:
defaultList
})
})
helper
.
defaultChecked
(
treeData
[
id
][
item
.
value
].
treeObj
,
defaultList
)
}
}
}
}
}
}
...
...
html/merchant/index.html
View file @
ee24a85
...
@@ -241,7 +241,7 @@
...
@@ -241,7 +241,7 @@
align
:
'center'
,
align
:
'center'
,
width
:
120
width
:
120
},
{
},
{
field
:
'merchantAddress'
,
field
:
'merchant
Full
Address'
,
title
:
'商户地址'
,
title
:
'商户地址'
,
align
:
'center'
,
align
:
'center'
,
width
:
160
width
:
160
...
...
html/role/add.html
View file @
ee24a85
...
@@ -249,6 +249,7 @@
...
@@ -249,6 +249,7 @@
treeData
[
id
][
item
.
value
].
treeObj
.
checkAllNodes
(
true
)
treeData
[
id
][
item
.
value
].
treeObj
.
checkAllNodes
(
true
)
}
else
{
}
else
{
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
checkedList
:
defaultList
})
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
checkedList
:
defaultList
})
helper
.
defaultChecked
(
treeData
[
id
][
item
.
value
].
treeObj
,
defaultList
)
}
}
}
}
}
}
...
...
js/gtree.js
View file @
ee24a85
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* @Author: limin
* @Author: limin
* @Date: 2021-07-19 16:37:36
* @Date: 2021-07-19 16:37:36
* @LastEditors: limin
* @LastEditors: limin
* @LastEditTime: 2021-08-2
0 12:06:31
* @LastEditTime: 2021-08-2
1 15:10:33
* @FilePath: \account\js\gtree.js
* @FilePath: \account\js\gtree.js
*/
*/
layui
.
define
([
'ztree'
],
function
(
exports
)
{
layui
.
define
([
'ztree'
],
function
(
exports
)
{
...
@@ -23,32 +23,6 @@ layui.define(['ztree'], function (exports) {
...
@@ -23,32 +23,6 @@ layui.define(['ztree'], function (exports) {
$switchs
.
not
(
':eq(0)'
).
addClass
(
'op0'
)
$switchs
.
not
(
':eq(0)'
).
addClass
(
'op0'
)
}
}
}
}
if
(
gtree
.
opt
&&
gtree
.
opt
.
checkedList
)
{
var
p
=
gtree
.
opt
.
checkedList
if
(
p
.
indexOf
(
treeNode
.
id
)
!=
-
1
)
{
// treeNode.checked = true
// var i= setInterval(function(){
// if (inst) {
// inst.updateNode(treeNode)
// clearInterval(i)
// }
// },20)
// var time = setTimeout(function () {
// if (inst) {
// inst.updateNode(treeNode)
// clearTimeout(time)
// }
// }, 20)
// console.log(!treeNode.children)
// if (inst) {
// inst.updateNode(treeNode)
// }
//else if (!treeNode.children) {
// rootNoChildCheckedNode.push(treeNode)
// // console.log(rootNoChildCheckedNode, '==============')
// }
}
}
if
(
gtree
.
opt
&&
gtree
.
opt
.
chkDisabled
)
{
if
(
gtree
.
opt
&&
gtree
.
opt
.
chkDisabled
)
{
treeNode
.
chkDisabled
=
true
treeNode
.
chkDisabled
=
true
}
}
...
@@ -90,20 +64,19 @@ layui.define(['ztree'], function (exports) {
...
@@ -90,20 +64,19 @@ layui.define(['ztree'], function (exports) {
if
(
check
==
0
)
setting
.
check
.
enable
=
false
if
(
check
==
0
)
setting
.
check
.
enable
=
false
inst
=
tree
.
init
(
$treeDom
,
setting
,
nodes
)
inst
=
tree
.
init
(
$treeDom
,
setting
,
nodes
)
inst
.
expandAll
(
true
)
inst
.
expandAll
(
true
)
setTimeout
(()
=>
{
if
(
opt
&&
opt
.
checkedList
)
{
inst
.
checkNodes
=
function
(
checked
){
var
nodesLevel1
=
inst
.
getNodes
()
var
nodesLevel1
=
this
.
getNodes
()
var
checked
=
opt
.
checkedList
var
nodesAll
=
this
.
transformToArray
(
nodesLevel1
)
var
nodesAll
=
inst
.
transformToArray
(
nodesLevel1
)
for
(
var
i
=
0
;
i
<=
nodesAll
.
length
;
i
++
)
{
$
.
each
(
nodesAll
,
function
(
index
,
node
)
{
var
node
=
nodesAll
[
i
]
if
(
checked
.
indexOf
(
node
.
id
)
!=
-
1
)
{
if
(
node
&&
checked
.
indexOf
(
node
.
id
)
!=
-
1
)
{
node
.
checked
=
true
node
.
checked
=
true
inst
.
updateNode
(
node
)
this
.
updateNode
(
node
)
}
}
})
}
}
}
,
20
);
}
// inst.refresh()
return
inst
return
inst
}
}
}
}
...
...
js/helper.js
View file @
ee24a85
...
@@ -42,45 +42,58 @@ layui.define(['store'], function (exports) {
...
@@ -42,45 +42,58 @@ layui.define(['store'], function (exports) {
function
debounce
(
fun
,
delay
)
{
function
debounce
(
fun
,
delay
)
{
return
function
(
args
)
{
return
function
(
args
)
{
//获取函数的作用域和变量
//获取函数的作用域和变量
var
that
=
this
var
that
=
this
var
_args
=
args
var
_args
=
args
//每次事件被触发,都会清除当前的timeer,然后重写设置超时调用
//每次事件被触发,都会清除当前的timeer,然后重写设置超时调用
clearTimeout
(
fun
.
id
)
clearTimeout
(
fun
.
id
)
fun
.
id
=
setTimeout
(
function
()
{
fun
.
id
=
setTimeout
(
function
()
{
fun
.
call
(
that
,
_args
)
fun
.
call
(
that
,
_args
)
},
delay
)
},
delay
)
}
}
}
}
//将后台返回数据中数值为空的字段全部替换为“-”
//将后台返回数据中数值为空的字段全部替换为“-”
function
formateNullFieldData
(
initialData
)
{
function
formateNullFieldData
(
initialData
)
{
const
isEmpty
=
function
(
val
)
{
const
isEmpty
=
function
(
val
)
{
if
(
!
String
(
val
)
||
String
(
val
)
===
'null'
)
{
if
(
!
String
(
val
)
||
String
(
val
)
===
'null'
)
{
return
'-'
;
return
'-'
;
}
return
val
;
}
}
if
(
initialData
instanceof
Array
)
{
return
val
;
initialData
.
forEach
(
function
(
val
,
key
,
array
)
{
}
array
[
key
]
=
formateNullFieldData
(
val
)
if
(
initialData
instanceof
Array
)
{
initialData
.
forEach
(
function
(
val
,
key
,
array
)
{
array
[
key
]
=
formateNullFieldData
(
val
)
})
})
}
else
if
(
initialData
instanceof
Object
)
{
}
else
if
(
initialData
instanceof
Object
)
{
for
(
let
pro
in
initialData
)
{
for
(
let
pro
in
initialData
)
{
initialData
[
pro
]
=
formateNullFieldData
(
initialData
[
pro
])
initialData
[
pro
]
=
formateNullFieldData
(
initialData
[
pro
])
}
}
else
{
//数据为基本类型时
initialData
=
isEmpty
(
initialData
)
}
}
return
initialData
;
}
else
{
//数据为基本类型时
initialData
=
isEmpty
(
initialData
)
}
}
return
initialData
;
}
function
defaultChecked
(
treeObj
,
checkedList
)
{
var
nodesLevel1
=
treeObj
.
getNodes
()
var
checked
=
checkedList
var
nodesAll
=
treeObj
.
transformToArray
(
nodesLevel1
)
for
(
var
i
=
0
;
i
<=
nodesAll
.
length
;
i
++
)
{
var
node
=
nodesAll
[
i
]
if
(
node
&&
checked
.
indexOf
(
node
.
id
)
!=
-
1
)
{
node
.
checked
=
true
treeObj
.
updateNode
(
node
)
}
}
}
exports
(
'helper'
,
{
exports
(
'helper'
,
{
clone
:
clone
,
clone
:
clone
,
store
:
layui
.
store
,
store
:
layui
.
store
,
debounce
:
debounce
,
debounce
:
debounce
,
formateNullFieldData
:
formateNullFieldData
formateNullFieldData
:
formateNullFieldData
,
defaultChecked
:
defaultChecked
})
})
})
})
\ No newline at end of file
\ No newline at end of file
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