|
|
|
@ -549,6 +549,7 @@
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let listData = []
|
|
|
|
|
$(function () {
|
|
|
|
|
var search = function () {
|
|
|
|
|
$.ajax({
|
|
|
|
@ -557,6 +558,7 @@
|
|
|
|
|
dataType: 'JSON', // 反序列化
|
|
|
|
|
success: (res) => { // 成功获取到后端返回结果的回调函数
|
|
|
|
|
initSelectableTree(res);
|
|
|
|
|
listData = res
|
|
|
|
|
return res;
|
|
|
|
|
},
|
|
|
|
|
error: () => { // 发送失败的回调函数
|
|
|
|
@ -566,6 +568,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var initSelectableTree = function (defaultData) {
|
|
|
|
|
console.log(defaultData)
|
|
|
|
|
return $('#treeview-selectable').treeview({
|
|
|
|
|
data: defaultData,
|
|
|
|
|
multiSelect: $('#chk-select-multi').is(':checked'),
|
|
|
|
@ -586,16 +589,26 @@
|
|
|
|
|
var $selectableTree = initSelectableTree(search());
|
|
|
|
|
|
|
|
|
|
var findSelectableNodes = function () {
|
|
|
|
|
return $selectableTree.treeview('search', [$('#input-select-node').val(), {
|
|
|
|
|
ignoreCase: false,
|
|
|
|
|
exactMatch: false,
|
|
|
|
|
}]);
|
|
|
|
|
let data = listData.map(e=>{
|
|
|
|
|
let nodes = e.nodes.filter(val=>val.text.includes($('#input-select-node').val()))
|
|
|
|
|
if(nodes.length === 0) return
|
|
|
|
|
return{
|
|
|
|
|
...e,
|
|
|
|
|
nodes,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
// console.log(data)
|
|
|
|
|
initSelectableTree(data)
|
|
|
|
|
// return $selectableTree.treeview('search', [$('#input-select-node').val(), {
|
|
|
|
|
// ignoreCase: false,
|
|
|
|
|
// exactMatch: false,
|
|
|
|
|
// }]);
|
|
|
|
|
};
|
|
|
|
|
var selectableNodes = findSelectableNodes();
|
|
|
|
|
|
|
|
|
|
$('#input-select-node').on('keyup', function (e) {
|
|
|
|
|
selectableNodes = findSelectableNodes();
|
|
|
|
|
$('.select-node').prop('disabled', !(selectableNodes.length >= 1));
|
|
|
|
|
findSelectableNodes();
|
|
|
|
|
// initSelectableTree([])
|
|
|
|
|
// $('.select-node').prop('disabled', !(selectableNodes.length >= 1));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|