|
|
|
@ -170,7 +170,7 @@ layui.define(['globalTree'], function (exports) { |
|
|
|
|
all: true, |
|
|
|
|
cache: true, |
|
|
|
|
checkbar: true, |
|
|
|
|
checkbarType: multiple ? 'no-all' : 'only', |
|
|
|
|
checkbarType: multiple ? 'self' : 'only', |
|
|
|
|
scroll: '#label-tree', |
|
|
|
|
done: function () { |
|
|
|
|
let _chooseIds = []; |
|
|
|
@ -198,24 +198,39 @@ layui.define(['globalTree'], function (exports) { |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
checkbarFun: { |
|
|
|
|
activeNode: null, |
|
|
|
|
chooseBefore: function ($i, node) { |
|
|
|
|
this.activeNode = node; |
|
|
|
|
this.activeNode['checked'] = !$i.hasClass('dtree-theme-choose'); |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
chooseDone: function (nodes) { |
|
|
|
|
if (disableIds.length > 0) { |
|
|
|
|
treeObj.chooseDataInit(disableIds.join(',')); |
|
|
|
|
} |
|
|
|
|
const chooseNodes = treeObj.chooseNodes; |
|
|
|
|
if (!multiple) { |
|
|
|
|
treeObj.chooseNodes = nodes; |
|
|
|
|
} else { |
|
|
|
|
const nodeMap = new Map(); |
|
|
|
|
const choosePids = nodes.map(n => n.id); |
|
|
|
|
// 如果包含选中节点中包含上下级关系,则在选中节点中去掉上级节点
|
|
|
|
|
for(const node of nodes){ |
|
|
|
|
if(nodeMap.has(node.parentId)){ |
|
|
|
|
nodeMap.delete(node.parentId); |
|
|
|
|
const {id, parentId, checked} = this.activeNode; |
|
|
|
|
if (checked) { |
|
|
|
|
// 判断父级节点,如果是选中状态,则模拟复选框单击事件,取消选中
|
|
|
|
|
if (isChecked(parentId)) { |
|
|
|
|
treeObj.dtreeObj.clickNodeCheckbar(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') |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -250,7 +265,7 @@ layui.define(['globalTree'], function (exports) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function addOtherLabel(value, readonly) { |
|
|
|
|
let template = `<div class="label-set-component other-label ${readonly?'read-only':''}" th:data-field-title="其他标签"></div>`; |
|
|
|
|
let template = `<div class="label-set-component other-label ${readonly ? 'read-only' : ''}" th:data-field-title="其他标签"></div>`; |
|
|
|
|
$('.other-label-item.layui-input-block').append(template); |
|
|
|
|
let cid = _KEY + _CACHE.size, |
|
|
|
|
component = new Component(cid, $('.label-set-component.other-label:last')); |
|
|
|
|