Commit ba909778 by limin

新增树过滤

1 parent 789635c5
......@@ -193,7 +193,7 @@
<div class="layui-form-item">
<label class="layui-form-label">主营品牌:</label>
<div class="layui-input-inline">
<input class="layui-input" placeholder="车型品牌">
<input class="layui-input" placeholder="车型品牌" id="brand">
<div id="carBrandTree" style="width: 300px; height: 200px; overflow-y: scroll;"></div>
</div>
</div>
......@@ -283,6 +283,7 @@
var editData = {}
var scopeIdx = 1
var treeObj = null
var all_nodes = []
// 1-创建新商户;2-创建子商户;3-修改
var editLevel = 1
var id = null
......@@ -582,8 +583,20 @@
getChannel()
getAccountLevel()
getPeriod()
bindEvent()
}
function bindEvent(){
$('#brand').on('input',helper.debounce(function(){
var txt = $(this).val()
if(!txt){
treeObj.showNodes(all_nodes)
}else{
var show_nodes = treeObj.getNodesByParamFuzzy('label',txt)
treeObj.hideNodes(all_nodes)
treeObj.showNodes(show_nodes)
}
},500))
}
function setCheckbox(checkedStr, attr) {
if (!checkedStr || !checkedStr.length) {
return false
......@@ -633,9 +646,9 @@
}, function (res) {
baseData.carBrandTreeList = res.data
treeObj = tree.create('carBrandTree', res.data)
all_nodes = treeObj.getNodes()
})
}
// 获取字典数据
function getDictData(dictType, fn) {
request({
......
......@@ -4,7 +4,7 @@
* @Author: limin
* @Date: 2021-07-21 17:20:56
* @LastEditors: limin
* @LastEditTime: 2021-07-22 16:52:46
* @LastEditTime: 2021-08-06 16:47:13
* @FilePath: \account\js\helper.js
*/
layui.define(['store'], function (exports) {
......@@ -39,8 +39,22 @@ layui.define(['store'], function (exports) {
}
return extended
}
function debounce(fun, delay) {
return function (args) {
//获取函数的作用域和变量
let that = this
let _args = args
//每次事件被触发,都会清除当前的timeer,然后重写设置超时调用
clearTimeout(fun.id)
fun.id = setTimeout(function () {
fun.call(that, _args)
}, delay)
}
}
exports('helper', {
clone: clone,
store: layui.store
store: layui.store,
debounce: debounce
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!