|
|
@ -170,7 +170,7 @@ layui.define(['globalTree'], function (exports) { |
|
|
|
all: true, |
|
|
|
all: true, |
|
|
|
cache: true, |
|
|
|
cache: true, |
|
|
|
checkbar: true, |
|
|
|
checkbar: true, |
|
|
|
checkbarType: multiple ? 'no-all' : 'only', |
|
|
|
checkbarType: multiple ? 'self' : 'only', |
|
|
|
scroll: '#label-tree', |
|
|
|
scroll: '#label-tree', |
|
|
|
done: function () { |
|
|
|
done: function () { |
|
|
|
let _chooseIds = []; |
|
|
|
let _chooseIds = []; |
|
|
@ -198,24 +198,39 @@ layui.define(['globalTree'], function (exports) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
checkbarFun: { |
|
|
|
checkbarFun: { |
|
|
|
|
|
|
|
activeNode: null, |
|
|
|
|
|
|
|
chooseBefore: function ($i, node) { |
|
|
|
|
|
|
|
this.activeNode = node; |
|
|
|
|
|
|
|
this.activeNode['checked'] = !$i.hasClass('dtree-theme-choose'); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
}, |
|
|
|
chooseDone: function (nodes) { |
|
|
|
chooseDone: function (nodes) { |
|
|
|
if (disableIds.length > 0) { |
|
|
|
if (disableIds.length > 0) { |
|
|
|
treeObj.chooseDataInit(disableIds.join(',')); |
|
|
|
treeObj.chooseDataInit(disableIds.join(',')); |
|
|
|
} |
|
|
|
} |
|
|
|
const chooseNodes = treeObj.chooseNodes; |
|
|
|
|
|
|
|
if (!multiple) { |
|
|
|
if (!multiple) { |
|
|
|
treeObj.chooseNodes = nodes; |
|
|
|
treeObj.chooseNodes = nodes; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const nodeMap = new Map(); |
|
|
|
const {id, parentId, checked} = this.activeNode; |
|
|
|
const choosePids = nodes.map(n => n.id); |
|
|
|
if (checked) { |
|
|
|
// 如果包含选中节点中包含上下级关系,则在选中节点中去掉上级节点
|
|
|
|
// 判断父级节点,如果是选中状态,则模拟复选框单击事件,取消选中
|
|
|
|
for(const node of nodes){ |
|
|
|
if (isChecked(parentId)) { |
|
|
|
if(nodeMap.has(node.parentId)){ |
|
|
|
treeObj.dtreeObj.clickNodeCheckbar(parentId); |
|
|
|
nodeMap.delete(node.parentId); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取下级节点集合,并遍历集合,如果是选中状态,则模拟复选框单击事件,取消选中
|
|
|
|
|
|
|
|
const children = layui.globalTree.getChildParam(treeObj, id); |
|
|
|
|
|
|
|
for (const child of children) { |
|
|
|
|
|
|
|
if (isChecked(child.id)) { |
|
|
|
|
|
|
|
treeObj.dtreeObj.clickNodeCheckbar(child.id); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
nodeMap.set(node.id, node) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
treeObj.chooseNodes = [...nodeMap.values()]; |
|
|
|
|
|
|
|
|
|
|
|
treeObj.chooseNodes = layui.globalTree.getCheckbarNodesParam("label-tree"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isChecked(id) { |
|
|
|
|
|
|
|
return $(`.dtree-nav-checkbox-div[data-id="${id}"] i`).hasClass('dtree-theme-choose') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|