Commit c20f63dc by 胡悦

tijao

1 parent a52cdeef
......@@ -350,12 +350,12 @@
} else {
console.log(11)
const arr = []
arr.push(merchantId)
visibleMerchant = tree.create('visibleInferiorMerTree', res.data)
var node = visibleMerchant.getNodesByParam('id', merchantId, {checkedList: arr})
// console.log(node, visibleMerchant)
arr.push(+merchantId)
visibleMerchant = tree.create('visibleInferiorMerTree', res.data, {checkedList: arr})
var node = visibleMerchant.getNodesByParam('id', merchantId)
console.log(node, visibleMerchant)
// node.checked = true
visibleMerchant.checkNode(node, true, true)
// visibleMerchant.checkNode(node, true, true)
// visibleMerchant.updateNode(node)
all_nodes = visibleMerchant.getNodes()
bindEvent()
......
......@@ -40,18 +40,23 @@ layui.define(['ztree'], function (exports) {
// }
// }, 20)
// console.log(!treeNode.children)
if (inst) {
inst.updateNode(treeNode)
} else if(!treeNode.children) {
rootNoChildCheckedNode.push(treeNode)
// console.log(rootNoChildCheckedNode, '==============')
}
// if (inst) {
// inst.updateNode(treeNode)
// }
//else if (!treeNode.children) {
// rootNoChildCheckedNode.push(treeNode)
// // console.log(rootNoChildCheckedNode, '==============')
// }
}
}
if (gtree.opt && gtree.opt.chkDisabled) {
treeNode.chkDisabled = true
}
}
function zTreeOnExpand(event, treeId, treeNode) {
console.log(treeNode)
treeNode.check=true
}
var setting = {
view: {
selectedMulti: false,
......@@ -70,7 +75,8 @@ layui.define(['ztree'], function (exports) {
}
},
callback: {
onNodeCreated: onNodeCreated
onNodeCreated: onNodeCreated,
onExpand: zTreeOnExpand
}
}
var inst = null
......@@ -84,11 +90,17 @@ layui.define(['ztree'], function (exports) {
if (check == 0) setting.check.enable = false
inst = tree.init($treeDom, setting, nodes)
inst.expandAll(true)
// console.log(rootNoChildCheckedNode)
$.each(rootNoChildCheckedNode, function(index, item) {
console.log(item, '============')
inst.checkNode(item, true)
})
if (opt && opt.checkedList) {
var nodes = inst.getCheckedNodes()
var checked = opt.checkedList
$.each(nodes, function (index, item) {
if (checked.indexOf(item.id) == -1) {
item.checked = false
inst.updateNode(item)
}
})
}
// inst.refresh()
return inst
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!