Commit ba909778 by limin

新增树过滤

1 parent 789635c5
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">主营品牌:</label> <label class="layui-form-label">主营品牌:</label>
<div class="layui-input-inline"> <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 id="carBrandTree" style="width: 300px; height: 200px; overflow-y: scroll;"></div>
</div> </div>
</div> </div>
...@@ -283,6 +283,7 @@ ...@@ -283,6 +283,7 @@
var editData = {} var editData = {}
var scopeIdx = 1 var scopeIdx = 1
var treeObj = null var treeObj = null
var all_nodes = []
// 1-创建新商户;2-创建子商户;3-修改 // 1-创建新商户;2-创建子商户;3-修改
var editLevel = 1 var editLevel = 1
var id = null var id = null
...@@ -582,8 +583,20 @@ ...@@ -582,8 +583,20 @@
getChannel() getChannel()
getAccountLevel() getAccountLevel()
getPeriod() 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) { function setCheckbox(checkedStr, attr) {
if (!checkedStr || !checkedStr.length) { if (!checkedStr || !checkedStr.length) {
return false return false
...@@ -633,9 +646,9 @@ ...@@ -633,9 +646,9 @@
}, function (res) { }, function (res) {
baseData.carBrandTreeList = res.data baseData.carBrandTreeList = res.data
treeObj = tree.create('carBrandTree', res.data) treeObj = tree.create('carBrandTree', res.data)
all_nodes = treeObj.getNodes()
}) })
} }
// 获取字典数据 // 获取字典数据
function getDictData(dictType, fn) { function getDictData(dictType, fn) {
request({ request({
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: limin * @Author: limin
* @Date: 2021-07-21 17:20:56 * @Date: 2021-07-21 17:20:56
* @LastEditors: limin * @LastEditors: limin
* @LastEditTime: 2021-07-22 16:52:46 * @LastEditTime: 2021-08-06 16:47:13
* @FilePath: \account\js\helper.js * @FilePath: \account\js\helper.js
*/ */
layui.define(['store'], function (exports) { layui.define(['store'], function (exports) {
...@@ -39,8 +39,22 @@ layui.define(['store'], function (exports) { ...@@ -39,8 +39,22 @@ layui.define(['store'], function (exports) {
} }
return extended 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', { exports('helper', {
clone: clone, 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!