guy 8 years ago
parent
commit
07ff967a0d
  1. 75
      bi/base.js
  2. 32
      bi/widget.js
  3. 75
      docs/base.js
  4. 32
      docs/widget.js
  5. 13
      src/base/combination/combo.js
  6. 25
      src/base/combination/expander.js
  7. 2
      src/base/combination/switcher.js
  8. 22
      src/base/tree/asynctree.js
  9. 8
      src/base/tree/parttree.js
  10. 5
      src/base/tree/treeview.js
  11. 32
      src/widget/multiselecttree/multiselecttree.js

75
bi/base.js

@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this._buildTree(map, path); this._buildTree(map, path);
return; return;
} }
var storeValues = BI.deepClone(this.selectedValues); var storeValues = BI.deepClone(this.options.paras.selectedValues);
var treeNode = this._getTree(storeValues, path); var treeNode = this._getTree(storeValues, path);
this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode);
}, },
@ -1952,8 +1952,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
}, },
setSelectedValue: function (value) { setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {}; this.options.paras.selectedValues = BI.deepClone(value || {});
this.selectedValues = BI.deepClone(value) || {};
}, },
updateValue: function (values, param) { updateValue: function (values, param) {
@ -2105,7 +2104,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) { if (treeNode.checked === true) {
} else { } else {
var tNode = treeNode; var tNode = treeNode;
var pNode = this._getTree(this.selectedValues, parentValues); var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
if (BI.isNotNull(pNode[name])) { if (BI.isNotNull(pNode[name])) {
delete pNode[name]; delete pNode[name];
} }
@ -2113,7 +2112,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
parentValues = parentValues.slice(0, parentValues.length - 1); parentValues = parentValues.slice(0, parentValues.length - 1);
tNode = tNode.getParentNode(); tNode = tNode.getParentNode();
if (tNode != null) { if (tNode != null) {
pNode = this._getTree(this.selectedValues, parentValues); pNode = this._getTree(this.options.paras.selectedValues, parentValues);
name = this._getNodeValue(tNode); name = this._getNodeValue(tNode);
delete pNode[name]; delete pNode[name];
} }
@ -2127,10 +2126,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options; var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
var op = BI.extend({}, o.paras, { var op = BI.extend({}, o.paras, {
"id": treeNode.id, id: treeNode.id,
"times": 1, times: 1,
"parentValues": parentValues.concat(this._getNodeValue(treeNode)), parentValues: parentValues.concat(this._getNodeValue(treeNode)),
"checkState": treeNode.getCheckStatus() checkState: treeNode.getCheckStatus()
}); });
var complete = function (d) { var complete = function (d) {
var nodes = d.items || []; var nodes = d.items || [];
@ -2178,7 +2177,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}, },
hasChecked: function () { hasChecked: function () {
return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments); return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
}, },
getValue: function () { getValue: function () {
@ -2187,20 +2186,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
} }
var checkedValues = this._getSelectedValues(); var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) { if (BI.isEmpty(checkedValues)) {
return BI.deepClone(this.selectedValues); return BI.deepClone(this.options.paras.selectedValues);
} }
if (BI.isEmpty(this.selectedValues)) { if (BI.isEmpty(this.options.paras.selectedValues)) {
return checkedValues; return checkedValues;
} }
return this._join(checkedValues, this.selectedValues); return this._join(checkedValues, this.options.paras.selectedValues);
}, },
//生成树方法 //生成树方法
stroke: function (config) { stroke: function (config) {
delete this.options.keyword; delete this.options.keyword;
BI.extend(this.options.paras, config); BI.extend(this.options.paras, config);
//取消选中时使用
this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {};
var setting = this._configSetting(); var setting = this._configSetting();
this._initTree(setting); this._initTree(setting);
} }
@ -2253,7 +2250,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else { } else {
//如果选中的值中不存在该值不处理 //如果选中的值中不存在该值不处理
var t = this.selectedValues; var t = this.options.paras.selectedValues;
var p = parentValues.concat(name); var p = parentValues.concat(name);
for (var i = 0, len = p.length; i < len; i++) { for (var i = 0, len = p.length; i < len; i++) {
t = t[p[i]]; t = t[p[i]];
@ -2266,11 +2263,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
} }
o.itemsCreator(BI.extend({}, o.paras, { o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_SELECT_DATA, type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name, notSelectedValue: name,
parentValues: parentValues parentValues: parentValues
}), function (new_values) { }), function (new_values) {
self.selectedValues = new_values; self.options.paras.selectedValues = new_values;
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
}); });
} }
@ -2367,9 +2363,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
delete o.paras.keyword; delete o.paras.keyword;
BI.extend(o.paras, config); BI.extend(o.paras, config);
delete o.paras.lastSearchValue; delete o.paras.lastSearchValue;
//取消选中时使用
this.selectedValues = BI.deepClone(o.paras.selectedValues) || {};
//delete this.options.paras.selectedValues;
var setting = this._configSetting(); var setting = this._configSetting();
this._initTree(setting, o.paras.keyword); this._initTree(setting, o.paras.keyword);
} }
@ -2920,7 +2913,7 @@ BI.Combo = BI.inherit(BI.Widget, {
this._initCombo(); this._initCombo();
this._initPullDownAction(); this._initPullDownAction();
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }
@ -2938,12 +2931,12 @@ BI.Combo = BI.inherit(BI.Widget, {
}); });
self.element.on("mouseenter." + self.getName(), function (e) { self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass); self.element.addClass(o.hoverClass);
} }
}); });
self.element.on("mouseleave." + self.getName(), function (e) { self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass); self.element.removeClass(o.hoverClass);
} }
}); });
@ -2990,14 +2983,14 @@ BI.Combo = BI.inherit(BI.Widget, {
switch (ev) { switch (ev) {
case "hover": case "hover":
self.element.on("mouseenter." + self.getName(), function (e) { self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView(); self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND); self.fireEvent(BI.Combo.EVENT_EXPAND);
} }
}); });
self.element.on("mouseleave." + self.getName(), function (e) { self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled() && o.toggle === true) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView(); self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE); self.fireEvent(BI.Combo.EVENT_COLLAPSE);
@ -3007,7 +3000,7 @@ BI.Combo = BI.inherit(BI.Widget, {
case "click": case "click":
var debounce = BI.debounce(function (e) { var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) { if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
o.toggle ? self._toggle() : self._popupView(); o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) { if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -3220,6 +3213,7 @@ BI.Combo = BI.inherit(BI.Widget, {
_setEnable: function (arg) { _setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments); BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView(); !arg && this.isViewVisible() && this._hideView();
}, },
@ -3317,13 +3311,13 @@ BI.Expander = BI.inherit(BI.Widget, {
this._initExpander(); this._initExpander();
this._initPullDownAction(); this._initPullDownAction();
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.EXPAND) { if (self.isEnabled() && self.isValid()) {
self._popupView(); if (type === BI.Events.EXPAND) {
} self._popupView();
if (type === BI.Events.COLLAPSE) { }
self._hideView(); if (type === BI.Events.COLLAPSE) {
} self._hideView();
if (self.isEnabled() && this.isEnabled()) { }
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND); self.fireEvent(BI.Expander.EVENT_EXPAND);
@ -3339,11 +3333,11 @@ BI.Expander = BI.inherit(BI.Widget, {
}); });
this.element.hover(function () { this.element.hover(function () {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.addClass(o.hoverClass); self.element.addClass(o.hoverClass);
} }
}, function () { }, function () {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.removeClass(o.hoverClass); self.element.removeClass(o.hoverClass);
} }
}); });
@ -3379,13 +3373,13 @@ BI.Expander = BI.inherit(BI.Widget, {
switch (e) { switch (e) {
case "hover": case "hover":
self.element[e](function (e) { self.element[e](function (e) {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self._popupView(); self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander);
self.fireEvent(BI.Expander.EVENT_EXPAND); self.fireEvent(BI.Expander.EVENT_EXPAND);
} }
}, function () { }, function () {
if (self.isEnabled() && self.expander.isEnabled() && o.toggle) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
self._hideView(); self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander);
self.fireEvent(BI.Expander.EVENT_COLLAPSE); self.fireEvent(BI.Expander.EVENT_COLLAPSE);
@ -3396,7 +3390,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (e) { if (e) {
self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) { self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
if (self.expander.element.__isMouseInBounds__(e)) { if (self.expander.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
o.toggle ? self._toggle() : self._popupView(); o.toggle ? self._toggle() : self._popupView();
if (self.isExpanded()) { if (self.isExpanded()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
@ -3487,6 +3481,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_setEnable: function (arg) { _setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments); BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView(); !arg && this.isViewVisible() && this._hideView();
}, },
@ -4484,7 +4479,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
this._initSwitcher(); this._initSwitcher();
this._initPullDownAction(); this._initPullDownAction();
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }

32
bi/widget.js

@ -11322,34 +11322,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) { if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()}; self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.adapter.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 //搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = BI.createWidget({
type: "bi.multi_tree_search_pane", type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom", cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () { keywordGetter: function () {
return self.trigger.getKeyword(); return self.searcher.getKeyword();
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword(); op.keyword = self.searcher.getKeyword();
o.itemsCreator(op, callback); o.itemsCreator(op, callback);
} }
}); });
this.searcherPane.setVisible(false); this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({ this.searcher = BI.createWidget({
type: "bi.searcher", type: "bi.searcher",
isAutoSearch: false, isAutoSearch: false,
isAutoSync: false, isAutoSync: false,
onSearch: function (op, callback) { onSearch: function (op, callback) {
callback({ callback({
keyword: self.trigger.getKeyword() keyword: self.searcher.getKeyword()
}); });
}, },
adapter: this.adapter, adapter: this.adapter,
@ -11359,15 +11361,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
eventName: BI.Searcher.EVENT_START, eventName: BI.Searcher.EVENT_START,
action: function () { action: function () {
self._showSearcherPane(); self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()}; // self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setSelectedValue(self.storeValue.value); // self.searcherPane.setSelectedValue(self.storeValue.value);
} }
}, { }, {
eventName: BI.Searcher.EVENT_STOP, eventName: BI.Searcher.EVENT_STOP,
action: function () { action: function () {
self._showAdapter(); self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()}; // self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setSelectedValue(self.storeValue.value); // self.adapter.setSelectedValue(self.storeValue.value);
BI.nextTick(function () { BI.nextTick(function () {
self.adapter.populate(); self.adapter.populate();
}); });
@ -11375,11 +11377,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, { }, {
eventName: BI.Searcher.EVENT_CHANGE, eventName: BI.Searcher.EVENT_CHANGE,
action: function () { action: function () {
if (self.trigger.isSearching()) { if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()}; self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.adapter.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
} }
}, { }, {
@ -11394,7 +11397,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
items: [{ items: [{
el: this.trigger, el: this.searcher,
height: 30 height: 30
}, { }, {
el: this.adapter, el: this.adapter,
@ -11432,7 +11435,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
setSelectedValue: function (v) { setSelectedValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.adapter.setSelectedValue(v); this.adapter.setSelectedValue(v);
this.trigger.setValue({ this.searcherPane.setSelectedValue(v);
this.searcher.setValue({
value: v || {} value: v || {}
}); });
}, },
@ -11444,7 +11448,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, },
stopSearch: function () { stopSearch: function () {
this.trigger.stopSearch(); this.searcher.stopSearch();
}, },
updateValue: function (v) { updateValue: function (v) {
@ -11456,7 +11460,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, },
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.searcher.populate.apply(this.searcher, arguments);
this.adapter.populate.apply(this.adapter, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });

75
docs/base.js

@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this._buildTree(map, path); this._buildTree(map, path);
return; return;
} }
var storeValues = BI.deepClone(this.selectedValues); var storeValues = BI.deepClone(this.options.paras.selectedValues);
var treeNode = this._getTree(storeValues, path); var treeNode = this._getTree(storeValues, path);
this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode);
}, },
@ -1952,8 +1952,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
}, },
setSelectedValue: function (value) { setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {}; this.options.paras.selectedValues = BI.deepClone(value || {});
this.selectedValues = BI.deepClone(value) || {};
}, },
updateValue: function (values, param) { updateValue: function (values, param) {
@ -2105,7 +2104,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) { if (treeNode.checked === true) {
} else { } else {
var tNode = treeNode; var tNode = treeNode;
var pNode = this._getTree(this.selectedValues, parentValues); var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
if (BI.isNotNull(pNode[name])) { if (BI.isNotNull(pNode[name])) {
delete pNode[name]; delete pNode[name];
} }
@ -2113,7 +2112,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
parentValues = parentValues.slice(0, parentValues.length - 1); parentValues = parentValues.slice(0, parentValues.length - 1);
tNode = tNode.getParentNode(); tNode = tNode.getParentNode();
if (tNode != null) { if (tNode != null) {
pNode = this._getTree(this.selectedValues, parentValues); pNode = this._getTree(this.options.paras.selectedValues, parentValues);
name = this._getNodeValue(tNode); name = this._getNodeValue(tNode);
delete pNode[name]; delete pNode[name];
} }
@ -2127,10 +2126,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options; var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
var op = BI.extend({}, o.paras, { var op = BI.extend({}, o.paras, {
"id": treeNode.id, id: treeNode.id,
"times": 1, times: 1,
"parentValues": parentValues.concat(this._getNodeValue(treeNode)), parentValues: parentValues.concat(this._getNodeValue(treeNode)),
"checkState": treeNode.getCheckStatus() checkState: treeNode.getCheckStatus()
}); });
var complete = function (d) { var complete = function (d) {
var nodes = d.items || []; var nodes = d.items || [];
@ -2178,7 +2177,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}, },
hasChecked: function () { hasChecked: function () {
return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments); return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
}, },
getValue: function () { getValue: function () {
@ -2187,20 +2186,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
} }
var checkedValues = this._getSelectedValues(); var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) { if (BI.isEmpty(checkedValues)) {
return BI.deepClone(this.selectedValues); return BI.deepClone(this.options.paras.selectedValues);
} }
if (BI.isEmpty(this.selectedValues)) { if (BI.isEmpty(this.options.paras.selectedValues)) {
return checkedValues; return checkedValues;
} }
return this._join(checkedValues, this.selectedValues); return this._join(checkedValues, this.options.paras.selectedValues);
}, },
//生成树方法 //生成树方法
stroke: function (config) { stroke: function (config) {
delete this.options.keyword; delete this.options.keyword;
BI.extend(this.options.paras, config); BI.extend(this.options.paras, config);
//取消选中时使用
this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {};
var setting = this._configSetting(); var setting = this._configSetting();
this._initTree(setting); this._initTree(setting);
} }
@ -2253,7 +2250,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else { } else {
//如果选中的值中不存在该值不处理 //如果选中的值中不存在该值不处理
var t = this.selectedValues; var t = this.options.paras.selectedValues;
var p = parentValues.concat(name); var p = parentValues.concat(name);
for (var i = 0, len = p.length; i < len; i++) { for (var i = 0, len = p.length; i < len; i++) {
t = t[p[i]]; t = t[p[i]];
@ -2266,11 +2263,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
} }
o.itemsCreator(BI.extend({}, o.paras, { o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_SELECT_DATA, type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name, notSelectedValue: name,
parentValues: parentValues parentValues: parentValues
}), function (new_values) { }), function (new_values) {
self.selectedValues = new_values; self.options.paras.selectedValues = new_values;
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
}); });
} }
@ -2367,9 +2363,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
delete o.paras.keyword; delete o.paras.keyword;
BI.extend(o.paras, config); BI.extend(o.paras, config);
delete o.paras.lastSearchValue; delete o.paras.lastSearchValue;
//取消选中时使用
this.selectedValues = BI.deepClone(o.paras.selectedValues) || {};
//delete this.options.paras.selectedValues;
var setting = this._configSetting(); var setting = this._configSetting();
this._initTree(setting, o.paras.keyword); this._initTree(setting, o.paras.keyword);
} }
@ -2920,7 +2913,7 @@ BI.Combo = BI.inherit(BI.Widget, {
this._initCombo(); this._initCombo();
this._initPullDownAction(); this._initPullDownAction();
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }
@ -2938,12 +2931,12 @@ BI.Combo = BI.inherit(BI.Widget, {
}); });
self.element.on("mouseenter." + self.getName(), function (e) { self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass); self.element.addClass(o.hoverClass);
} }
}); });
self.element.on("mouseleave." + self.getName(), function (e) { self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass); self.element.removeClass(o.hoverClass);
} }
}); });
@ -2990,14 +2983,14 @@ BI.Combo = BI.inherit(BI.Widget, {
switch (ev) { switch (ev) {
case "hover": case "hover":
self.element.on("mouseenter." + self.getName(), function (e) { self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView(); self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND); self.fireEvent(BI.Combo.EVENT_EXPAND);
} }
}); });
self.element.on("mouseleave." + self.getName(), function (e) { self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled() && o.toggle === true) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView(); self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE); self.fireEvent(BI.Combo.EVENT_COLLAPSE);
@ -3007,7 +3000,7 @@ BI.Combo = BI.inherit(BI.Widget, {
case "click": case "click":
var debounce = BI.debounce(function (e) { var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) { if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
o.toggle ? self._toggle() : self._popupView(); o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) { if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -3220,6 +3213,7 @@ BI.Combo = BI.inherit(BI.Widget, {
_setEnable: function (arg) { _setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments); BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView(); !arg && this.isViewVisible() && this._hideView();
}, },
@ -3317,13 +3311,13 @@ BI.Expander = BI.inherit(BI.Widget, {
this._initExpander(); this._initExpander();
this._initPullDownAction(); this._initPullDownAction();
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.EXPAND) { if (self.isEnabled() && self.isValid()) {
self._popupView(); if (type === BI.Events.EXPAND) {
} self._popupView();
if (type === BI.Events.COLLAPSE) { }
self._hideView(); if (type === BI.Events.COLLAPSE) {
} self._hideView();
if (self.isEnabled() && this.isEnabled()) { }
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND); self.fireEvent(BI.Expander.EVENT_EXPAND);
@ -3339,11 +3333,11 @@ BI.Expander = BI.inherit(BI.Widget, {
}); });
this.element.hover(function () { this.element.hover(function () {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.addClass(o.hoverClass); self.element.addClass(o.hoverClass);
} }
}, function () { }, function () {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.removeClass(o.hoverClass); self.element.removeClass(o.hoverClass);
} }
}); });
@ -3379,13 +3373,13 @@ BI.Expander = BI.inherit(BI.Widget, {
switch (e) { switch (e) {
case "hover": case "hover":
self.element[e](function (e) { self.element[e](function (e) {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self._popupView(); self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander);
self.fireEvent(BI.Expander.EVENT_EXPAND); self.fireEvent(BI.Expander.EVENT_EXPAND);
} }
}, function () { }, function () {
if (self.isEnabled() && self.expander.isEnabled() && o.toggle) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
self._hideView(); self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander);
self.fireEvent(BI.Expander.EVENT_COLLAPSE); self.fireEvent(BI.Expander.EVENT_COLLAPSE);
@ -3396,7 +3390,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (e) { if (e) {
self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) { self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
if (self.expander.element.__isMouseInBounds__(e)) { if (self.expander.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
o.toggle ? self._toggle() : self._popupView(); o.toggle ? self._toggle() : self._popupView();
if (self.isExpanded()) { if (self.isExpanded()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
@ -3487,6 +3481,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_setEnable: function (arg) { _setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments); BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView(); !arg && this.isViewVisible() && this._hideView();
}, },
@ -4484,7 +4479,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
this._initSwitcher(); this._initSwitcher();
this._initPullDownAction(); this._initPullDownAction();
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }

32
docs/widget.js

@ -11322,34 +11322,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) { if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()}; self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.adapter.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 //搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = BI.createWidget({
type: "bi.multi_tree_search_pane", type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom", cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () { keywordGetter: function () {
return self.trigger.getKeyword(); return self.searcher.getKeyword();
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword(); op.keyword = self.searcher.getKeyword();
o.itemsCreator(op, callback); o.itemsCreator(op, callback);
} }
}); });
this.searcherPane.setVisible(false); this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({ this.searcher = BI.createWidget({
type: "bi.searcher", type: "bi.searcher",
isAutoSearch: false, isAutoSearch: false,
isAutoSync: false, isAutoSync: false,
onSearch: function (op, callback) { onSearch: function (op, callback) {
callback({ callback({
keyword: self.trigger.getKeyword() keyword: self.searcher.getKeyword()
}); });
}, },
adapter: this.adapter, adapter: this.adapter,
@ -11359,15 +11361,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
eventName: BI.Searcher.EVENT_START, eventName: BI.Searcher.EVENT_START,
action: function () { action: function () {
self._showSearcherPane(); self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()}; // self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setSelectedValue(self.storeValue.value); // self.searcherPane.setSelectedValue(self.storeValue.value);
} }
}, { }, {
eventName: BI.Searcher.EVENT_STOP, eventName: BI.Searcher.EVENT_STOP,
action: function () { action: function () {
self._showAdapter(); self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()}; // self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setSelectedValue(self.storeValue.value); // self.adapter.setSelectedValue(self.storeValue.value);
BI.nextTick(function () { BI.nextTick(function () {
self.adapter.populate(); self.adapter.populate();
}); });
@ -11375,11 +11377,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, { }, {
eventName: BI.Searcher.EVENT_CHANGE, eventName: BI.Searcher.EVENT_CHANGE,
action: function () { action: function () {
if (self.trigger.isSearching()) { if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()}; self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.adapter.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
} }
}, { }, {
@ -11394,7 +11397,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
items: [{ items: [{
el: this.trigger, el: this.searcher,
height: 30 height: 30
}, { }, {
el: this.adapter, el: this.adapter,
@ -11432,7 +11435,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
setSelectedValue: function (v) { setSelectedValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.adapter.setSelectedValue(v); this.adapter.setSelectedValue(v);
this.trigger.setValue({ this.searcherPane.setSelectedValue(v);
this.searcher.setValue({
value: v || {} value: v || {}
}); });
}, },
@ -11444,7 +11448,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, },
stopSearch: function () { stopSearch: function () {
this.trigger.stopSearch(); this.searcher.stopSearch();
}, },
updateValue: function (v) { updateValue: function (v) {
@ -11456,7 +11460,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, },
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.searcher.populate.apply(this.searcher, arguments);
this.adapter.populate.apply(this.adapter, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });

13
src/base/combination/combo.js

@ -34,7 +34,7 @@ BI.Combo = BI.inherit(BI.Widget, {
this._initCombo(); this._initCombo();
this._initPullDownAction(); this._initPullDownAction();
this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }
@ -52,12 +52,12 @@ BI.Combo = BI.inherit(BI.Widget, {
}); });
self.element.on("mouseenter." + self.getName(), function (e) { self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.addClass(o.hoverClass); self.element.addClass(o.hoverClass);
} }
}); });
self.element.on("mouseleave." + self.getName(), function (e) { self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self.element.removeClass(o.hoverClass); self.element.removeClass(o.hoverClass);
} }
}); });
@ -104,14 +104,14 @@ BI.Combo = BI.inherit(BI.Widget, {
switch (ev) { switch (ev) {
case "hover": case "hover":
self.element.on("mouseenter." + self.getName(), function (e) { self.element.on("mouseenter." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
self._popupView(); self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
self.fireEvent(BI.Combo.EVENT_EXPAND); self.fireEvent(BI.Combo.EVENT_EXPAND);
} }
}); });
self.element.on("mouseleave." + self.getName(), function (e) { self.element.on("mouseleave." + self.getName(), function (e) {
if (self.isEnabled() && self.combo.isEnabled() && o.toggle === true) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid() && o.toggle === true) {
self._hideView(); self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo);
self.fireEvent(BI.Combo.EVENT_COLLAPSE); self.fireEvent(BI.Combo.EVENT_COLLAPSE);
@ -121,7 +121,7 @@ BI.Combo = BI.inherit(BI.Widget, {
case "click": case "click":
var debounce = BI.debounce(function (e) { var debounce = BI.debounce(function (e) {
if (self.combo.element.__isMouseInBounds__(e)) { if (self.combo.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.combo.isEnabled()) { if (self.isEnabled() && self.isValid() && self.combo.isEnabled() && self.combo.isValid()) {
o.toggle ? self._toggle() : self._popupView(); o.toggle ? self._toggle() : self._popupView();
if (self.isViewVisible()) { if (self.isViewVisible()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo);
@ -334,6 +334,7 @@ BI.Combo = BI.inherit(BI.Widget, {
_setEnable: function (arg) { _setEnable: function (arg) {
BI.Combo.superclass._setEnable.apply(this, arguments); BI.Combo.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView(); !arg && this.isViewVisible() && this._hideView();
}, },

25
src/base/combination/expander.js

@ -28,13 +28,13 @@ BI.Expander = BI.inherit(BI.Widget, {
this._initExpander(); this._initExpander();
this._initPullDownAction(); this._initPullDownAction();
this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (type === BI.Events.EXPAND) { if (self.isEnabled() && self.isValid()) {
self._popupView(); if (type === BI.Events.EXPAND) {
} self._popupView();
if (type === BI.Events.COLLAPSE) { }
self._hideView(); if (type === BI.Events.COLLAPSE) {
} self._hideView();
if (self.isEnabled() && this.isEnabled()) { }
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
self.fireEvent(BI.Expander.EVENT_EXPAND); self.fireEvent(BI.Expander.EVENT_EXPAND);
@ -50,11 +50,11 @@ BI.Expander = BI.inherit(BI.Widget, {
}); });
this.element.hover(function () { this.element.hover(function () {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.addClass(o.hoverClass); self.element.addClass(o.hoverClass);
} }
}, function () { }, function () {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self.element.removeClass(o.hoverClass); self.element.removeClass(o.hoverClass);
} }
}); });
@ -90,13 +90,13 @@ BI.Expander = BI.inherit(BI.Widget, {
switch (e) { switch (e) {
case "hover": case "hover":
self.element[e](function (e) { self.element[e](function (e) {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
self._popupView(); self._popupView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander);
self.fireEvent(BI.Expander.EVENT_EXPAND); self.fireEvent(BI.Expander.EVENT_EXPAND);
} }
}, function () { }, function () {
if (self.isEnabled() && self.expander.isEnabled() && o.toggle) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid() && o.toggle) {
self._hideView(); self._hideView();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander);
self.fireEvent(BI.Expander.EVENT_COLLAPSE); self.fireEvent(BI.Expander.EVENT_COLLAPSE);
@ -107,7 +107,7 @@ BI.Expander = BI.inherit(BI.Widget, {
if (e) { if (e) {
self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) { self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (e) {
if (self.expander.element.__isMouseInBounds__(e)) { if (self.expander.element.__isMouseInBounds__(e)) {
if (self.isEnabled() && self.expander.isEnabled()) { if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) {
o.toggle ? self._toggle() : self._popupView(); o.toggle ? self._toggle() : self._popupView();
if (self.isExpanded()) { if (self.isExpanded()) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander); self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander);
@ -198,6 +198,7 @@ BI.Expander = BI.inherit(BI.Widget, {
_setEnable: function (arg) { _setEnable: function (arg) {
BI.Expander.superclass._setEnable.apply(this, arguments); BI.Expander.superclass._setEnable.apply(this, arguments);
!arg && this.element.removeClass(this.options.hoverClass);
!arg && this.isViewVisible() && this._hideView(); !arg && this.isViewVisible() && this._hideView();
}, },

2
src/base/combination/switcher.js

@ -28,7 +28,7 @@ BI.Switcher = BI.inherit(BI.Widget, {
this._initSwitcher(); this._initSwitcher();
this._initPullDownAction(); this._initPullDownAction();
this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { this.switcher.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) {
if (self.isEnabled() && this.isEnabled()) { if (self.isEnabled() && self.isValid()) {
if (type === BI.Events.EXPAND) { if (type === BI.Events.EXPAND) {
self._popupView(); self._popupView();
} }

22
src/base/tree/asynctree.js

@ -105,7 +105,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) { if (treeNode.checked === true) {
} else { } else {
var tNode = treeNode; var tNode = treeNode;
var pNode = this._getTree(this.selectedValues, parentValues); var pNode = this._getTree(this.options.paras.selectedValues, parentValues);
if (BI.isNotNull(pNode[name])) { if (BI.isNotNull(pNode[name])) {
delete pNode[name]; delete pNode[name];
} }
@ -113,7 +113,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
parentValues = parentValues.slice(0, parentValues.length - 1); parentValues = parentValues.slice(0, parentValues.length - 1);
tNode = tNode.getParentNode(); tNode = tNode.getParentNode();
if (tNode != null) { if (tNode != null) {
pNode = this._getTree(this.selectedValues, parentValues); pNode = this._getTree(this.options.paras.selectedValues, parentValues);
name = this._getNodeValue(tNode); name = this._getNodeValue(tNode);
delete pNode[name]; delete pNode[name];
} }
@ -127,10 +127,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options; var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
var op = BI.extend({}, o.paras, { var op = BI.extend({}, o.paras, {
"id": treeNode.id, id: treeNode.id,
"times": 1, times: 1,
"parentValues": parentValues.concat(this._getNodeValue(treeNode)), parentValues: parentValues.concat(this._getNodeValue(treeNode)),
"checkState": treeNode.getCheckStatus() checkState: treeNode.getCheckStatus()
}); });
var complete = function (d) { var complete = function (d) {
var nodes = d.items || []; var nodes = d.items || [];
@ -178,7 +178,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}, },
hasChecked: function () { hasChecked: function () {
return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments); return !BI.isEmpty(this.options.paras.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments);
}, },
getValue: function () { getValue: function () {
@ -187,20 +187,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
} }
var checkedValues = this._getSelectedValues(); var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) { if (BI.isEmpty(checkedValues)) {
return BI.deepClone(this.selectedValues); return BI.deepClone(this.options.paras.selectedValues);
} }
if (BI.isEmpty(this.selectedValues)) { if (BI.isEmpty(this.options.paras.selectedValues)) {
return checkedValues; return checkedValues;
} }
return this._join(checkedValues, this.selectedValues); return this._join(checkedValues, this.options.paras.selectedValues);
}, },
//生成树方法 //生成树方法
stroke: function (config) { stroke: function (config) {
delete this.options.keyword; delete this.options.keyword;
BI.extend(this.options.paras, config); BI.extend(this.options.paras, config);
//取消选中时使用
this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {};
var setting = this._configSetting(); var setting = this._configSetting();
this._initTree(setting); this._initTree(setting);
} }

8
src/base/tree/parttree.js

@ -45,7 +45,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else { } else {
//如果选中的值中不存在该值不处理 //如果选中的值中不存在该值不处理
var t = this.selectedValues; var t = this.options.paras.selectedValues;
var p = parentValues.concat(name); var p = parentValues.concat(name);
for (var i = 0, len = p.length; i < len; i++) { for (var i = 0, len = p.length; i < len; i++) {
t = t[p[i]]; t = t[p[i]];
@ -58,11 +58,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
} }
o.itemsCreator(BI.extend({}, o.paras, { o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_SELECT_DATA, type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name, notSelectedValue: name,
parentValues: parentValues parentValues: parentValues
}), function (new_values) { }), function (new_values) {
self.selectedValues = new_values; self.options.paras.selectedValues = new_values;
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
}); });
} }
@ -159,9 +158,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
delete o.paras.keyword; delete o.paras.keyword;
BI.extend(o.paras, config); BI.extend(o.paras, config);
delete o.paras.lastSearchValue; delete o.paras.lastSearchValue;
//取消选中时使用
this.selectedValues = BI.deepClone(o.paras.selectedValues) || {};
//delete this.options.paras.selectedValues;
var setting = this._configSetting(); var setting = this._configSetting();
this._initTree(setting, o.paras.keyword); this._initTree(setting, o.paras.keyword);
} }

5
src/base/tree/treeview.js

@ -241,7 +241,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this._buildTree(map, path); this._buildTree(map, path);
return; return;
} }
var storeValues = BI.deepClone(this.selectedValues); var storeValues = BI.deepClone(this.options.paras.selectedValues);
var treeNode = this._getTree(storeValues, path); var treeNode = this._getTree(storeValues, path);
this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode);
}, },
@ -451,8 +451,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
}, },
setSelectedValue: function (value) { setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {}; this.options.paras.selectedValues = BI.deepClone(value || {});
this.selectedValues = BI.deepClone(value) || {};
}, },
updateValue: function (values, param) { updateValue: function (values, param) {

32
src/widget/multiselecttree/multiselecttree.js

@ -19,34 +19,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
if (self.trigger.isSearching()) { if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()}; self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.adapter.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 //搜索中的时候用的是parttree,同adapter中的synctree不一样
this.searcherPane = BI.createWidget({
type: "bi.multi_tree_search_pane", type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom", cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () { keywordGetter: function () {
return self.trigger.getKeyword(); return self.searcher.getKeyword();
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword(); op.keyword = self.searcher.getKeyword();
o.itemsCreator(op, callback); o.itemsCreator(op, callback);
} }
}); });
this.searcherPane.setVisible(false); this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({ this.searcher = BI.createWidget({
type: "bi.searcher", type: "bi.searcher",
isAutoSearch: false, isAutoSearch: false,
isAutoSync: false, isAutoSync: false,
onSearch: function (op, callback) { onSearch: function (op, callback) {
callback({ callback({
keyword: self.trigger.getKeyword() keyword: self.searcher.getKeyword()
}); });
}, },
adapter: this.adapter, adapter: this.adapter,
@ -56,15 +58,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
eventName: BI.Searcher.EVENT_START, eventName: BI.Searcher.EVENT_START,
action: function () { action: function () {
self._showSearcherPane(); self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()}; // self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setSelectedValue(self.storeValue.value); // self.searcherPane.setSelectedValue(self.storeValue.value);
} }
}, { }, {
eventName: BI.Searcher.EVENT_STOP, eventName: BI.Searcher.EVENT_STOP,
action: function () { action: function () {
self._showAdapter(); self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()}; // self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setSelectedValue(self.storeValue.value); // self.adapter.setSelectedValue(self.storeValue.value);
BI.nextTick(function () { BI.nextTick(function () {
self.adapter.populate(); self.adapter.populate();
}); });
@ -72,11 +74,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, { }, {
eventName: BI.Searcher.EVENT_CHANGE, eventName: BI.Searcher.EVENT_CHANGE,
action: function () { action: function () {
if (self.trigger.isSearching()) { if (self.searcher.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()}; self.storeValue = {value: self.searcherPane.getValue()};
} else { } else {
self.storeValue = {value: self.adapter.getValue()}; self.storeValue = {value: self.adapter.getValue()};
} }
self.setSelectedValue(self.storeValue.value);
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
} }
}, { }, {
@ -91,7 +94,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
items: [{ items: [{
el: this.trigger, el: this.searcher,
height: 30 height: 30
}, { }, {
el: this.adapter, el: this.adapter,
@ -129,7 +132,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
setSelectedValue: function (v) { setSelectedValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.adapter.setSelectedValue(v); this.adapter.setSelectedValue(v);
this.trigger.setValue({ this.searcherPane.setSelectedValue(v);
this.searcher.setValue({
value: v || {} value: v || {}
}); });
}, },
@ -141,7 +145,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, },
stopSearch: function () { stopSearch: function () {
this.trigger.stopSearch(); this.searcher.stopSearch();
}, },
updateValue: function (v) { updateValue: function (v) {
@ -153,7 +157,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
}, },
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.searcher.populate.apply(this.searcher, arguments);
this.adapter.populate.apply(this.adapter, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });

Loading…
Cancel
Save