修改筛选

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

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

Loading…
Cancel
Save