From f26d9f5429cdf5a05a8cb154ba96a2684ca26da4 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 1 Jul 2019 11:15:28 +0800 Subject: [PATCH] =?UTF-8?q?BI-46741=20fix:=20=E5=A4=8D=E9=80=89=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=90=9C=E7=B4=A2keywords=E9=9B=86=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../abstract.allvaluechooser.js | 23 +++++++++++-------- .../valuechooser/abstract.valuechooser.js | 23 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/component/allvaluechooser/abstract.allvaluechooser.js b/src/component/allvaluechooser/abstract.allvaluechooser.js index 53f9e02cd..332a1737d 100644 --- a/src/component/allvaluechooser/abstract.allvaluechooser.js +++ b/src/component/allvaluechooser/abstract.allvaluechooser.js @@ -52,30 +52,33 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, { if (options.keyword) { keywords.push(options.keyword); } - var resultItems = []; - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - resultItems = resultItems.concat(search.match).concat(search.find); - }); - resultItems = BI.uniq(resultItems); + var resultItems = items; + if(BI.isNotEmptyArray(keywords)) { + resultItems = []; + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + resultItems = resultItems.concat(search.match).concat(search.find); + }); + resultItems = BI.uniq(resultItems); + } if (options.selectedValues) {// 过滤 var filter = BI.makeObject(options.selectedValues, true); - items = BI.filter(items, function (i, ob) { + resultItems = BI.filter(resultItems, function (i, ob) { return !filter[ob.value]; }); } if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { callback({ - items: items + items: resultItems }); return; } if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { - callback({count: items.length}); + callback({count: resultItems.length}); return; } callback({ - items: items, + items: resultItems, hasNext: false }); } diff --git a/src/component/valuechooser/abstract.valuechooser.js b/src/component/valuechooser/abstract.valuechooser.js index cadc2832a..ff199e76a 100644 --- a/src/component/valuechooser/abstract.valuechooser.js +++ b/src/component/valuechooser/abstract.valuechooser.js @@ -58,29 +58,34 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, { } function call (items) { var keywords = (options.keywords || []).slice(); - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - items = search.match.concat(search.find); - }); + var resultItems = items; + if(BI.isNotEmptyArray(keywords)) { + resultItems = []; + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + resultItems = resultItems.concat(search.match).concat(search.find); + }); + resultItems = BI.uniq(resultItems); + } if (options.selectedValues) {// 过滤 var filter = BI.makeObject(options.selectedValues, true); - items = BI.filter(items, function (i, ob) { + resultItems = BI.filter(resultItems, function (i, ob) { return !filter[ob.value]; }); } if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { callback({ - items: items + items: resultItems }); return; } if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { - callback({count: items.length}); + callback({count: resultItems.length}); return; } callback({ - items: self._getItemsByTimes(items, options.times), - hasNext: self._hasNextByTimes(items, options.times) + items: self._getItemsByTimes(resultItems, options.times), + hasNext: self._hasNextByTimes(resultItems, options.times) }); } }