From bcbacaa38ed41b926c4216e469f644cf1102cbee Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 3 Sep 2019 09:36:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8D=A2=E4=B8=80=E7=A7=8D?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/2.0/fineui.ie.js | 30 ++++++++++++------- dist/2.0/fineui.js | 30 ++++++++++++------- dist/bundle.ie.js | 30 ++++++++++++------- dist/bundle.js | 30 ++++++++++++------- dist/fineui.ie.js | 30 ++++++++++++------- dist/fineui.js | 30 ++++++++++++------- dist/fineui_without_jquery_polyfill.js | 30 ++++++++++++------- dist/widget.js | 30 ++++++++++++------- .../multilayerselecttree.trigger.js | 15 ++++++---- .../multilayersingletree.trigger.js | 15 ++++++---- 10 files changed, 180 insertions(+), 90 deletions(-) diff --git a/dist/2.0/fineui.ie.js b/dist/2.0/fineui.ie.js index a83082d73..80928cb87 100644 --- a/dist/2.0/fineui.ie.js +++ b/dist/2.0/fineui.ie.js @@ -69244,11 +69244,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -70415,11 +70420,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/2.0/fineui.js b/dist/2.0/fineui.js index 1492ee320..9bc68ae6c 100644 --- a/dist/2.0/fineui.js +++ b/dist/2.0/fineui.js @@ -69648,11 +69648,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -70819,11 +70824,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/bundle.ie.js b/dist/bundle.ie.js index a83082d73..80928cb87 100644 --- a/dist/bundle.ie.js +++ b/dist/bundle.ie.js @@ -69244,11 +69244,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -70415,11 +70420,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/bundle.js b/dist/bundle.js index 1492ee320..9bc68ae6c 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -69648,11 +69648,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -70819,11 +70824,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/fineui.ie.js b/dist/fineui.ie.js index 394d8c838..efc058a9d 100644 --- a/dist/fineui.ie.js +++ b/dist/fineui.ie.js @@ -69489,11 +69489,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -70660,11 +70665,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/fineui.js b/dist/fineui.js index 673357db9..da2d9cb01 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -69893,11 +69893,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -71064,11 +71069,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/fineui_without_jquery_polyfill.js b/dist/fineui_without_jquery_polyfill.js index e1a3d7fee..61e8bb8e1 100644 --- a/dist/fineui_without_jquery_polyfill.js +++ b/dist/fineui_without_jquery_polyfill.js @@ -52192,11 +52192,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -53363,11 +53368,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/dist/widget.js b/dist/widget.js index 4b3828e12..12b2ce018 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -7303,11 +7303,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { @@ -8474,11 +8479,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js index 90cab85f4..f9312e384 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js @@ -130,11 +130,16 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) { diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index 4ff540e96..819986c59 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -130,11 +130,16 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { _getSearchItems: function(keyword) { var o = this.options; - var findingText = BI.Func.getSearchResult(this.nodes, keyword, "text"); - var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(this.nodes, keyword, "value") : {find: [], match: []}; - var textItems = findingText.find.concat(findingText.match); - var valueItems = findingValue.find.concat(findingValue.match); - return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id")); + // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 + var items = []; + this.tree.traverse(function (node) { + var find = BI.Func.getSearchResult([node.text || (o.allowSearchValue && node.value) || ""], keyword); + if(find.find.length > 0 || find.match.length > 0) { + items.push(node); + return true; + } + }); + return this._fillTreeStructure4Search(items, "id"); }, _createJson: function(node, open) {