修改筛选

main
夜笙歌 2 years ago
parent 6e274d4bfe
commit 02ce084f8e

@ -10,6 +10,12 @@
<link rel="stylesheet" th:href="@{/css/lot-ui/bootstrap-table.css}"/>
<link rel="stylesheet" th:href="@{/css/lot-ui/Iot-sensorSummaryStyle.css}"/>
</head>
<style>
.bootstrap-table .fixed-table-container .fixed-table-body{
height: calc(91vh - 100px);
}
</style>
<body>
<!--传感器类型-->
<iframe id="sensorType" name="a_iframe" width="100%" height="100%" frameborder="1" align="middle"

@ -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>

Loading…
Cancel
Save