From e93655a1c1fc9c7d29b398b039ff3d9c106fd261 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 18 May 2017 17:12:09 +0800 Subject: [PATCH] add --- bi/widget.js | 462 +++++++++--------- docs/widget.js | 462 +++++++++--------- src/widget/multistringlist/multistringlist.js | 228 +++++---- src/widget/multitreelist/multitreelist.js | 214 ++++---- .../multitreelist/multitreelist.popup.js | 20 +- 5 files changed, 714 insertions(+), 672 deletions(-) diff --git a/bi/widget.js b/bi/widget.js index 9ec134e1a4..903504541b 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -10955,7 +10955,7 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** - * Created by zcf on 2016/12/14. + * Created by zcf_1 on 2017/5/2. */ BI.MultiStringList = BI.inherit(BI.Widget, { _defaultConfig: function () { @@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, { baseCls: 'bi-multi-string-list', itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, - height: 25 + el: {} }) }, _init: function () { BI.MultiStringList.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.storeValue = {}; var assertShowValue = function () { BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); }; - this.storeValue = {}; - - this.popup = BI.createWidget({ + this.adapter = BI.createWidget({ type: "bi.multi_select_loader", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - onLoaded: o.onLoaded, + // onLoaded: o.onLoaded, el: { height: "" } }); - this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); @@ -10997,90 +10994,105 @@ BI.MultiStringList = BI.inherit(BI.Widget, { }); }); - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - adapter: this.popup, - masker: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } - }, + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keyword)) { - self.trigger.setValue(self.getValue()); - } - callback.apply(self, arguments); - }); + op.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); } }); + this.searcherPane.setVisible(false); - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); self._setStartValue(""); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); - }) - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - assertShowValue(); - self.popup.populate(); - self._setStartValue(""); + this.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + if (this.hasMatched()) { + var keyword = this.getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self._showAdapter(); + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self._setStartValue(""); + self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + }) } else { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - assertShowValue(); + self._showAdapter(); } - }); - } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () {//安徽省 北京 + assertShowValue(); + }); + } + } + }] }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () {//安徽省 北京 - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - var div = BI.createWidget({ - type: "bi.layout" - }); BI.createWidget({ type: "bi.vtape", element: this, @@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, { width: "100%", items: [{ el: this.trigger, - height: 25 - }, { - el: div, - height: 2 + height: 30 }, { - el: this.popup, + el: this.adapter, height: "fill" }] }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + _defaultState: function () { this.trigger.stopEditing(); }, @@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this._assertValue(res); o.itemsCreator({ type: BI.MultiStringList.REQ_GET_ALL_DATA, - keyword: this.trigger.getKey() + keyword: self.trigger.getKeyword() }, function (ob) { var items = BI.pluck(ob.items, "value"); if (self.storeValue.type === res.type) { @@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, { _setStartValue: function (value) { this._startValue = value; - this.popup.setStartValue(value); + this.adapter.setStartValue(value); }, - // isAllSelected: function () { - // return this.popup.isAllSelected(); - // }, + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, resize: function () { - this.trigger.getCounter().adjustView(); - this.trigger.getSearcher().adjustView(); + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); }, - setValue: function (v) { this.storeValue = v || {}; this._assertValue(this.storeValue); - this.popup.setValue(this.storeValue); + this.adapter.setValue(this.storeValue); this.trigger.setValue(this.storeValue); }, @@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { populate: function () { this._count = null; this._allData = null; - this.popup.populate.apply(this.popup, arguments); + this.adapter.populate.apply(this.adapter, arguments); this.trigger.populate.apply(this.trigger, arguments); } }); @@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** - * Created by zcf on 2016/12/20. + * Created by zcf_1 on 2017/5/11. */ -BI.MultiTreeList = BI.inherit(BI.Widget, { - constants: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } - }, - +BI.MultiSelectTree = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { baseCls: 'bi-multi-tree-combo', itemsCreator: BI.emptyFn, height: 25 - }); + }) }, _init: function () { - BI.MultiTreeList.superclass._init.apply(this, arguments); - + BI.MultiSelectTree.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.storeValue = {value: {}}; - var isInit = false; - var want2showCounter = false; - - this.popup = BI.createWidget({ - type: "bi.multi_tree_list_popup", + this.adapter = BI.createWidget({ + type: "bi.multi_select_tree_popup", itemsCreator: o.itemsCreator }); - - this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { - self.trigger.getCounter().adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); + this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); }); - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - adapter: this.popup, - masker: { - offset: this.constants.offset + this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.trigger.getKeyword(); }, - searcher: { - type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator - }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator - } - } - }); - - this.storeValue = {value: {}}; - - var isSearching = function () { - return self.trigger.getSearcher().isSearching(); - }; - - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.popup.getValue()}; - this.setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - BI.nextTick(function () { - self.trigger.populate(); - self.popup.populate(); - }); - }); - function showCounter() { - if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; - } else { - self.storeValue = {value: self.popup.getValue()}; - } - self.trigger.setValue(self.storeValue); - } - - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - if (want2showCounter === false) { - want2showCounter = true; - } - if (isInit === true) { - want2showCounter = null; - showCounter(); + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + o.itemsCreator(op, callback); } }); + this.searcherPane.setVisible(false); - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { - var val = { - type: BI.Selection.Multi, - value: this.getSearcher().hasChecked() ? {1: 1} : {} - }; - this.getSearcher().setState(val); - this.getCounter().setButtonChecked(val); - }); - - this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () { - showCounter(); - var val = { - type: BI.Selection.Multi, - value: this.hasChecked() ? {1: 1} : {} - }; - self.trigger.getSearcher().setState(val); - self.trigger.getCounter().setButtonChecked(val); - self.fireEvent(BI.MultiTreeList.EVENT_CHANGE); + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.trigger.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self.storeValue = {value: self.adapter.getValue()}; + self.searcherPane.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + self.adapter.setValue(self.storeValue); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] }); - var div = BI.createWidget({ - type: "bi.layout" - }); BI.createWidget({ type: "bi.vtape", element: this, @@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { width: "100%", items: [{ el: this.trigger, - height: 25 - }, { - el: div, - height: 2 + height: 30 }, { - el: this.popup, + el: this.adapter, height: "fill" }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] }) + }, - _defaultState: function () { - this.trigger.stopEditing(); + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); }, resize: function () { - this.trigger.getCounter().adjustView(); - this.trigger.getSearcher().adjustView(); + }, setValue: function (v) { this.storeValue.value = v || {}; - this.popup.setValue({ + this.adapter.setValue({ value: v || {} }); this.trigger.setValue({ @@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { populate: function () { this.trigger.populate.apply(this.trigger, arguments); - this.popup.populate.apply(this.popup, arguments); + this.adapter.populate.apply(this.adapter, arguments); } }); -BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; -BI.shortcut('bi.multi_tree_list', BI.MultiTreeList);/** +BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** * Created by zcf on 2016/12/21. */ -BI.MultiStringListPopup=BI.inherit(BI.Widget,{ - _defaultConfig:function () { - return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { +BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", itemsCreator: BI.emptyFn }); }, - _init:function () { - BI.MultiStringListPopup.superclass._init.apply(this, arguments); + _init: function () { + BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); var self = this, o = this.options; this.popup = BI.createWidget({ type: "bi.sync_tree", @@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{ itemsCreator: o.itemsCreator }); this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) + self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) }); this.popup.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) + self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) }); }, @@ -12224,9 +12238,9 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{ } }); -BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; -BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; -BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1 +BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; +BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1 //closeMIn:最小值的符号,closeMax:最大值的符号 /** * Created by roy on 15/9/17. diff --git a/docs/widget.js b/docs/widget.js index 9ec134e1a4..903504541b 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -10955,7 +10955,7 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** - * Created by zcf on 2016/12/14. + * Created by zcf_1 on 2017/5/2. */ BI.MultiStringList = BI.inherit(BI.Widget, { _defaultConfig: function () { @@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, { baseCls: 'bi-multi-string-list', itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, - height: 25 + el: {} }) }, _init: function () { BI.MultiStringList.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.storeValue = {}; var assertShowValue = function () { BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); }; - this.storeValue = {}; - - this.popup = BI.createWidget({ + this.adapter = BI.createWidget({ type: "bi.multi_select_loader", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - onLoaded: o.onLoaded, + // onLoaded: o.onLoaded, el: { height: "" } }); - this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); @@ -10997,90 +10994,105 @@ BI.MultiStringList = BI.inherit(BI.Widget, { }); }); - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - adapter: this.popup, - masker: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } - }, + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keyword)) { - self.trigger.setValue(self.getValue()); - } - callback.apply(self, arguments); - }); + op.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); } }); + this.searcherPane.setVisible(false); - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); self._setStartValue(""); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); - }) - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - assertShowValue(); - self.popup.populate(); - self._setStartValue(""); + this.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + if (this.hasMatched()) { + var keyword = this.getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self._showAdapter(); + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self._setStartValue(""); + self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + }) } else { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - assertShowValue(); + self._showAdapter(); } - }); - } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () {//安徽省 北京 + assertShowValue(); + }); + } + } + }] }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () {//安徽省 北京 - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - var div = BI.createWidget({ - type: "bi.layout" - }); BI.createWidget({ type: "bi.vtape", element: this, @@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, { width: "100%", items: [{ el: this.trigger, - height: 25 - }, { - el: div, - height: 2 + height: 30 }, { - el: this.popup, + el: this.adapter, height: "fill" }] }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + _defaultState: function () { this.trigger.stopEditing(); }, @@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this._assertValue(res); o.itemsCreator({ type: BI.MultiStringList.REQ_GET_ALL_DATA, - keyword: this.trigger.getKey() + keyword: self.trigger.getKeyword() }, function (ob) { var items = BI.pluck(ob.items, "value"); if (self.storeValue.type === res.type) { @@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, { _setStartValue: function (value) { this._startValue = value; - this.popup.setStartValue(value); + this.adapter.setStartValue(value); }, - // isAllSelected: function () { - // return this.popup.isAllSelected(); - // }, + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, resize: function () { - this.trigger.getCounter().adjustView(); - this.trigger.getSearcher().adjustView(); + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); }, - setValue: function (v) { this.storeValue = v || {}; this._assertValue(this.storeValue); - this.popup.setValue(this.storeValue); + this.adapter.setValue(this.storeValue); this.trigger.setValue(this.storeValue); }, @@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { populate: function () { this._count = null; this._allData = null; - this.popup.populate.apply(this.popup, arguments); + this.adapter.populate.apply(this.adapter, arguments); this.trigger.populate.apply(this.trigger, arguments); } }); @@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** - * Created by zcf on 2016/12/20. + * Created by zcf_1 on 2017/5/11. */ -BI.MultiTreeList = BI.inherit(BI.Widget, { - constants: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } - }, - +BI.MultiSelectTree = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { baseCls: 'bi-multi-tree-combo', itemsCreator: BI.emptyFn, height: 25 - }); + }) }, _init: function () { - BI.MultiTreeList.superclass._init.apply(this, arguments); - + BI.MultiSelectTree.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.storeValue = {value: {}}; - var isInit = false; - var want2showCounter = false; - - this.popup = BI.createWidget({ - type: "bi.multi_tree_list_popup", + this.adapter = BI.createWidget({ + type: "bi.multi_select_tree_popup", itemsCreator: o.itemsCreator }); - - this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { - self.trigger.getCounter().adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); + this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); }); - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - adapter: this.popup, - masker: { - offset: this.constants.offset + this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.trigger.getKeyword(); }, - searcher: { - type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator - }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator - } - } - }); - - this.storeValue = {value: {}}; - - var isSearching = function () { - return self.trigger.getSearcher().isSearching(); - }; - - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.popup.getValue()}; - this.setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - BI.nextTick(function () { - self.trigger.populate(); - self.popup.populate(); - }); - }); - function showCounter() { - if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; - } else { - self.storeValue = {value: self.popup.getValue()}; - } - self.trigger.setValue(self.storeValue); - } - - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - if (want2showCounter === false) { - want2showCounter = true; - } - if (isInit === true) { - want2showCounter = null; - showCounter(); + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + o.itemsCreator(op, callback); } }); + this.searcherPane.setVisible(false); - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { - var val = { - type: BI.Selection.Multi, - value: this.getSearcher().hasChecked() ? {1: 1} : {} - }; - this.getSearcher().setState(val); - this.getCounter().setButtonChecked(val); - }); - - this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () { - showCounter(); - var val = { - type: BI.Selection.Multi, - value: this.hasChecked() ? {1: 1} : {} - }; - self.trigger.getSearcher().setState(val); - self.trigger.getCounter().setButtonChecked(val); - self.fireEvent(BI.MultiTreeList.EVENT_CHANGE); + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.trigger.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self.storeValue = {value: self.adapter.getValue()}; + self.searcherPane.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + self.adapter.setValue(self.storeValue); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] }); - var div = BI.createWidget({ - type: "bi.layout" - }); BI.createWidget({ type: "bi.vtape", element: this, @@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { width: "100%", items: [{ el: this.trigger, - height: 25 - }, { - el: div, - height: 2 + height: 30 }, { - el: this.popup, + el: this.adapter, height: "fill" }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] }) + }, - _defaultState: function () { - this.trigger.stopEditing(); + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); }, resize: function () { - this.trigger.getCounter().adjustView(); - this.trigger.getSearcher().adjustView(); + }, setValue: function (v) { this.storeValue.value = v || {}; - this.popup.setValue({ + this.adapter.setValue({ value: v || {} }); this.trigger.setValue({ @@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { populate: function () { this.trigger.populate.apply(this.trigger, arguments); - this.popup.populate.apply(this.popup, arguments); + this.adapter.populate.apply(this.adapter, arguments); } }); -BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; -BI.shortcut('bi.multi_tree_list', BI.MultiTreeList);/** +BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** * Created by zcf on 2016/12/21. */ -BI.MultiStringListPopup=BI.inherit(BI.Widget,{ - _defaultConfig:function () { - return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { +BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", itemsCreator: BI.emptyFn }); }, - _init:function () { - BI.MultiStringListPopup.superclass._init.apply(this, arguments); + _init: function () { + BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); var self = this, o = this.options; this.popup = BI.createWidget({ type: "bi.sync_tree", @@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{ itemsCreator: o.itemsCreator }); this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) + self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) }); this.popup.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) + self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) }); }, @@ -12224,9 +12238,9 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{ } }); -BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; -BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; -BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1 +BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; +BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1 //closeMIn:最小值的符号,closeMax:最大值的符号 /** * Created by roy on 15/9/17. diff --git a/src/widget/multistringlist/multistringlist.js b/src/widget/multistringlist/multistringlist.js index 5ca2696795..f1783428da 100644 --- a/src/widget/multistringlist/multistringlist.js +++ b/src/widget/multistringlist/multistringlist.js @@ -1,5 +1,5 @@ /** - * Created by zcf on 2016/12/14. + * Created by zcf_1 on 2017/5/2. */ BI.MultiStringList = BI.inherit(BI.Widget, { _defaultConfig: function () { @@ -7,33 +7,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, { baseCls: 'bi-multi-string-list', itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, - height: 25 + el: {} }) }, _init: function () { BI.MultiStringList.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.storeValue = {}; var assertShowValue = function () { BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); }; - this.storeValue = {}; - - this.popup = BI.createWidget({ + this.adapter = BI.createWidget({ type: "bi.multi_select_loader", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - onLoaded: o.onLoaded, + // onLoaded: o.onLoaded, el: { height: "" } }); - this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); @@ -41,90 +38,105 @@ BI.MultiStringList = BI.inherit(BI.Widget, { }); }); - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - adapter: this.popup, - masker: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } - }, + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keyword)) { - self.trigger.setValue(self.getValue()); - } - callback.apply(self, arguments); - }); + op.keyword = self.trigger.getKeyword(); + this.setKeyword(op.keyword); + o.itemsCreator(op, callback); } }); + this.searcherPane.setVisible(false); - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); self._setStartValue(""); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); - }) - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - assertShowValue(); - self.popup.populate(); - self._setStartValue(""); + this.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + if (this.hasMatched()) { + var keyword = this.getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self._showAdapter(); + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self._setStartValue(""); + self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + }) } else { - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - assertShowValue(); + self._showAdapter(); } - }); - } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.trigger.setValue(self.storeValue); + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () {//安徽省 北京 + assertShowValue(); + }); + } + } + }] }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () {//安徽省 北京 - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - var div = BI.createWidget({ - type: "bi.layout" - }); BI.createWidget({ type: "bi.vtape", element: this, @@ -132,16 +144,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, { width: "100%", items: [{ el: this.trigger, - height: 25 - }, { - el: div, - height: 2 + height: 30 }, { - el: this.popup, + el: this.adapter, height: "fill" }] }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + _defaultState: function () { this.trigger.stopEditing(); }, @@ -186,7 +219,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this._assertValue(res); o.itemsCreator({ type: BI.MultiStringList.REQ_GET_ALL_DATA, - keyword: this.trigger.getKey() + keyword: self.trigger.getKeyword() }, function (ob) { var items = BI.pluck(ob.items, "value"); if (self.storeValue.type === res.type) { @@ -275,22 +308,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, { _setStartValue: function (value) { this._startValue = value; - this.popup.setStartValue(value); + this.adapter.setStartValue(value); }, - // isAllSelected: function () { - // return this.popup.isAllSelected(); - // }, + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, resize: function () { - this.trigger.getCounter().adjustView(); - this.trigger.getSearcher().adjustView(); + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); }, - setValue: function (v) { this.storeValue = v || {}; this._assertValue(this.storeValue); - this.popup.setValue(this.storeValue); + this.adapter.setValue(this.storeValue); this.trigger.setValue(this.storeValue); }, @@ -301,7 +333,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { populate: function () { this._count = null; this._allData = null; - this.popup.populate.apply(this.popup, arguments); + this.adapter.populate.apply(this.adapter, arguments); this.trigger.populate.apply(this.trigger, arguments); } }); diff --git a/src/widget/multitreelist/multitreelist.js b/src/widget/multitreelist/multitreelist.js index 52182c0dce..2403eac14a 100644 --- a/src/widget/multitreelist/multitreelist.js +++ b/src/widget/multitreelist/multitreelist.js @@ -1,128 +1,94 @@ /** - * Created by zcf on 2016/12/20. + * Created by zcf_1 on 2017/5/11. */ -BI.MultiTreeList = BI.inherit(BI.Widget, { - constants: { - offset: { - left: 1, - top: 0, - right: 2, - bottom: 1 - } - }, - +BI.MultiSelectTree = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { + return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { baseCls: 'bi-multi-tree-combo', itemsCreator: BI.emptyFn, height: 25 - }); + }) }, _init: function () { - BI.MultiTreeList.superclass._init.apply(this, arguments); - + BI.MultiSelectTree.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.storeValue = {value: {}}; - var isInit = false; - var want2showCounter = false; - - this.popup = BI.createWidget({ - type: "bi.multi_tree_list_popup", + this.adapter = BI.createWidget({ + type: "bi.multi_select_tree_popup", itemsCreator: o.itemsCreator }); - - this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { - self.trigger.getCounter().adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); + this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); }); - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - adapter: this.popup, - masker: { - offset: this.constants.offset + this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.trigger.getKeyword(); }, - searcher: { - type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator - }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator - } + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + o.itemsCreator(op, callback); } }); + this.searcherPane.setVisible(false); - this.storeValue = {value: {}}; - - var isSearching = function () { - return self.trigger.getSearcher().isSearching(); - }; - - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.popup.getValue()}; - this.setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; - self.trigger.setValue(self.storeValue); - self.popup.setValue(self.storeValue); - BI.nextTick(function () { - self.trigger.populate(); - self.popup.populate(); - }); - }); - function showCounter() { - if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; - } else { - self.storeValue = {value: self.popup.getValue()}; - } - self.trigger.setValue(self.storeValue); - } - - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - if (want2showCounter === false) { - want2showCounter = true; - } - if (isInit === true) { - want2showCounter = null; - showCounter(); - } - }); - - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { - var val = { - type: BI.Selection.Multi, - value: this.getSearcher().hasChecked() ? {1: 1} : {} - }; - this.getSearcher().setState(val); - this.getCounter().setButtonChecked(val); - }); - - this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () { - showCounter(); - var val = { - type: BI.Selection.Multi, - value: this.hasChecked() ? {1: 1} : {} - }; - self.trigger.getSearcher().setState(val); - self.trigger.getCounter().setButtonChecked(val); - self.fireEvent(BI.MultiTreeList.EVENT_CHANGE); + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.trigger.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self.storeValue = {value: self.adapter.getValue()}; + self.searcherPane.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + self.adapter.setValue(self.storeValue); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] }); - var div = BI.createWidget({ - type: "bi.layout" - }); BI.createWidget({ type: "bi.vtape", element: this, @@ -130,29 +96,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { width: "100%", items: [{ el: this.trigger, - height: 25 + height: 30 }, { - el: div, - height: 2 - }, { - el: this.popup, + el: this.adapter, height: "fill" }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] }) + }, - _defaultState: function () { - this.trigger.stopEditing(); + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); }, resize: function () { - this.trigger.getCounter().adjustView(); - this.trigger.getSearcher().adjustView(); + }, setValue: function (v) { this.storeValue.value = v || {}; - this.popup.setValue({ + this.adapter.setValue({ value: v || {} }); this.trigger.setValue({ @@ -166,8 +148,8 @@ BI.MultiTreeList = BI.inherit(BI.Widget, { populate: function () { this.trigger.populate.apply(this.trigger, arguments); - this.popup.populate.apply(this.popup, arguments); + this.adapter.populate.apply(this.adapter, arguments); } }); -BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; -BI.shortcut('bi.multi_tree_list', BI.MultiTreeList); \ No newline at end of file +BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree); \ No newline at end of file diff --git a/src/widget/multitreelist/multitreelist.popup.js b/src/widget/multitreelist/multitreelist.popup.js index 549c471d0f..864137a9c6 100644 --- a/src/widget/multitreelist/multitreelist.popup.js +++ b/src/widget/multitreelist/multitreelist.popup.js @@ -1,15 +1,15 @@ /** * Created by zcf on 2016/12/21. */ -BI.MultiStringListPopup=BI.inherit(BI.Widget,{ - _defaultConfig:function () { - return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { +BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", itemsCreator: BI.emptyFn }); }, - _init:function () { - BI.MultiStringListPopup.superclass._init.apply(this, arguments); + _init: function () { + BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); var self = this, o = this.options; this.popup = BI.createWidget({ type: "bi.sync_tree", @@ -18,10 +18,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{ itemsCreator: o.itemsCreator }); this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) + self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) }); this.popup.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) + self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) }); }, @@ -43,6 +43,6 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{ } }); -BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; -BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; -BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup); \ No newline at end of file +BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; +BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup); \ No newline at end of file