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