From 497ee62de95d114b3e0c2d54f5b7b3f06bf05a15 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 24 May 2017 11:49:07 +0800 Subject: [PATCH 01/27] update --- bi/base.js | 15 ++++++++++----- bi/case.js | 4 +--- bi/core.js | 6 ++++++ docs/base.js | 15 ++++++++++----- docs/case.js | 4 +--- docs/core.js | 6 ++++++ src/base/layer/layer.floatbox.js | 15 ++++++++++----- src/case/clipboard/index.js | 4 +--- src/core/ob.js | 6 ++++++ 9 files changed, 51 insertions(+), 24 deletions(-) diff --git a/bi/base.js b/bi/base.js index 9f79c10d1..661427432 100644 --- a/bi/base.js +++ b/bi/base.js @@ -15109,15 +15109,16 @@ BI.FloatBox = BI.inherit(BI.Widget, { populate: function (sectionProvider) { var self = this; + if (this.currentSectionProvider && this.currentSectionProvider !== sectionProvider) { + this.currentSectionProvider.destroy(); + } this.currentSectionProvider = sectionProvider; sectionProvider.rebuildNorth(this._north); sectionProvider.rebuildCenter(this._center); sectionProvider.rebuildSouth(this._south); - if (sectionProvider instanceof BI.Widget) { - sectionProvider.on(BI.PopoverSection.EVENT_CLOSE, function () { - self.close(); - }) - } + sectionProvider.on(BI.PopoverSection.EVENT_CLOSE, function () { + self.close(); + }) }, show: function () { @@ -15140,6 +15141,10 @@ BI.FloatBox = BI.inherit(BI.Widget, { setZindex: function (zindex) { this.element.css({"z-index": zindex}); + }, + + destroyed: function () { + this.currentSectionProvider && this.currentSectionProvider.destroy(); } }); diff --git a/bi/case.js b/bi/case.js index b70256eb6..d98ac5789 100644 --- a/bi/case.js +++ b/bi/case.js @@ -3567,9 +3567,7 @@ BI.ClipBoard = BI.inherit(BI.BasicButton, { return BI.isFunction(o.copy) ? o.copy() : o.copy; } }); - this.clipboard.on("success", function (e) { - o.afterCopy(); - }) + this.clipboard.on("success", o.afterCopy) } else { this.element.zclip({ path: BI.resourceURL + "/ZeroClipboard.swf", diff --git a/bi/core.js b/bi/core.js index 2e88efc9b..e7aa96ebc 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4198,6 +4198,7 @@ BI.OB = function (config) { $.extend(BI.OB.prototype, { props: {}, init: null, + destroyed: null, _defaultConfig: function (config) { return {}; @@ -4317,6 +4318,11 @@ $.extend(BI.OB.prototype, { } } return true; + }, + + destroy: function () { + this.destroyed && this.destroyed(); + this.purgeListeners(); } });/** * Widget超类 diff --git a/docs/base.js b/docs/base.js index 9f79c10d1..661427432 100644 --- a/docs/base.js +++ b/docs/base.js @@ -15109,15 +15109,16 @@ BI.FloatBox = BI.inherit(BI.Widget, { populate: function (sectionProvider) { var self = this; + if (this.currentSectionProvider && this.currentSectionProvider !== sectionProvider) { + this.currentSectionProvider.destroy(); + } this.currentSectionProvider = sectionProvider; sectionProvider.rebuildNorth(this._north); sectionProvider.rebuildCenter(this._center); sectionProvider.rebuildSouth(this._south); - if (sectionProvider instanceof BI.Widget) { - sectionProvider.on(BI.PopoverSection.EVENT_CLOSE, function () { - self.close(); - }) - } + sectionProvider.on(BI.PopoverSection.EVENT_CLOSE, function () { + self.close(); + }) }, show: function () { @@ -15140,6 +15141,10 @@ BI.FloatBox = BI.inherit(BI.Widget, { setZindex: function (zindex) { this.element.css({"z-index": zindex}); + }, + + destroyed: function () { + this.currentSectionProvider && this.currentSectionProvider.destroy(); } }); diff --git a/docs/case.js b/docs/case.js index b70256eb6..d98ac5789 100644 --- a/docs/case.js +++ b/docs/case.js @@ -3567,9 +3567,7 @@ BI.ClipBoard = BI.inherit(BI.BasicButton, { return BI.isFunction(o.copy) ? o.copy() : o.copy; } }); - this.clipboard.on("success", function (e) { - o.afterCopy(); - }) + this.clipboard.on("success", o.afterCopy) } else { this.element.zclip({ path: BI.resourceURL + "/ZeroClipboard.swf", diff --git a/docs/core.js b/docs/core.js index 854962a55..e87cd01c6 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14200,6 +14200,7 @@ BI.OB = function (config) { $.extend(BI.OB.prototype, { props: {}, init: null, + destroyed: null, _defaultConfig: function (config) { return {}; @@ -14319,6 +14320,11 @@ $.extend(BI.OB.prototype, { } } return true; + }, + + destroy: function () { + this.destroyed && this.destroyed(); + this.purgeListeners(); } });/** * Widget超类 diff --git a/src/base/layer/layer.floatbox.js b/src/base/layer/layer.floatbox.js index c015e76eb..8f4b7002a 100644 --- a/src/base/layer/layer.floatbox.js +++ b/src/base/layer/layer.floatbox.js @@ -105,15 +105,16 @@ BI.FloatBox = BI.inherit(BI.Widget, { populate: function (sectionProvider) { var self = this; + if (this.currentSectionProvider && this.currentSectionProvider !== sectionProvider) { + this.currentSectionProvider.destroy(); + } this.currentSectionProvider = sectionProvider; sectionProvider.rebuildNorth(this._north); sectionProvider.rebuildCenter(this._center); sectionProvider.rebuildSouth(this._south); - if (sectionProvider instanceof BI.Widget) { - sectionProvider.on(BI.PopoverSection.EVENT_CLOSE, function () { - self.close(); - }) - } + sectionProvider.on(BI.PopoverSection.EVENT_CLOSE, function () { + self.close(); + }) }, show: function () { @@ -136,6 +137,10 @@ BI.FloatBox = BI.inherit(BI.Widget, { setZindex: function (zindex) { this.element.css({"z-index": zindex}); + }, + + destroyed: function () { + this.currentSectionProvider && this.currentSectionProvider.destroy(); } }); diff --git a/src/case/clipboard/index.js b/src/case/clipboard/index.js index 1b9327d08..314cf2e5e 100644 --- a/src/case/clipboard/index.js +++ b/src/case/clipboard/index.js @@ -25,9 +25,7 @@ BI.ClipBoard = BI.inherit(BI.BasicButton, { return BI.isFunction(o.copy) ? o.copy() : o.copy; } }); - this.clipboard.on("success", function (e) { - o.afterCopy(); - }) + this.clipboard.on("success", o.afterCopy) } else { this.element.zclip({ path: BI.resourceURL + "/ZeroClipboard.swf", diff --git a/src/core/ob.js b/src/core/ob.js index bb71c3874..51848c34f 100644 --- a/src/core/ob.js +++ b/src/core/ob.js @@ -15,6 +15,7 @@ BI.OB = function (config) { $.extend(BI.OB.prototype, { props: {}, init: null, + destroyed: null, _defaultConfig: function (config) { return {}; @@ -134,5 +135,10 @@ $.extend(BI.OB.prototype, { } } return true; + }, + + destroy: function () { + this.destroyed && this.destroyed(); + this.purgeListeners(); } }); \ No newline at end of file From a33e3c90ee971060de5a6531b5d943b9bd065c3c Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 24 May 2017 16:39:53 +0800 Subject: [PATCH 02/27] add --- bi/base.js | 10 +++++----- docs/base.js | 10 +++++----- src/base/table/table.grid.js | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bi/base.js b/bi/base.js index 661427432..a530305ce 100644 --- a/bi/base.js +++ b/bi/base.js @@ -29684,7 +29684,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.topLeftGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnLeftWidthGetter, + columnWidthGetter: columnLeftWidthGetter }); this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); @@ -29694,7 +29694,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.topRightGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnRightWidthGetter, + columnWidthGetter: columnRightWidthGetter }); this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); @@ -29704,7 +29704,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomLeftGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnLeftWidthGetter, + columnWidthGetter: columnLeftWidthGetter }); this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); @@ -29715,7 +29715,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnRightWidthGetter, + columnWidthGetter: columnRightWidthGetter }); this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); @@ -29803,7 +29803,7 @@ BI.GridTable = BI.inherit(BI.Widget, { el: this.leftScrollbar, left: 0 }, { - el: this.rightScrollbar, + el: this.rightScrollbar }] }); this._width = o.width - BI.GridTableScrollbar.SIZE; diff --git a/docs/base.js b/docs/base.js index 661427432..a530305ce 100644 --- a/docs/base.js +++ b/docs/base.js @@ -29684,7 +29684,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.topLeftGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnLeftWidthGetter, + columnWidthGetter: columnLeftWidthGetter }); this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); @@ -29694,7 +29694,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.topRightGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnRightWidthGetter, + columnWidthGetter: columnRightWidthGetter }); this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); @@ -29704,7 +29704,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomLeftGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnLeftWidthGetter, + columnWidthGetter: columnLeftWidthGetter }); this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); @@ -29715,7 +29715,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnRightWidthGetter, + columnWidthGetter: columnRightWidthGetter }); this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); @@ -29803,7 +29803,7 @@ BI.GridTable = BI.inherit(BI.Widget, { el: this.leftScrollbar, left: 0 }, { - el: this.rightScrollbar, + el: this.rightScrollbar }] }); this._width = o.width - BI.GridTableScrollbar.SIZE; diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 7454fafd2..155b5b614 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -37,7 +37,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.topLeftGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnLeftWidthGetter, + columnWidthGetter: columnLeftWidthGetter }); this.topLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollLeft(scroll.scrollLeft); @@ -47,7 +47,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.topRightGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnRightWidthGetter, + columnWidthGetter: columnRightWidthGetter }); this.topRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollLeft(scroll.scrollLeft); @@ -57,7 +57,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomLeftGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnLeftWidthGetter, + columnWidthGetter: columnLeftWidthGetter }); this.bottomLeftGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomRightGrid.setScrollTop(scroll.scrollTop); @@ -68,7 +68,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid = BI.createWidget({ type: "bi.grid_view", rowHeightGetter: rowHeightGetter, - columnWidthGetter: columnRightWidthGetter, + columnWidthGetter: columnRightWidthGetter }); this.bottomRightGrid.on(BI.GridView.EVENT_SCROLL, function (scroll) { self.bottomLeftGrid.setScrollTop(scroll.scrollTop); @@ -156,7 +156,7 @@ BI.GridTable = BI.inherit(BI.Widget, { el: this.leftScrollbar, left: 0 }, { - el: this.rightScrollbar, + el: this.rightScrollbar }] }); this._width = o.width - BI.GridTableScrollbar.SIZE; From 6931210b24fd04a01b0e1b29795181b2ede53a68 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 24 May 2017 19:51:15 +0800 Subject: [PATCH 03/27] =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=B8=8Bbubblecombo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.css | 4 ++++ docs/base.css | 4 ++++ src/css/base/combo/combo.bubble.css | 4 ++++ src/less/base/combo/combo.bubble.less | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/bi/base.css b/bi/base.css index 1ced609f6..8270c9fb0 100644 --- a/bi/base.css +++ b/bi/base.css @@ -33,6 +33,7 @@ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ .bi-bubble-combo .bubble-combo-triangle-left { + z-index: 1; width: 0; height: 0; border-top: 6px solid transparent; @@ -40,6 +41,7 @@ border-bottom: 6px solid transparent; } .bi-bubble-combo .bubble-combo-triangle-right { + z-index: 1; width: 0; height: 0; border-top: 6px solid transparent; @@ -47,6 +49,7 @@ border-bottom: 6px solid transparent; } .bi-bubble-combo .bubble-combo-triangle-top { + z-index: 1; width: 0; height: 0; border-left: 6px solid transparent; @@ -54,6 +57,7 @@ border-top: 6px solid #3f8ce8; } .bi-bubble-combo .bubble-combo-triangle-bottom { + z-index: 1; width: 0; height: 0; border-left: 6px solid transparent; diff --git a/docs/base.css b/docs/base.css index 1ced609f6..8270c9fb0 100644 --- a/docs/base.css +++ b/docs/base.css @@ -33,6 +33,7 @@ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ .bi-bubble-combo .bubble-combo-triangle-left { + z-index: 1; width: 0; height: 0; border-top: 6px solid transparent; @@ -40,6 +41,7 @@ border-bottom: 6px solid transparent; } .bi-bubble-combo .bubble-combo-triangle-right { + z-index: 1; width: 0; height: 0; border-top: 6px solid transparent; @@ -47,6 +49,7 @@ border-bottom: 6px solid transparent; } .bi-bubble-combo .bubble-combo-triangle-top { + z-index: 1; width: 0; height: 0; border-left: 6px solid transparent; @@ -54,6 +57,7 @@ border-top: 6px solid #3f8ce8; } .bi-bubble-combo .bubble-combo-triangle-bottom { + z-index: 1; width: 0; height: 0; border-left: 6px solid transparent; diff --git a/src/css/base/combo/combo.bubble.css b/src/css/base/combo/combo.bubble.css index 88aaf0f0e..b2c553173 100644 --- a/src/css/base/combo/combo.bubble.css +++ b/src/css/base/combo/combo.bubble.css @@ -2,6 +2,7 @@ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ .bi-bubble-combo .bubble-combo-triangle-left { + z-index: 1; width: 0; height: 0; border-top: 6px solid transparent; @@ -9,6 +10,7 @@ border-bottom: 6px solid transparent; } .bi-bubble-combo .bubble-combo-triangle-right { + z-index: 1; width: 0; height: 0; border-top: 6px solid transparent; @@ -16,6 +18,7 @@ border-bottom: 6px solid transparent; } .bi-bubble-combo .bubble-combo-triangle-top { + z-index: 1; width: 0; height: 0; border-left: 6px solid transparent; @@ -23,6 +26,7 @@ border-top: 6px solid #3f8ce8; } .bi-bubble-combo .bubble-combo-triangle-bottom { + z-index: 1; width: 0; height: 0; border-left: 6px solid transparent; diff --git a/src/less/base/combo/combo.bubble.less b/src/less/base/combo/combo.bubble.less index 8eac71cea..fdca54079 100644 --- a/src/less/base/combo/combo.bubble.less +++ b/src/less/base/combo/combo.bubble.less @@ -2,15 +2,19 @@ .bi-bubble-combo { & .bubble-combo-triangle-left { + z-index: 1; .solid-triangle-right(@color-bi-background-highlight); } & .bubble-combo-triangle-right { + z-index: 1; .solid-triangle-left(@color-bi-background-highlight); } & .bubble-combo-triangle-top { + z-index: 1; .solid-triangle-down(@color-bi-background-highlight); } & .bubble-combo-triangle-bottom { + z-index: 1; .solid-triangle-up(@color-bi-background-highlight); } } \ No newline at end of file From f6a34733560b2084e9871cfa4e4e3aec92286bf3 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 25 May 2017 01:47:16 +0800 Subject: [PATCH 04/27] add --- bi/core.js | 35 +++++++++++++++++++++-------------- docs/core.js | 35 +++++++++++++++++++++-------------- src/core/model.js | 9 +++++++-- src/core/mvc/fbi.js | 7 ++----- src/core/view.js | 19 ++++++++++++------- 5 files changed, 63 insertions(+), 42 deletions(-) diff --git a/bi/core.js b/bi/core.js index e7aa96ebc..75319bb31 100644 --- a/bi/core.js +++ b/bi/core.js @@ -351,12 +351,9 @@ BI.Factory = { return {} }, - init: function () { - }, // _init is an empty function by default. Override it with your own // initialization logic. _init: function () { - this.init(); }, // Return a copy of the model's `attributes` object. @@ -1204,9 +1201,9 @@ BI.Factory = { setVisible: function (visible) { this.options.invisible = !visible; if (visible) { - this.element.show(); + this.element.css("display", ""); } else { - this.element.hide(); + this.element.css("display", "none"); } }, @@ -4750,11 +4747,15 @@ BI.Widget = BI.inherit(BI.OB, { this.purgeListeners(); } });BI.Model = BI.inherit(BI.M, { + props: {}, + init: null, + destroyed: null, + _defaultConfig: function () { - return { + return BI.extend({ "default": "just a default", "current": void 0 - } + }, this.props) }, _static: function () { @@ -4788,6 +4789,7 @@ BI.Widget = BI.inherit(BI.OB, { this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30); this._F = []; + this.init && this.init(); }, toJSON: function () { @@ -5230,8 +5232,16 @@ BI.Widget = BI.inherit(BI.OB, { */ BI.View = BI.inherit(BI.V, { + //生命周期函数 + beforeCreate: null, + + created: null, + + destroyed: null, + _init: function () { BI.View.superclass._init.apply(this, arguments); + this.beforeCreate && this.beforeCreate(); var self = this; this.listenTo(this.model, "change:current", function (obj, val) { if (BI.isNotNull(val) && val.length > 0) { @@ -5275,7 +5285,8 @@ BI.View = BI.inherit(BI.V, { return f.apply(this, arguments); }, self); } - }) + }); + this.created && this.created(); }, change: function (changed, prev) { @@ -5720,7 +5731,7 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.off(); }, @@ -5730,14 +5741,10 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.remove(); this.trigger(BI.Events.DESTROY); this.off(); - }, - - destroyed: function () { - } });(function () { diff --git a/docs/core.js b/docs/core.js index e87cd01c6..ddbf75f1a 100644 --- a/docs/core.js +++ b/docs/core.js @@ -11493,12 +11493,9 @@ BI.Factory = { return {} }, - init: function () { - }, // _init is an empty function by default. Override it with your own // initialization logic. _init: function () { - this.init(); }, // Return a copy of the model's `attributes` object. @@ -12346,9 +12343,9 @@ BI.Factory = { setVisible: function (visible) { this.options.invisible = !visible; if (visible) { - this.element.show(); + this.element.css("display", ""); } else { - this.element.hide(); + this.element.css("display", "none"); } }, @@ -14752,11 +14749,15 @@ BI.Widget = BI.inherit(BI.OB, { this.purgeListeners(); } });BI.Model = BI.inherit(BI.M, { + props: {}, + init: null, + destroyed: null, + _defaultConfig: function () { - return { + return BI.extend({ "default": "just a default", "current": void 0 - } + }, this.props) }, _static: function () { @@ -14790,6 +14791,7 @@ BI.Widget = BI.inherit(BI.OB, { this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30); this._F = []; + this.init && this.init(); }, toJSON: function () { @@ -15232,8 +15234,16 @@ BI.Widget = BI.inherit(BI.OB, { */ BI.View = BI.inherit(BI.V, { + //生命周期函数 + beforeCreate: null, + + created: null, + + destroyed: null, + _init: function () { BI.View.superclass._init.apply(this, arguments); + this.beforeCreate && this.beforeCreate(); var self = this; this.listenTo(this.model, "change:current", function (obj, val) { if (BI.isNotNull(val) && val.length > 0) { @@ -15277,7 +15287,8 @@ BI.View = BI.inherit(BI.V, { return f.apply(this, arguments); }, self); } - }) + }); + this.created && this.created(); }, change: function (changed, prev) { @@ -15722,7 +15733,7 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.off(); }, @@ -15732,14 +15743,10 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.remove(); this.trigger(BI.Events.DESTROY); this.off(); - }, - - destroyed: function () { - } });(function () { diff --git a/src/core/model.js b/src/core/model.js index 7c8ced029..a45cfb5e1 100644 --- a/src/core/model.js +++ b/src/core/model.js @@ -1,9 +1,13 @@ BI.Model = BI.inherit(BI.M, { + props: {}, + init: null, + destroyed: null, + _defaultConfig: function () { - return { + return BI.extend({ "default": "just a default", "current": void 0 - } + }, this.props) }, _static: function () { @@ -37,6 +41,7 @@ BI.Model = BI.inherit(BI.M, { this._read = BI.debounce(BI.bind(this.fetch, this), 30); this._save = BI.debounce(BI.bind(this.save, this), 30); this._F = []; + this.init && this.init(); }, toJSON: function () { diff --git a/src/core/mvc/fbi.js b/src/core/mvc/fbi.js index a00ec13c7..948b2b143 100644 --- a/src/core/mvc/fbi.js +++ b/src/core/mvc/fbi.js @@ -300,12 +300,9 @@ return {} }, - init: function () { - }, // _init is an empty function by default. Override it with your own // initialization logic. _init: function () { - this.init(); }, // Return a copy of the model's `attributes` object. @@ -1153,9 +1150,9 @@ setVisible: function (visible) { this.options.invisible = !visible; if (visible) { - this.element.show(); + this.element.css("display", ""); } else { - this.element.hide(); + this.element.css("display", "none"); } }, diff --git a/src/core/view.js b/src/core/view.js index f5e5f2311..5912819cd 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -5,8 +5,16 @@ */ BI.View = BI.inherit(BI.V, { + //生命周期函数 + beforeCreate: null, + + created: null, + + destroyed: null, + _init: function () { BI.View.superclass._init.apply(this, arguments); + this.beforeCreate && this.beforeCreate(); var self = this; this.listenTo(this.model, "change:current", function (obj, val) { if (BI.isNotNull(val) && val.length > 0) { @@ -50,7 +58,8 @@ BI.View = BI.inherit(BI.V, { return f.apply(this, arguments); }, self); } - }) + }); + this.created && this.created(); }, change: function (changed, prev) { @@ -495,7 +504,7 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.off(); }, @@ -505,13 +514,9 @@ BI.View = BI.inherit(BI.V, { }); delete this._cardLayouts; delete this._cards; - this.destroyed(); + this.destroyed && this.destroyed(); this.remove(); this.trigger(BI.Events.DESTROY); this.off(); - }, - - destroyed: function () { - } }); \ No newline at end of file From 0eb6aab991f035477fb6bb9a30a8393f0c021882 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 25 May 2017 10:54:18 +0800 Subject: [PATCH 05/27] add --- src/less/lib/constant.less | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/less/lib/constant.less b/src/less/lib/constant.less index 81c5fa713..77b403fb1 100644 --- a/src/less/lib/constant.less +++ b/src/less/lib/constant.less @@ -26,10 +26,9 @@ @font-color-white: #ffffff;// @font-color-highlight: #3f8ce8; @font-color-success: #0c6d23; -@font-color-warning: #e85050; -@font-color-light-gray: #7f7f7f; -@font-color-redmark: #f07d0a; -@font-color-orange: #fcc550; +@font-color-warning: #e85050;// +@font-color-redmark: #f07d0a;// +@font-color-orange: #fbb03b;// //background color @background-color-black: #1a1a1a;// From eed14a4d765ee3be82d5019a595e1ab832453a5d Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 26 May 2017 14:20:24 +0800 Subject: [PATCH 06/27] update --- bi/base.css | 3 ++ bi/base.js | 9 +++++- bi/case.js | 32 +++++++++++++--------- docs/base.css | 3 ++ docs/base.js | 9 +++++- docs/case.js | 32 +++++++++++++--------- src/base/combination/combo.js | 9 +++++- src/case/combo/bubblecombo/combo.bubble.js | 32 +++++++++++++--------- src/css/base/combo/combo.bubble.css | 3 ++ src/less/base/combo/combo.bubble.less | 3 ++ 10 files changed, 93 insertions(+), 42 deletions(-) diff --git a/bi/base.css b/bi/base.css index 8270c9fb0..b9ac8ced1 100644 --- a/bi/base.css +++ b/bi/base.css @@ -32,6 +32,9 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ +.bi-bubble-combo .button-combo-triangle-wrapper { + position: fixed !important; +} .bi-bubble-combo .bubble-combo-triangle-left { z-index: 1; width: 0; diff --git a/bi/base.js b/bi/base.js index a530305ce..f3bc308c3 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2903,6 +2903,7 @@ BI.Combo = BI.inherit(BI.Widget, { toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right isDefaultInit: false, + destroyWhenHide: false, isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustWidth: true, stopEvent: false, @@ -3088,7 +3089,13 @@ BI.Combo = BI.inherit(BI.Widget, { _hideView: function () { this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); - this.popupView && this.popupView.invisible(); + if (this.options.destroyWhenHide === true) { + this.popupView && this.popupView.destroy(); + this.popupView = null; + this._rendered = false; + } else { + this.popupView && this.popupView.invisible(); + } this.element.removeClass(this.options.comboClass); $(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); diff --git a/bi/case.js b/bi/case.js index d98ac5789..5287d3f57 100644 --- a/bi/case.js +++ b/bi/case.js @@ -4761,6 +4761,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right isDefaultInit: false, + destroyWhenHide: false, isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustWidth: true, stopPropagation: false, @@ -4783,6 +4784,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { toggle: o.toggle, direction: o.direction, isDefaultInit: o.isDefaultInit, + destroyWhenHide: o.destroyWhenHide, isNeedAdjustHeight: o.isNeedAdjustHeight, isNeedAdjustWidth: o.isNeedAdjustWidth, adjustLength: this._getAdjustLength(), @@ -4833,37 +4835,40 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _createTriangle: function (direction) { var pos = {}, op = {}; - var adjustLength = this._getAdjustLength(); + var adjustLength = this.options.adjustLength; + var offset = this.element.offset(); + var left = offset.left, right = offset.left + this.element.outerWidth(); + var top = offset.top, bottom = offset.top + this.element.outerHeight(); switch (direction) { case "left": pos = { - top: 0, - bottom: 0, - left: -adjustLength + top: top, + height: this.element.outerHeight(), + left: left - adjustLength - this._const.TRIANGLE_LENGTH }; op = {width: this._const.TRIANGLE_LENGTH}; break; case "right": pos = { - top: 0, - bottom: 0, - right: -adjustLength + top: top, + height: this.element.outerHeight(), + left: right + adjustLength }; op = {width: this._const.TRIANGLE_LENGTH}; break; case "top": pos = { - left: 0, - right: 0, - top: -adjustLength + left: left, + width: this.element.outerWidth(), + top: top - adjustLength - this._const.TRIANGLE_LENGTH }; op = {height: this._const.TRIANGLE_LENGTH}; break; case "bottom": pos = { - left: 0, - right: 0, - bottom: -adjustLength + left: left, + width: this.element.outerWidth(), + top: bottom + adjustLength }; op = {height: this._const.TRIANGLE_LENGTH}; break; @@ -4872,6 +4877,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { } this.triangle = BI.createWidget(op, { type: "bi.center_adapt", + cls: "button-combo-triangle-wrapper", items: [{ type: "bi.layout", cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" diff --git a/docs/base.css b/docs/base.css index 8270c9fb0..b9ac8ced1 100644 --- a/docs/base.css +++ b/docs/base.css @@ -32,6 +32,9 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ +.bi-bubble-combo .button-combo-triangle-wrapper { + position: fixed !important; +} .bi-bubble-combo .bubble-combo-triangle-left { z-index: 1; width: 0; diff --git a/docs/base.js b/docs/base.js index a530305ce..f3bc308c3 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2903,6 +2903,7 @@ BI.Combo = BI.inherit(BI.Widget, { toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right isDefaultInit: false, + destroyWhenHide: false, isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustWidth: true, stopEvent: false, @@ -3088,7 +3089,13 @@ BI.Combo = BI.inherit(BI.Widget, { _hideView: function () { this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); - this.popupView && this.popupView.invisible(); + if (this.options.destroyWhenHide === true) { + this.popupView && this.popupView.destroy(); + this.popupView = null; + this._rendered = false; + } else { + this.popupView && this.popupView.invisible(); + } this.element.removeClass(this.options.comboClass); $(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); diff --git a/docs/case.js b/docs/case.js index d98ac5789..5287d3f57 100644 --- a/docs/case.js +++ b/docs/case.js @@ -4761,6 +4761,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right isDefaultInit: false, + destroyWhenHide: false, isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustWidth: true, stopPropagation: false, @@ -4783,6 +4784,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { toggle: o.toggle, direction: o.direction, isDefaultInit: o.isDefaultInit, + destroyWhenHide: o.destroyWhenHide, isNeedAdjustHeight: o.isNeedAdjustHeight, isNeedAdjustWidth: o.isNeedAdjustWidth, adjustLength: this._getAdjustLength(), @@ -4833,37 +4835,40 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _createTriangle: function (direction) { var pos = {}, op = {}; - var adjustLength = this._getAdjustLength(); + var adjustLength = this.options.adjustLength; + var offset = this.element.offset(); + var left = offset.left, right = offset.left + this.element.outerWidth(); + var top = offset.top, bottom = offset.top + this.element.outerHeight(); switch (direction) { case "left": pos = { - top: 0, - bottom: 0, - left: -adjustLength + top: top, + height: this.element.outerHeight(), + left: left - adjustLength - this._const.TRIANGLE_LENGTH }; op = {width: this._const.TRIANGLE_LENGTH}; break; case "right": pos = { - top: 0, - bottom: 0, - right: -adjustLength + top: top, + height: this.element.outerHeight(), + left: right + adjustLength }; op = {width: this._const.TRIANGLE_LENGTH}; break; case "top": pos = { - left: 0, - right: 0, - top: -adjustLength + left: left, + width: this.element.outerWidth(), + top: top - adjustLength - this._const.TRIANGLE_LENGTH }; op = {height: this._const.TRIANGLE_LENGTH}; break; case "bottom": pos = { - left: 0, - right: 0, - bottom: -adjustLength + left: left, + width: this.element.outerWidth(), + top: bottom + adjustLength }; op = {height: this._const.TRIANGLE_LENGTH}; break; @@ -4872,6 +4877,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { } this.triangle = BI.createWidget(op, { type: "bi.center_adapt", + cls: "button-combo-triangle-wrapper", items: [{ type: "bi.layout", cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 7a43f7070..373fbf6ff 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -11,6 +11,7 @@ BI.Combo = BI.inherit(BI.Widget, { toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right isDefaultInit: false, + destroyWhenHide: false, isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustWidth: true, stopEvent: false, @@ -196,7 +197,13 @@ BI.Combo = BI.inherit(BI.Widget, { _hideView: function () { this.fireEvent(BI.Combo.EVENT_BEFORE_HIDEVIEW); - this.popupView && this.popupView.invisible(); + if (this.options.destroyWhenHide === true) { + this.popupView && this.popupView.destroy(); + this.popupView = null; + this._rendered = false; + } else { + this.popupView && this.popupView.invisible(); + } this.element.removeClass(this.options.comboClass); $(document).unbind("mousedown." + this.getName()).unbind("mousewheel." + this.getName()); diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 8801475f2..0ff96ae37 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -15,6 +15,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { toggle: true, direction: "bottom", //top||bottom||left||right||top,left||top,right||bottom,left||bottom,right isDefaultInit: false, + destroyWhenHide: false, isNeedAdjustHeight: true,//是否需要高度调整 isNeedAdjustWidth: true, stopPropagation: false, @@ -37,6 +38,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { toggle: o.toggle, direction: o.direction, isDefaultInit: o.isDefaultInit, + destroyWhenHide: o.destroyWhenHide, isNeedAdjustHeight: o.isNeedAdjustHeight, isNeedAdjustWidth: o.isNeedAdjustWidth, adjustLength: this._getAdjustLength(), @@ -87,37 +89,40 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _createTriangle: function (direction) { var pos = {}, op = {}; - var adjustLength = this._getAdjustLength(); + var adjustLength = this.options.adjustLength; + var offset = this.element.offset(); + var left = offset.left, right = offset.left + this.element.outerWidth(); + var top = offset.top, bottom = offset.top + this.element.outerHeight(); switch (direction) { case "left": pos = { - top: 0, - bottom: 0, - left: -adjustLength + top: top, + height: this.element.outerHeight(), + left: left - adjustLength - this._const.TRIANGLE_LENGTH }; op = {width: this._const.TRIANGLE_LENGTH}; break; case "right": pos = { - top: 0, - bottom: 0, - right: -adjustLength + top: top, + height: this.element.outerHeight(), + left: right + adjustLength }; op = {width: this._const.TRIANGLE_LENGTH}; break; case "top": pos = { - left: 0, - right: 0, - top: -adjustLength + left: left, + width: this.element.outerWidth(), + top: top - adjustLength - this._const.TRIANGLE_LENGTH }; op = {height: this._const.TRIANGLE_LENGTH}; break; case "bottom": pos = { - left: 0, - right: 0, - bottom: -adjustLength + left: left, + width: this.element.outerWidth(), + top: bottom + adjustLength }; op = {height: this._const.TRIANGLE_LENGTH}; break; @@ -126,6 +131,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { } this.triangle = BI.createWidget(op, { type: "bi.center_adapt", + cls: "button-combo-triangle-wrapper", items: [{ type: "bi.layout", cls: "bubble-combo-triangle-" + direction + " bi-high-light-border" diff --git a/src/css/base/combo/combo.bubble.css b/src/css/base/combo/combo.bubble.css index b2c553173..bb4e3c4db 100644 --- a/src/css/base/combo/combo.bubble.css +++ b/src/css/base/combo/combo.bubble.css @@ -1,6 +1,9 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ +.bi-bubble-combo .button-combo-triangle-wrapper { + position: fixed !important; +} .bi-bubble-combo .bubble-combo-triangle-left { z-index: 1; width: 0; diff --git a/src/less/base/combo/combo.bubble.less b/src/less/base/combo/combo.bubble.less index fdca54079..da74aef0c 100644 --- a/src/less/base/combo/combo.bubble.less +++ b/src/less/base/combo/combo.bubble.less @@ -1,6 +1,9 @@ @import "../../bibase"; .bi-bubble-combo { + & .button-combo-triangle-wrapper { + position: fixed !important; + } & .bubble-combo-triangle-left { z-index: 1; .solid-triangle-right(@color-bi-background-highlight); From afc184b671cc1abf3bf9e2c7a8fa35dc46cb8d3e Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 26 May 2017 14:39:00 +0800 Subject: [PATCH 07/27] add --- bi/base.js | 2 +- docs/base.js | 2 +- src/base/single/tip/tip.bubble.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bi/base.js b/bi/base.js index f3bc308c3..f93fa5363 100644 --- a/bi/base.js +++ b/bi/base.js @@ -20075,7 +20075,7 @@ BI.Bubble = BI.inherit(BI.Tip, { _right: function(){ return BI.createWidget({ - type: "bi.inline", + type: "bi.left", items: [{ el: { type: "bi.layout", diff --git a/docs/base.js b/docs/base.js index f3bc308c3..f93fa5363 100644 --- a/docs/base.js +++ b/docs/base.js @@ -20075,7 +20075,7 @@ BI.Bubble = BI.inherit(BI.Tip, { _right: function(){ return BI.createWidget({ - type: "bi.inline", + type: "bi.left", items: [{ el: { type: "bi.layout", diff --git a/src/base/single/tip/tip.bubble.js b/src/base/single/tip/tip.bubble.js index 715d60231..425578a00 100644 --- a/src/base/single/tip/tip.bubble.js +++ b/src/base/single/tip/tip.bubble.js @@ -86,7 +86,7 @@ BI.Bubble = BI.inherit(BI.Tip, { _right: function(){ return BI.createWidget({ - type: "bi.inline", + type: "bi.left", items: [{ el: { type: "bi.layout", From 885bc8a7166f625a98935666b07f865fd55c9df8 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 26 May 2017 16:18:13 +0800 Subject: [PATCH 08/27] add --- bi/case.js | 2 +- bi/widget.js | 2 +- docs/case.js | 2 +- docs/widget.js | 2 +- src/case/combo/bubblecombo/combo.bubble.js | 2 +- src/widget/arrangement/arrangement.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bi/case.js b/bi/case.js index 5287d3f57..255c3bf16 100644 --- a/bi/case.js +++ b/bi/case.js @@ -4935,7 +4935,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _hideTriangle: function () { this.triangle && this.triangle.destroy(); - this.combo.getView().hideLine(); + this.combo.getView() && this.combo.getView().hideLine(); }, hideView: function () { diff --git a/bi/widget.js b/bi/widget.js index 37afe2e44..ae412aba1 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -3742,7 +3742,7 @@ BI.Arrangement = BI.inherit(BI.Widget, { case BI.Arrangement.LAYOUT_TYPE.ADAPTIVE: if (this._isArrangeFine()) { var width = this.getClientWidth(), height = this.getClientHeight(); - var isHeightAdjust = height > occupied.top + occupied.height; + var isHeightAdjust = height > occupied.height; var regions = this._cloneRegion(); BI.each(regions, function (i, region) { region.width = region.width / occupied.width * width; diff --git a/docs/case.js b/docs/case.js index 5287d3f57..255c3bf16 100644 --- a/docs/case.js +++ b/docs/case.js @@ -4935,7 +4935,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _hideTriangle: function () { this.triangle && this.triangle.destroy(); - this.combo.getView().hideLine(); + this.combo.getView() && this.combo.getView().hideLine(); }, hideView: function () { diff --git a/docs/widget.js b/docs/widget.js index 37afe2e44..ae412aba1 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -3742,7 +3742,7 @@ BI.Arrangement = BI.inherit(BI.Widget, { case BI.Arrangement.LAYOUT_TYPE.ADAPTIVE: if (this._isArrangeFine()) { var width = this.getClientWidth(), height = this.getClientHeight(); - var isHeightAdjust = height > occupied.top + occupied.height; + var isHeightAdjust = height > occupied.height; var regions = this._cloneRegion(); BI.each(regions, function (i, region) { region.width = region.width / occupied.width * width; diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 0ff96ae37..55fcd60d3 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -189,7 +189,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { _hideTriangle: function () { this.triangle && this.triangle.destroy(); - this.combo.getView().hideLine(); + this.combo.getView() && this.combo.getView().hideLine(); }, hideView: function () { diff --git a/src/widget/arrangement/arrangement.js b/src/widget/arrangement/arrangement.js index a4fbcba47..8bedd4259 100644 --- a/src/widget/arrangement/arrangement.js +++ b/src/widget/arrangement/arrangement.js @@ -2752,7 +2752,7 @@ BI.Arrangement = BI.inherit(BI.Widget, { case BI.Arrangement.LAYOUT_TYPE.ADAPTIVE: if (this._isArrangeFine()) { var width = this.getClientWidth(), height = this.getClientHeight(); - var isHeightAdjust = height > occupied.top + occupied.height; + var isHeightAdjust = height > occupied.height; var regions = this._cloneRegion(); BI.each(regions, function (i, region) { region.width = region.width / occupied.width * width; From ed25fbb9e4510bfb9e7bf9e8a48682804b00abce Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 26 May 2017 17:02:06 +0800 Subject: [PATCH 09/27] update --- bi/base.js | 2 +- bi/widget.js | 4 ++++ docs/base.js | 2 +- docs/widget.js | 4 ++++ src/base/table/table.collection.cell.js | 2 +- src/widget/downlist/combo.downlist.js | 4 ++++ 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bi/base.js b/bi/base.js index f93fa5363..b92b70061 100644 --- a/bi/base.js +++ b/bi/base.js @@ -28841,7 +28841,7 @@ BI.CollectionTableCell = BI.inherit(BI.Widget, { this.cell = BI.createWidget(BI.extend({ type: "bi.label" }, o.cell, { - cls: (o.cell.cls || "") + "collection-table-cell-wrapper", + cls: (o.cell.cls || "") + " collection-table-cell-wrapper", width: o.width - (o._left === 0 ? 1 : 0) - 1, height: o.height - (o._top === 0 ? 1 : 0) - 1 })); diff --git a/bi/widget.js b/bi/widget.js index ae412aba1..14511955e 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -5638,6 +5638,10 @@ BI.DownListCombo = BI.inherit(BI.Widget, { }); }, + hideView: function () { + this.downlistcombo.hideView(); + }, + populate: function (items) { this.popupview.populate(items); }, diff --git a/docs/base.js b/docs/base.js index f93fa5363..b92b70061 100644 --- a/docs/base.js +++ b/docs/base.js @@ -28841,7 +28841,7 @@ BI.CollectionTableCell = BI.inherit(BI.Widget, { this.cell = BI.createWidget(BI.extend({ type: "bi.label" }, o.cell, { - cls: (o.cell.cls || "") + "collection-table-cell-wrapper", + cls: (o.cell.cls || "") + " collection-table-cell-wrapper", width: o.width - (o._left === 0 ? 1 : 0) - 1, height: o.height - (o._top === 0 ? 1 : 0) - 1 })); diff --git a/docs/widget.js b/docs/widget.js index ae412aba1..14511955e 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -5638,6 +5638,10 @@ BI.DownListCombo = BI.inherit(BI.Widget, { }); }, + hideView: function () { + this.downlistcombo.hideView(); + }, + populate: function (items) { this.popupview.populate(items); }, diff --git a/src/base/table/table.collection.cell.js b/src/base/table/table.collection.cell.js index 7a1ebae85..5c5105399 100644 --- a/src/base/table/table.collection.cell.js +++ b/src/base/table/table.collection.cell.js @@ -24,7 +24,7 @@ BI.CollectionTableCell = BI.inherit(BI.Widget, { this.cell = BI.createWidget(BI.extend({ type: "bi.label" }, o.cell, { - cls: (o.cell.cls || "") + "collection-table-cell-wrapper", + cls: (o.cell.cls || "") + " collection-table-cell-wrapper", width: o.width - (o._left === 0 ? 1 : 0) - 1, height: o.height - (o._top === 0 ? 1 : 0) - 1 })); diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js index ed37eb40c..2481a8ba7 100644 --- a/src/widget/downlist/combo.downlist.js +++ b/src/widget/downlist/combo.downlist.js @@ -56,6 +56,10 @@ BI.DownListCombo = BI.inherit(BI.Widget, { }); }, + hideView: function () { + this.downlistcombo.hideView(); + }, + populate: function (items) { this.popupview.populate(items); }, From 93e9e5043625cae17eb3c2853ed95eb9576d47fa Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 27 May 2017 11:45:56 +0800 Subject: [PATCH 10/27] update --- bi/core.js | 11 +++++++++-- docs/core.js | 11 +++++++++-- src/core/widget.js | 11 +++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bi/core.js b/bi/core.js index 75319bb31..100e50c68 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4537,6 +4537,14 @@ BI.Widget = BI.inherit(BI.OB, { }); }, + _setVisible: function (visible) { + if (visible === true) { + this.options.invisible = false; + } else if (visible === false) { + this.options.invisible = true; + } + }, + setEnable: function (enable) { this._setEnable(enable); if (enable === true) { @@ -4547,13 +4555,12 @@ BI.Widget = BI.inherit(BI.OB, { }, setVisible: function (visible) { + this._setVisible(visible); if (visible === true) { - this.options.invisible = false; //用this.element.show()会把display属性改成block this.element.css("display", ""); this._mount(); } else if (visible === false) { - this.options.invisible = true; this.element.css("display", "none"); } this.fireEvent(BI.Events.VIEW, visible); diff --git a/docs/core.js b/docs/core.js index ddbf75f1a..5103bb804 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14539,6 +14539,14 @@ BI.Widget = BI.inherit(BI.OB, { }); }, + _setVisible: function (visible) { + if (visible === true) { + this.options.invisible = false; + } else if (visible === false) { + this.options.invisible = true; + } + }, + setEnable: function (enable) { this._setEnable(enable); if (enable === true) { @@ -14549,13 +14557,12 @@ BI.Widget = BI.inherit(BI.OB, { }, setVisible: function (visible) { + this._setVisible(visible); if (visible === true) { - this.options.invisible = false; //用this.element.show()会把display属性改成block this.element.css("display", ""); this._mount(); } else if (visible === false) { - this.options.invisible = true; this.element.css("display", "none"); } this.fireEvent(BI.Events.VIEW, visible); diff --git a/src/core/widget.js b/src/core/widget.js index dd9f56b3c..a868b4d31 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -214,6 +214,14 @@ BI.Widget = BI.inherit(BI.OB, { }); }, + _setVisible: function (visible) { + if (visible === true) { + this.options.invisible = false; + } else if (visible === false) { + this.options.invisible = true; + } + }, + setEnable: function (enable) { this._setEnable(enable); if (enable === true) { @@ -224,13 +232,12 @@ BI.Widget = BI.inherit(BI.OB, { }, setVisible: function (visible) { + this._setVisible(visible); if (visible === true) { - this.options.invisible = false; //用this.element.show()会把display属性改成block this.element.css("display", ""); this._mount(); } else if (visible === false) { - this.options.invisible = true; this.element.css("display", "none"); } this.fireEvent(BI.Events.VIEW, visible); From 7625121824a2c1567960c5613e21ad90eb95f425 Mon Sep 17 00:00:00 2001 From: young Date: Sat, 27 May 2017 17:24:06 +0800 Subject: [PATCH 11/27] setSelectedValue --- bi/widget.js | 21 +++++++++++++++---- docs/widget.js | 21 +++++++++++++++---- .../abstract.treevaluechooser.js | 8 +++---- .../treevaluechooser/pane.treevaluechooser.js | 4 ++++ src/widget/multiselecttree/multiselecttree.js | 4 ++++ .../multiselecttree/multiselecttree.popup.js | 5 +++++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/bi/widget.js b/bi/widget.js index 14511955e..43536e4f7 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -11429,6 +11429,10 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, + setSelectedValue: function (v) { + this.adapter.setSelectedValue(v); + }, + setValue: function (v) { this.storeValue.value = v || {}; this.adapter.setValue({ @@ -11496,6 +11500,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { this.popup.setValue(v.value); }, + setSelectedValue: function (v) { + v || (v = {}); + this.popup.setSelectedValue(v); + }, + updateValue: function (v) { this.popup.updateValue(v); this.popup.refresh(); @@ -17586,11 +17595,11 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var times = op.times; var checkState = op.checkState || {}; var parentValues = op.parentValues || []; - var selectedValues = op.selectedValues; + var selectedValues = op.selectedValues || {}; var valueMap = {}; - if (judgeState(parentValues, selectedValues, checkState)) { + // if (judgeState(parentValues, selectedValues, checkState)) { valueMap = dealWidthSelectedValue(parentValues, selectedValues); - } + // } var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); @@ -17623,7 +17632,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree function dealWidthSelectedValue(parentValues, selectedValues) { var valueMap = {}; BI.each(parentValues, function (i, v) { - selectedValues = selectedValues[v]; + selectedValues = selectedValues[v] || {}; }); BI.each(selectedValues, function (value, obj) { if (BI.isNull(obj)) { @@ -17810,6 +17819,10 @@ BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { } }, + setSelectedValue: function (v) { + this.pane.setSelectedValue(v); + }, + setValue: function (v) { this.pane.setValue(v); }, diff --git a/docs/widget.js b/docs/widget.js index 14511955e..43536e4f7 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -11429,6 +11429,10 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, + setSelectedValue: function (v) { + this.adapter.setSelectedValue(v); + }, + setValue: function (v) { this.storeValue.value = v || {}; this.adapter.setValue({ @@ -11496,6 +11500,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { this.popup.setValue(v.value); }, + setSelectedValue: function (v) { + v || (v = {}); + this.popup.setSelectedValue(v); + }, + updateValue: function (v) { this.popup.updateValue(v); this.popup.refresh(); @@ -17586,11 +17595,11 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var times = op.times; var checkState = op.checkState || {}; var parentValues = op.parentValues || []; - var selectedValues = op.selectedValues; + var selectedValues = op.selectedValues || {}; var valueMap = {}; - if (judgeState(parentValues, selectedValues, checkState)) { + // if (judgeState(parentValues, selectedValues, checkState)) { valueMap = dealWidthSelectedValue(parentValues, selectedValues); - } + // } var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); @@ -17623,7 +17632,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree function dealWidthSelectedValue(parentValues, selectedValues) { var valueMap = {}; BI.each(parentValues, function (i, v) { - selectedValues = selectedValues[v]; + selectedValues = selectedValues[v] || {}; }); BI.each(selectedValues, function (value, obj) { if (BI.isNull(obj)) { @@ -17810,6 +17819,10 @@ BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { } }, + setSelectedValue: function (v) { + this.pane.setSelectedValue(v); + }, + setValue: function (v) { this.pane.setValue(v); }, diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index 41699b41e..57369bf24 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -407,11 +407,11 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { var times = op.times; var checkState = op.checkState || {}; var parentValues = op.parentValues || []; - var selectedValues = op.selectedValues; + var selectedValues = op.selectedValues || {}; var valueMap = {}; - if (judgeState(parentValues, selectedValues, checkState)) { + // if (judgeState(parentValues, selectedValues, checkState)) { valueMap = dealWidthSelectedValue(parentValues, selectedValues); - } + // } var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); @@ -444,7 +444,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { function dealWidthSelectedValue(parentValues, selectedValues) { var valueMap = {}; BI.each(parentValues, function (i, v) { - selectedValues = selectedValues[v]; + selectedValues = selectedValues[v] || {}; }); BI.each(selectedValues, function (value, obj) { if (BI.isNull(obj)) { diff --git a/src/component/treevaluechooser/pane.treevaluechooser.js b/src/component/treevaluechooser/pane.treevaluechooser.js index dd924c925..c0ebb8f32 100644 --- a/src/component/treevaluechooser/pane.treevaluechooser.js +++ b/src/component/treevaluechooser/pane.treevaluechooser.js @@ -33,6 +33,10 @@ BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { } }, + setSelectedValue: function (v) { + this.pane.setSelectedValue(v); + }, + setValue: function (v) { this.pane.setValue(v); }, diff --git a/src/widget/multiselecttree/multiselecttree.js b/src/widget/multiselecttree/multiselecttree.js index 320036436..0b5c91bb1 100644 --- a/src/widget/multiselecttree/multiselecttree.js +++ b/src/widget/multiselecttree/multiselecttree.js @@ -126,6 +126,10 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, + setSelectedValue: function (v) { + this.adapter.setSelectedValue(v); + }, + setValue: function (v) { this.storeValue.value = v || {}; this.adapter.setValue({ diff --git a/src/widget/multiselecttree/multiselecttree.popup.js b/src/widget/multiselecttree/multiselecttree.popup.js index 2ccdd977e..72a235077 100644 --- a/src/widget/multiselecttree/multiselecttree.popup.js +++ b/src/widget/multiselecttree/multiselecttree.popup.js @@ -37,6 +37,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { this.popup.setValue(v.value); }, + setSelectedValue: function (v) { + v || (v = {}); + this.popup.setSelectedValue(v); + }, + updateValue: function (v) { this.popup.updateValue(v); this.popup.refresh(); From feb353963d0db780d1b4f1277392a5b34078103c Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 28 May 2017 23:21:30 +0800 Subject: [PATCH 12/27] add --- bi/base.js | 7 +++---- bi/widget.js | 4 ++-- docs/base.js | 7 +++---- docs/widget.js | 4 ++-- src/base/tree/parttree.js | 2 +- src/base/tree/treeview.js | 5 ++--- src/widget/arrangement/arrangement.js | 2 +- src/widget/multitree/multi.tree.combo.js | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/bi/base.js b/bi/base.js index b92b70061..785c8ad4d 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, { this._buildTree(map, path); return; } - var storeValues = BI.deepClone(this.options.paras.selectedValues); + var storeValues = BI.deepClone(this.selectedValues); var treeNode = this._getTree(storeValues, path); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); }, @@ -1946,14 +1946,13 @@ BI.TreeView = BI.inherit(BI.Pane, { //设置树节点的状态 setValue: function (value, param) { - this.setSelectedValue(value); this.checkAll(false); this.updateValue(value, param); this.refresh(); }, setSelectedValue: function (value) { - this.options.paras.selectedValues = BI.deepClone(value) || {}; + this.options.paras.selectedValues = value || {}; this.selectedValues = BI.deepClone(value) || {}; }, @@ -2249,7 +2248,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { _selectTreeNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); - var name = this._getNodeValue(treeNode) + var name = this._getNodeValue(treeNode); // var values = parentValues.concat([name]); if (treeNode.checked === true) { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); diff --git a/bi/widget.js b/bi/widget.js index 43536e4f7..c8304eb1b 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -3924,7 +3924,7 @@ BI.Arrangement = BI.inherit(BI.Widget, { BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; BI.extend(BI.Arrangement, { PORTION: 24, - GRID_HEIGHT: 50, + GRID_HEIGHT: 60, LAYOUT_TYPE: { ADAPTIVE: 0, FREE: 1, @@ -11721,7 +11721,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, action: function () { - self._defaultState(); + self.combo.hideView(); } }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, diff --git a/docs/base.js b/docs/base.js index b92b70061..785c8ad4d 100644 --- a/docs/base.js +++ b/docs/base.js @@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, { this._buildTree(map, path); return; } - var storeValues = BI.deepClone(this.options.paras.selectedValues); + var storeValues = BI.deepClone(this.selectedValues); var treeNode = this._getTree(storeValues, path); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); }, @@ -1946,14 +1946,13 @@ BI.TreeView = BI.inherit(BI.Pane, { //设置树节点的状态 setValue: function (value, param) { - this.setSelectedValue(value); this.checkAll(false); this.updateValue(value, param); this.refresh(); }, setSelectedValue: function (value) { - this.options.paras.selectedValues = BI.deepClone(value) || {}; + this.options.paras.selectedValues = value || {}; this.selectedValues = BI.deepClone(value) || {}; }, @@ -2249,7 +2248,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { _selectTreeNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); - var name = this._getNodeValue(treeNode) + var name = this._getNodeValue(treeNode); // var values = parentValues.concat([name]); if (treeNode.checked === true) { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); diff --git a/docs/widget.js b/docs/widget.js index 43536e4f7..c8304eb1b 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -3924,7 +3924,7 @@ BI.Arrangement = BI.inherit(BI.Widget, { BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; BI.extend(BI.Arrangement, { PORTION: 24, - GRID_HEIGHT: 50, + GRID_HEIGHT: 60, LAYOUT_TYPE: { ADAPTIVE: 0, FREE: 1, @@ -11721,7 +11721,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, action: function () { - self._defaultState(); + self.combo.hideView(); } }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, diff --git a/src/base/tree/parttree.js b/src/base/tree/parttree.js index d628cd72c..6d4fe6f58 100644 --- a/src/base/tree/parttree.js +++ b/src/base/tree/parttree.js @@ -40,7 +40,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { _selectTreeNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); - var name = this._getNodeValue(treeNode) + var name = this._getNodeValue(treeNode); // var values = parentValues.concat([name]); if (treeNode.checked === true) { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 0326b38ae..045388c4d 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -241,7 +241,7 @@ BI.TreeView = BI.inherit(BI.Pane, { this._buildTree(map, path); return; } - var storeValues = BI.deepClone(this.options.paras.selectedValues); + var storeValues = BI.deepClone(this.selectedValues); var treeNode = this._getTree(storeValues, path); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); }, @@ -445,14 +445,13 @@ BI.TreeView = BI.inherit(BI.Pane, { //设置树节点的状态 setValue: function (value, param) { - this.setSelectedValue(value); this.checkAll(false); this.updateValue(value, param); this.refresh(); }, setSelectedValue: function (value) { - this.options.paras.selectedValues = BI.deepClone(value) || {}; + this.options.paras.selectedValues = value || {}; this.selectedValues = BI.deepClone(value) || {}; }, diff --git a/src/widget/arrangement/arrangement.js b/src/widget/arrangement/arrangement.js index 8bedd4259..96514ce62 100644 --- a/src/widget/arrangement/arrangement.js +++ b/src/widget/arrangement/arrangement.js @@ -2934,7 +2934,7 @@ BI.Arrangement = BI.inherit(BI.Widget, { BI.Arrangement.EVENT_SCROLL = "EVENT_SCROLL"; BI.extend(BI.Arrangement, { PORTION: 24, - GRID_HEIGHT: 50, + GRID_HEIGHT: 60, LAYOUT_TYPE: { ADAPTIVE: 0, FREE: 1, diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js index d2bd72edf..3c98f2c52 100644 --- a/src/widget/multitree/multi.tree.combo.js +++ b/src/widget/multitree/multi.tree.combo.js @@ -88,7 +88,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, action: function () { - self._defaultState(); + self.combo.hideView(); } }, { eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, From 35718a6539a7607e5726c97b4ffb17d2557aab16 Mon Sep 17 00:00:00 2001 From: guy <141592Wc> Date: Tue, 30 May 2017 12:57:09 +0800 Subject: [PATCH 13/27] add --- bi/base.js | 29 +++---- bi/widget.js | 80 ++++++++++++++++--- docs/base.js | 29 +++---- docs/widget.js | 80 ++++++++++++++++--- src/base/tree/parttree.js | 29 +++---- .../abstract.treevaluechooser.js | 80 ++++++++++++++++--- 6 files changed, 243 insertions(+), 84 deletions(-) diff --git a/bi/base.js b/bi/base.js index 785c8ad4d..0e20f47e8 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2249,32 +2249,27 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); var name = this._getNodeValue(treeNode); -// var values = parentValues.concat([name]); if (treeNode.checked === true) { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { + //如果选中的值中不存在该值不处理 + var t = this.selectedValues; + var p = parentValues.concat(name); + for (var i = 0, len = p.length; i < len; i++) { + t = t[p[i]]; + if (t == null) { + return; + } + if (BI.isEmpty(t)) { + break; + } + } o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_SELECT_DATA, selectedValues: this.selectedValues, notSelectedValue: name, parentValues: parentValues }), function (new_values) { - if (BI.isEqual(self.selectedValues, new_values)) { - var tNode = treeNode; - var pNode = self._getTree(new_values, parentValues); - if (pNode[name]) { - delete pNode[name]; - } - while (tNode != null && BI.isEmpty(pNode)) { - parentValues = parentValues.slice(0, parentValues.length - 1); - tNode = tNode.getParentNode(); - if (tNode != null) { - pNode = self._getTree(new_values, parentValues); - name = self._getNodeValue(tNode); - delete pNode[name]; - } - } - } self.selectedValues = new_values; BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); diff --git a/bi/widget.js b/bi/widget.js index c8304eb1b..0863124f0 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -17297,7 +17297,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree _reqSelectedTreeNode: function (op, callback) { var self = this; - var selectedValues = op.selectedValues; + var selectedValues = BI.deepClone(op.selectedValues); var notSelectedValue = op.notSelectedValue || {}; var keyword = op.keyword || ""; var parentValues = op.parentValues || []; @@ -17312,12 +17312,38 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree function dealWithSelectedValues(selectedValues) { - var p = BI.clone(parentValues); - p.push(notSelectedValue); + //存储的值中存在这个值就把它删掉 + if (canFindKey(selectedValues, parentValues.concat(notSelectedValue))) { + //如果搜索的值在父亲链中 + if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + var name = notSelectedValue; + var p = parentValues; + var pNode = getNode(selectedValues, parentValues); + if (pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = getNode(selectedValues, p); + delete pNode[name]; + } + } + } + } - if (isChild(selectedValues, p)) { - var result = []; - var finded = search(parentValues.length + 1, parentValues, notSelectedValue, result); + //存储的值中不存在这个值,但父亲节点是全选的情况 + if (isChild(selectedValues, parentValues.concat(notSelectedValue))) { + var result = [], finded = false; + var p = parentValues; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + finded = true; + p = parentValues.concat(notSelectedValue); + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + } if (finded === true) { var next = selectedValues; @@ -17353,7 +17379,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } - function search(deep, parents, current, result) { + function search(parents, current, result) { var newParents = BI.clone(parents); newParents.push(current); if (self._isMatch(current, keyword)) { @@ -17366,7 +17392,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var can = false; BI.each(children, function (i, child) { - if (search(deep + 1, newParents, child.value, result)) { + if (search(newParents, child.value, result)) { can = true; } else { notSearch.push(child.value); @@ -17382,6 +17408,38 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return can; } + function isSearchValueInParent(parentValues) { + for (var i = 0, len = parentValues.length; i < len; i++) { + if (self._isMatch(parentValues[i], keyword)) { + return true; + } + } + return false; + } + + function getNode(selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + } + + function canFindKey(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + t = t[v]; + if (t == null) { + return false; + } + } + return true; + } + function isChild(selectedValues, parents) { var t = selectedValues; for (var i = 0; i < parents.length; i++) { @@ -17390,11 +17448,11 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return false; } t = t[v]; - if (t == null || BI.isEmpty(t)) { + if (BI.isEmpty(t)) { return true; } } - return true; + return false; } }, @@ -17598,7 +17656,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var selectedValues = op.selectedValues || {}; var valueMap = {}; // if (judgeState(parentValues, selectedValues, checkState)) { - valueMap = dealWidthSelectedValue(parentValues, selectedValues); + valueMap = dealWidthSelectedValue(parentValues, selectedValues); // } var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { diff --git a/docs/base.js b/docs/base.js index 785c8ad4d..0e20f47e8 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2249,32 +2249,27 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); var name = this._getNodeValue(treeNode); -// var values = parentValues.concat([name]); if (treeNode.checked === true) { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { + //如果选中的值中不存在该值不处理 + var t = this.selectedValues; + var p = parentValues.concat(name); + for (var i = 0, len = p.length; i < len; i++) { + t = t[p[i]]; + if (t == null) { + return; + } + if (BI.isEmpty(t)) { + break; + } + } o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_SELECT_DATA, selectedValues: this.selectedValues, notSelectedValue: name, parentValues: parentValues }), function (new_values) { - if (BI.isEqual(self.selectedValues, new_values)) { - var tNode = treeNode; - var pNode = self._getTree(new_values, parentValues); - if (pNode[name]) { - delete pNode[name]; - } - while (tNode != null && BI.isEmpty(pNode)) { - parentValues = parentValues.slice(0, parentValues.length - 1); - tNode = tNode.getParentNode(); - if (tNode != null) { - pNode = self._getTree(new_values, parentValues); - name = self._getNodeValue(tNode); - delete pNode[name]; - } - } - } self.selectedValues = new_values; BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); diff --git a/docs/widget.js b/docs/widget.js index c8304eb1b..0863124f0 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -17297,7 +17297,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree _reqSelectedTreeNode: function (op, callback) { var self = this; - var selectedValues = op.selectedValues; + var selectedValues = BI.deepClone(op.selectedValues); var notSelectedValue = op.notSelectedValue || {}; var keyword = op.keyword || ""; var parentValues = op.parentValues || []; @@ -17312,12 +17312,38 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree function dealWithSelectedValues(selectedValues) { - var p = BI.clone(parentValues); - p.push(notSelectedValue); + //存储的值中存在这个值就把它删掉 + if (canFindKey(selectedValues, parentValues.concat(notSelectedValue))) { + //如果搜索的值在父亲链中 + if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + var name = notSelectedValue; + var p = parentValues; + var pNode = getNode(selectedValues, parentValues); + if (pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = getNode(selectedValues, p); + delete pNode[name]; + } + } + } + } - if (isChild(selectedValues, p)) { - var result = []; - var finded = search(parentValues.length + 1, parentValues, notSelectedValue, result); + //存储的值中不存在这个值,但父亲节点是全选的情况 + if (isChild(selectedValues, parentValues.concat(notSelectedValue))) { + var result = [], finded = false; + var p = parentValues; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + finded = true; + p = parentValues.concat(notSelectedValue); + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + } if (finded === true) { var next = selectedValues; @@ -17353,7 +17379,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } - function search(deep, parents, current, result) { + function search(parents, current, result) { var newParents = BI.clone(parents); newParents.push(current); if (self._isMatch(current, keyword)) { @@ -17366,7 +17392,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var can = false; BI.each(children, function (i, child) { - if (search(deep + 1, newParents, child.value, result)) { + if (search(newParents, child.value, result)) { can = true; } else { notSearch.push(child.value); @@ -17382,6 +17408,38 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return can; } + function isSearchValueInParent(parentValues) { + for (var i = 0, len = parentValues.length; i < len; i++) { + if (self._isMatch(parentValues[i], keyword)) { + return true; + } + } + return false; + } + + function getNode(selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + } + + function canFindKey(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + t = t[v]; + if (t == null) { + return false; + } + } + return true; + } + function isChild(selectedValues, parents) { var t = selectedValues; for (var i = 0; i < parents.length; i++) { @@ -17390,11 +17448,11 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return false; } t = t[v]; - if (t == null || BI.isEmpty(t)) { + if (BI.isEmpty(t)) { return true; } } - return true; + return false; } }, @@ -17598,7 +17656,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var selectedValues = op.selectedValues || {}; var valueMap = {}; // if (judgeState(parentValues, selectedValues, checkState)) { - valueMap = dealWidthSelectedValue(parentValues, selectedValues); + valueMap = dealWidthSelectedValue(parentValues, selectedValues); // } var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { diff --git a/src/base/tree/parttree.js b/src/base/tree/parttree.js index 6d4fe6f58..625fed4e0 100644 --- a/src/base/tree/parttree.js +++ b/src/base/tree/parttree.js @@ -41,32 +41,27 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); var name = this._getNodeValue(treeNode); -// var values = parentValues.concat([name]); if (treeNode.checked === true) { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { + //如果选中的值中不存在该值不处理 + var t = this.selectedValues; + var p = parentValues.concat(name); + for (var i = 0, len = p.length; i < len; i++) { + t = t[p[i]]; + if (t == null) { + return; + } + if (BI.isEmpty(t)) { + break; + } + } o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_SELECT_DATA, selectedValues: this.selectedValues, notSelectedValue: name, parentValues: parentValues }), function (new_values) { - if (BI.isEqual(self.selectedValues, new_values)) { - var tNode = treeNode; - var pNode = self._getTree(new_values, parentValues); - if (pNode[name]) { - delete pNode[name]; - } - while (tNode != null && BI.isEmpty(pNode)) { - parentValues = parentValues.slice(0, parentValues.length - 1); - tNode = tNode.getParentNode(); - if (tNode != null) { - pNode = self._getTree(new_values, parentValues); - name = self._getNodeValue(tNode); - delete pNode[name]; - } - } - } self.selectedValues = new_values; BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index 57369bf24..40c6acfc9 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -109,7 +109,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { _reqSelectedTreeNode: function (op, callback) { var self = this; - var selectedValues = op.selectedValues; + var selectedValues = BI.deepClone(op.selectedValues); var notSelectedValue = op.notSelectedValue || {}; var keyword = op.keyword || ""; var parentValues = op.parentValues || []; @@ -124,12 +124,38 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { function dealWithSelectedValues(selectedValues) { - var p = BI.clone(parentValues); - p.push(notSelectedValue); + //存储的值中存在这个值就把它删掉 + if (canFindKey(selectedValues, parentValues.concat(notSelectedValue))) { + //如果搜索的值在父亲链中 + if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + var name = notSelectedValue; + var p = parentValues; + var pNode = getNode(selectedValues, parentValues); + if (pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = getNode(selectedValues, p); + delete pNode[name]; + } + } + } + } - if (isChild(selectedValues, p)) { - var result = []; - var finded = search(parentValues.length + 1, parentValues, notSelectedValue, result); + //存储的值中不存在这个值,但父亲节点是全选的情况 + if (isChild(selectedValues, parentValues.concat(notSelectedValue))) { + var result = [], finded = false; + var p = parentValues; + //如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + finded = true; + p = parentValues.concat(notSelectedValue); + } else { + //从当前值开始搜 + finded = search(parentValues, notSelectedValue, result); + } if (finded === true) { var next = selectedValues; @@ -165,7 +191,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { } - function search(deep, parents, current, result) { + function search(parents, current, result) { var newParents = BI.clone(parents); newParents.push(current); if (self._isMatch(current, keyword)) { @@ -178,7 +204,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { var can = false; BI.each(children, function (i, child) { - if (search(deep + 1, newParents, child.value, result)) { + if (search(newParents, child.value, result)) { can = true; } else { notSearch.push(child.value); @@ -194,6 +220,38 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return can; } + function isSearchValueInParent(parentValues) { + for (var i = 0, len = parentValues.length; i < len; i++) { + if (self._isMatch(parentValues[i], keyword)) { + return true; + } + } + return false; + } + + function getNode(selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + } + + function canFindKey(selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + t = t[v]; + if (t == null) { + return false; + } + } + return true; + } + function isChild(selectedValues, parents) { var t = selectedValues; for (var i = 0; i < parents.length; i++) { @@ -202,11 +260,11 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return false; } t = t[v]; - if (t == null || BI.isEmpty(t)) { + if (BI.isEmpty(t)) { return true; } } - return true; + return false; } }, @@ -410,7 +468,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { var selectedValues = op.selectedValues || {}; var valueMap = {}; // if (judgeState(parentValues, selectedValues, checkState)) { - valueMap = dealWidthSelectedValue(parentValues, selectedValues); + valueMap = dealWidthSelectedValue(parentValues, selectedValues); // } var nodes = this._getChildren(parentValues); for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { From 6876257298cf05eb94e66c12d0a2848fb558f66e Mon Sep 17 00:00:00 2001 From: guy <141592Wc> Date: Tue, 30 May 2017 19:05:05 +0800 Subject: [PATCH 14/27] add --- bi/widget.js | 82 +++++++++++-------- docs/widget.js | 82 +++++++++++-------- .../abstract.treevaluechooser.js | 82 +++++++++++-------- 3 files changed, 141 insertions(+), 105 deletions(-) diff --git a/bi/widget.js b/bi/widget.js index 0863124f0..2bc53e8ab 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -17265,7 +17265,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return; } BI.each(selected, function (k) { - var node = self._getNode(parentValues, k); + var node = self._getTreeNode(parentValues, k); var newParents = BI.clone(parentValues); newParents.push(node.value); createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents)); @@ -17312,37 +17312,33 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree function dealWithSelectedValues(selectedValues) { + var p = parentValues.concat(notSelectedValue); //存储的值中存在这个值就把它删掉 - if (canFindKey(selectedValues, parentValues.concat(notSelectedValue))) { + if (canFindKey(selectedValues, p)) { //如果搜索的值在父亲链中 - if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { - var name = notSelectedValue; - var p = parentValues; - var pNode = getNode(selectedValues, parentValues); - if (pNode[name]) { - delete pNode[name]; - //递归删掉空父节点 - while (p.length > 0 && BI.isEmpty(pNode)) { - name = p[p.length - 1]; - p = p.slice(0, p.length - 1); - pNode = getNode(selectedValues, p); - delete pNode[name]; - } + if (isSearchValueInParent(p)) { + self._deleteNode(selectedValues, p); + } else { + var searched = []; + var finded = search(parentValues, notSelectedValue, [], searched); + if (finded && BI.isNotEmptyArray(searched)) { + BI.each(searched, function (i, arr) { + self._deleteNode(selectedValues, arr); + }) } } } //存储的值中不存在这个值,但父亲节点是全选的情况 - if (isChild(selectedValues, parentValues.concat(notSelectedValue))) { + if (isChild(selectedValues, p)) { var result = [], finded = false; - var p = parentValues; //如果parentValues中有匹配的值,说明搜索结果不在当前值下 - if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + if (isSearchValueInParent(p)) { finded = true; - p = parentValues.concat(notSelectedValue); } else { //从当前值开始搜 finded = search(parentValues, notSelectedValue, result); + p = parentValues; } if (finded === true) { @@ -17379,10 +17375,11 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } - function search(parents, current, result) { + function search(parents, current, result, searched) { var newParents = BI.clone(parents); newParents.push(current); if (self._isMatch(current, keyword)) { + searched && searched.push(newParents); return true; } @@ -17392,7 +17389,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var can = false; BI.each(children, function (i, child) { - if (search(newParents, child.value, result)) { + if (search(newParents, child.value, result, searched)) { can = true; } else { notSearch.push(child.value); @@ -17417,17 +17414,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return false; } - function getNode(selectedValues, parentValues) { - var pNode = selectedValues; - for (var i = 0, len = parentValues.length; i < len; i++) { - if (pNode == null) { - return null; - } - pNode = pNode[parentValues[i]]; - } - return pNode; - } - function canFindKey(selectedValues, parents) { var t = selectedValues; for (var i = 0; i < parents.length; i++) { @@ -17576,7 +17562,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } function createOneJson(parentValues, value, isOpen, checked, half, flag, result) { - var node = self._getNode(parentValues, value) + var node = self._getTreeNode(parentValues, value) result.push({ id: node.id, pId: node.pId, @@ -17738,6 +17724,32 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } }, + _getNode: function (selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + }, + + _deleteNode: function (selectedValues, values) { + var name = values[values.length - 1]; + var p = values.slice(0, values.length - 1); + var pNode = this._getNode(selectedValues, p); + if (pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = this._getNode(selectedValues, p); + delete pNode[name]; + } + } + }, _buildTree: function (jo, values) { var t = jo; @@ -17754,7 +17766,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return finded.finded.length > 0 || finded.matched.length > 0; }, - _getNode: function (parentValues, v) { + _getTreeNode: function (parentValues, v) { var self = this; var findedParentNode; var index = 0; @@ -17781,7 +17793,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree _getChildren: function (parentValues) { if (parentValues.length > 0) { var value = BI.last(parentValues); - var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value); + var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); } else { var parent = this.tree.getRoot(); } diff --git a/docs/widget.js b/docs/widget.js index 0863124f0..2bc53e8ab 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -17265,7 +17265,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return; } BI.each(selected, function (k) { - var node = self._getNode(parentValues, k); + var node = self._getTreeNode(parentValues, k); var newParents = BI.clone(parentValues); newParents.push(node.value); createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents)); @@ -17312,37 +17312,33 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree function dealWithSelectedValues(selectedValues) { + var p = parentValues.concat(notSelectedValue); //存储的值中存在这个值就把它删掉 - if (canFindKey(selectedValues, parentValues.concat(notSelectedValue))) { + if (canFindKey(selectedValues, p)) { //如果搜索的值在父亲链中 - if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { - var name = notSelectedValue; - var p = parentValues; - var pNode = getNode(selectedValues, parentValues); - if (pNode[name]) { - delete pNode[name]; - //递归删掉空父节点 - while (p.length > 0 && BI.isEmpty(pNode)) { - name = p[p.length - 1]; - p = p.slice(0, p.length - 1); - pNode = getNode(selectedValues, p); - delete pNode[name]; - } + if (isSearchValueInParent(p)) { + self._deleteNode(selectedValues, p); + } else { + var searched = []; + var finded = search(parentValues, notSelectedValue, [], searched); + if (finded && BI.isNotEmptyArray(searched)) { + BI.each(searched, function (i, arr) { + self._deleteNode(selectedValues, arr); + }) } } } //存储的值中不存在这个值,但父亲节点是全选的情况 - if (isChild(selectedValues, parentValues.concat(notSelectedValue))) { + if (isChild(selectedValues, p)) { var result = [], finded = false; - var p = parentValues; //如果parentValues中有匹配的值,说明搜索结果不在当前值下 - if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + if (isSearchValueInParent(p)) { finded = true; - p = parentValues.concat(notSelectedValue); } else { //从当前值开始搜 finded = search(parentValues, notSelectedValue, result); + p = parentValues; } if (finded === true) { @@ -17379,10 +17375,11 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } - function search(parents, current, result) { + function search(parents, current, result, searched) { var newParents = BI.clone(parents); newParents.push(current); if (self._isMatch(current, keyword)) { + searched && searched.push(newParents); return true; } @@ -17392,7 +17389,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree var can = false; BI.each(children, function (i, child) { - if (search(newParents, child.value, result)) { + if (search(newParents, child.value, result, searched)) { can = true; } else { notSearch.push(child.value); @@ -17417,17 +17414,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return false; } - function getNode(selectedValues, parentValues) { - var pNode = selectedValues; - for (var i = 0, len = parentValues.length; i < len; i++) { - if (pNode == null) { - return null; - } - pNode = pNode[parentValues[i]]; - } - return pNode; - } - function canFindKey(selectedValues, parents) { var t = selectedValues; for (var i = 0; i < parents.length; i++) { @@ -17576,7 +17562,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } function createOneJson(parentValues, value, isOpen, checked, half, flag, result) { - var node = self._getNode(parentValues, value) + var node = self._getTreeNode(parentValues, value) result.push({ id: node.id, pId: node.pId, @@ -17738,6 +17724,32 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree } }, + _getNode: function (selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + }, + + _deleteNode: function (selectedValues, values) { + var name = values[values.length - 1]; + var p = values.slice(0, values.length - 1); + var pNode = this._getNode(selectedValues, p); + if (pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = this._getNode(selectedValues, p); + delete pNode[name]; + } + } + }, _buildTree: function (jo, values) { var t = jo; @@ -17754,7 +17766,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree return finded.finded.length > 0 || finded.matched.length > 0; }, - _getNode: function (parentValues, v) { + _getTreeNode: function (parentValues, v) { var self = this; var findedParentNode; var index = 0; @@ -17781,7 +17793,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree _getChildren: function (parentValues) { if (parentValues.length > 0) { var value = BI.last(parentValues); - var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value); + var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); } else { var parent = this.tree.getRoot(); } diff --git a/src/component/treevaluechooser/abstract.treevaluechooser.js b/src/component/treevaluechooser/abstract.treevaluechooser.js index 40c6acfc9..e32b1fdd1 100644 --- a/src/component/treevaluechooser/abstract.treevaluechooser.js +++ b/src/component/treevaluechooser/abstract.treevaluechooser.js @@ -77,7 +77,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return; } BI.each(selected, function (k) { - var node = self._getNode(parentValues, k); + var node = self._getTreeNode(parentValues, k); var newParents = BI.clone(parentValues); newParents.push(node.value); createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents)); @@ -124,37 +124,33 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { function dealWithSelectedValues(selectedValues) { + var p = parentValues.concat(notSelectedValue); //存储的值中存在这个值就把它删掉 - if (canFindKey(selectedValues, parentValues.concat(notSelectedValue))) { + if (canFindKey(selectedValues, p)) { //如果搜索的值在父亲链中 - if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { - var name = notSelectedValue; - var p = parentValues; - var pNode = getNode(selectedValues, parentValues); - if (pNode[name]) { - delete pNode[name]; - //递归删掉空父节点 - while (p.length > 0 && BI.isEmpty(pNode)) { - name = p[p.length - 1]; - p = p.slice(0, p.length - 1); - pNode = getNode(selectedValues, p); - delete pNode[name]; - } + if (isSearchValueInParent(p)) { + self._deleteNode(selectedValues, p); + } else { + var searched = []; + var finded = search(parentValues, notSelectedValue, [], searched); + if (finded && BI.isNotEmptyArray(searched)) { + BI.each(searched, function (i, arr) { + self._deleteNode(selectedValues, arr); + }) } } } //存储的值中不存在这个值,但父亲节点是全选的情况 - if (isChild(selectedValues, parentValues.concat(notSelectedValue))) { + if (isChild(selectedValues, p)) { var result = [], finded = false; - var p = parentValues; //如果parentValues中有匹配的值,说明搜索结果不在当前值下 - if (isSearchValueInParent(parentValues.concat(notSelectedValue))) { + if (isSearchValueInParent(p)) { finded = true; - p = parentValues.concat(notSelectedValue); } else { //从当前值开始搜 finded = search(parentValues, notSelectedValue, result); + p = parentValues; } if (finded === true) { @@ -191,10 +187,11 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { } - function search(parents, current, result) { + function search(parents, current, result, searched) { var newParents = BI.clone(parents); newParents.push(current); if (self._isMatch(current, keyword)) { + searched && searched.push(newParents); return true; } @@ -204,7 +201,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { var can = false; BI.each(children, function (i, child) { - if (search(newParents, child.value, result)) { + if (search(newParents, child.value, result, searched)) { can = true; } else { notSearch.push(child.value); @@ -229,17 +226,6 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return false; } - function getNode(selectedValues, parentValues) { - var pNode = selectedValues; - for (var i = 0, len = parentValues.length; i < len; i++) { - if (pNode == null) { - return null; - } - pNode = pNode[parentValues[i]]; - } - return pNode; - } - function canFindKey(selectedValues, parents) { var t = selectedValues; for (var i = 0; i < parents.length; i++) { @@ -388,7 +374,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { } function createOneJson(parentValues, value, isOpen, checked, half, flag, result) { - var node = self._getNode(parentValues, value) + var node = self._getTreeNode(parentValues, value) result.push({ id: node.id, pId: node.pId, @@ -550,6 +536,32 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { } }, + _getNode: function (selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + }, + + _deleteNode: function (selectedValues, values) { + var name = values[values.length - 1]; + var p = values.slice(0, values.length - 1); + var pNode = this._getNode(selectedValues, p); + if (pNode[name]) { + delete pNode[name]; + //递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = this._getNode(selectedValues, p); + delete pNode[name]; + } + } + }, _buildTree: function (jo, values) { var t = jo; @@ -566,7 +578,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { return finded.finded.length > 0 || finded.matched.length > 0; }, - _getNode: function (parentValues, v) { + _getTreeNode: function (parentValues, v) { var self = this; var findedParentNode; var index = 0; @@ -593,7 +605,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { _getChildren: function (parentValues) { if (parentValues.length > 0) { var value = BI.last(parentValues); - var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value); + var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); } else { var parent = this.tree.getRoot(); } From fb49efa38dd2e9e66f2a3262d08c4de5166b3048 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 1 Jun 2017 18:54:00 +0800 Subject: [PATCH 15/27] add --- docs/resource.css | 26 +++++++++++++------------- src/css/resource/app.css | 13 ------------- src/css/resource/font.css | 13 +++++++++++++ src/less/resource/app.less | 13 ------------- src/less/resource/font.less | 13 +++++++++++++ 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/resource.css b/docs/resource.css index 0e32ac8cc..534b4c244 100644 --- a/docs/resource.css +++ b/docs/resource.css @@ -1,19 +1,6 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ -@font-face { - font-family: 'bi'; - src: url('font/iconfont.eot'), /* IE6-IE8 */ url('font/iconfont.woff') format('woff'), /* chrome、firefox */ url('font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('font/iconfont.svg#svgFontName') format('svg'); - - /* iOS 4.1- */ -} -.b-font { - font-family: "bi"; - font-style: normal; - -webkit-font-smoothing: antialiased; - -webkit-text-stroke-width: 0.2px; - -moz-osx-font-smoothing: grayscale; -} html, button, input, @@ -140,6 +127,19 @@ textarea::-webkit-scrollbar-thumb:hover { } /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ +@font-face { + font-family: 'bi'; + src: url('font/iconfont.eot'), /* IE6-IE8 */ url('font/iconfont.woff') format('woff'), /* chrome、firefox */ url('font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('font/iconfont.svg#svgFontName') format('svg'); + + /* iOS 4.1- */ +} +.b-font { + font-family: "bi"; + font-style: normal; + -webkit-font-smoothing: antialiased; + -webkit-text-stroke-width: 0.2px; + -moz-osx-font-smoothing: grayscale; +} .close-font .b-font { *zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = ''); } diff --git a/src/css/resource/app.css b/src/css/resource/app.css index 76b863206..bdc9f44d8 100644 --- a/src/css/resource/app.css +++ b/src/css/resource/app.css @@ -1,19 +1,6 @@ /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ -@font-face { - font-family: 'bi'; - src: url('font/iconfont.eot'), /* IE6-IE8 */ url('font/iconfont.woff') format('woff'), /* chrome、firefox */ url('font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('font/iconfont.svg#svgFontName') format('svg'); - - /* iOS 4.1- */ -} -.b-font { - font-family: "bi"; - font-style: normal; - -webkit-font-smoothing: antialiased; - -webkit-text-stroke-width: 0.2px; - -moz-osx-font-smoothing: grayscale; -} html, button, input, diff --git a/src/css/resource/font.css b/src/css/resource/font.css index 9015e9501..27409046b 100644 --- a/src/css/resource/font.css +++ b/src/css/resource/font.css @@ -1,5 +1,18 @@ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ +@font-face { + font-family: 'bi'; + src: url('font/iconfont.eot'), /* IE6-IE8 */ url('font/iconfont.woff') format('woff'), /* chrome、firefox */ url('font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('font/iconfont.svg#svgFontName') format('svg'); + + /* iOS 4.1- */ +} +.b-font { + font-family: "bi"; + font-style: normal; + -webkit-font-smoothing: antialiased; + -webkit-text-stroke-width: 0.2px; + -moz-osx-font-smoothing: grayscale; +} .close-font .b-font { *zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = ''); } diff --git a/src/less/resource/app.less b/src/less/resource/app.less index 2d73ca063..f9e045636 100644 --- a/src/less/resource/app.less +++ b/src/less/resource/app.less @@ -1,18 +1,5 @@ @import "../bibase"; -@font-face { - font-family: 'bi'; - src: url('@{webUrl}font/iconfont.eot'), /* IE6-IE8 */ url('@{webUrl}font/iconfont.woff') format('woff'), /* chrome、firefox */ url('@{webUrl}font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('@{webUrl}font/iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */ -} - -.b-font { - font-family: "bi"; - font-style: normal; - -webkit-font-smoothing: antialiased; - -webkit-text-stroke-width: 0.2px; - -moz-osx-font-smoothing: grayscale; -} - html, button, input, diff --git a/src/less/resource/font.less b/src/less/resource/font.less index 1d63e9402..603ef3fef 100644 --- a/src/less/resource/font.less +++ b/src/less/resource/font.less @@ -2,6 +2,19 @@ @import "../lib/colors"; @import "../image"; +@font-face { + font-family: 'bi'; + src: url('@{webUrl}font/iconfont.eot'), /* IE6-IE8 */ url('@{webUrl}font/iconfont.woff') format('woff'), /* chrome、firefox */ url('@{webUrl}font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('@{webUrl}font/iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */ +} + +.b-font { + font-family: "bi"; + font-style: normal; + -webkit-font-smoothing: antialiased; + -webkit-text-stroke-width: 0.2px; + -moz-osx-font-smoothing: grayscale; +} + .font(close-font, @font-cross); .font-hover(close-h-font, @font-cross); .font-hover-active(close-ha-font, @font-cross); From 361a1b78d414a89f0428e902386867c6e97baf29 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 1 Jun 2017 19:18:22 +0800 Subject: [PATCH 16/27] add --- bi/base.js | 2 +- docs/base.js | 2 +- src/base/tree/treeview.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bi/base.js b/bi/base.js index 0e20f47e8..b656b208b 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1717,7 +1717,7 @@ BI.TreeView = BI.inherit(BI.Pane, { _getNodeValue: function (node) { //去除标红 - return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value; + return node.value == null ? node.text.replace(/<[^>]+>/g, "").replaceAll(" ", " ") : node.value; }, //获取半选框值 diff --git a/docs/base.js b/docs/base.js index 0e20f47e8..b656b208b 100644 --- a/docs/base.js +++ b/docs/base.js @@ -1717,7 +1717,7 @@ BI.TreeView = BI.inherit(BI.Pane, { _getNodeValue: function (node) { //去除标红 - return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value; + return node.value == null ? node.text.replace(/<[^>]+>/g, "").replaceAll(" ", " ") : node.value; }, //获取半选框值 diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 045388c4d..bf87dc7c6 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -216,7 +216,7 @@ BI.TreeView = BI.inherit(BI.Pane, { _getNodeValue: function (node) { //去除标红 - return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value; + return node.value == null ? node.text.replace(/<[^>]+>/g, "").replaceAll(" ", " ") : node.value; }, //获取半选框值 From 60ad3b4bf71873dd051aa586470c703f40dc5c6e Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 2 Jun 2017 11:58:15 +0800 Subject: [PATCH 17/27] add --- bi/case.js | 2 +- bi/widget.js | 20 +++++++++++-------- docs/case.js | 2 +- docs/widget.js | 20 +++++++++++-------- .../table/table.dynamicsummarylayertree.js | 2 +- src/widget/multiselecttree/multiselecttree.js | 12 +++++------ .../multiselecttree/multiselecttree.popup.js | 2 +- .../multitree/multi.tree.search.pane.js | 6 +++++- 8 files changed, 39 insertions(+), 27 deletions(-) diff --git a/bi/case.js b/bi/case.js index 255c3bf16..7090b6ee8 100644 --- a/bi/case.js +++ b/bi/case.js @@ -10395,7 +10395,7 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _recomputeColumnSize: function () { var o = this.options; o.regionColumnSize = this.table.getRegionColumnSize(); - var columnSize = this.table.getColumnSize(); + var columnSize = this.table.getColumnSize().slice(); if (o.freezeCols.length > 1) { for (var i = 0; i < o.freezeCols.length - 1; i++) { columnSize.splice(1, 0, 0); diff --git a/bi/widget.js b/bi/widget.js index 2bc53e8ab..b45324fa8 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -11360,14 +11360,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { action: function () { self._showSearcherPane(); self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setValue(self.storeValue); + self.searcherPane.setSelectedValue(self.storeValue.value); } }, { eventName: BI.Searcher.EVENT_STOP, action: function () { self._showAdapter(); // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setValue(self.storeValue); + self.adapter.setSelectedValue(self.storeValue.value); BI.nextTick(function () { self.adapter.populate(); }); @@ -11430,17 +11430,17 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, setSelectedValue: function (v) { + this.storeValue.value = v || {}; this.adapter.setSelectedValue(v); + this.trigger.setValue({ + value: v || {} + }); }, setValue: function (v) { - this.storeValue.value = v || {}; this.adapter.setValue({ value: v || {} }); - this.trigger.setValue({ - value: v || {} - }); }, stopSearch: function () { @@ -11497,7 +11497,7 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { setValue: function (v) { v || (v = {}); - this.popup.setValue(v.value); + this.popup.setValue(v); }, setSelectedValue: function (v) { @@ -12029,8 +12029,12 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { }, setValue: function (v) { + this.setSelectedValue(v.value); + }, + + setSelectedValue: function (v) { v || (v = {}); - this.partTree.setSelectedValue(v.value); + this.partTree.setSelectedValue(v); }, getValue: function () { diff --git a/docs/case.js b/docs/case.js index 255c3bf16..7090b6ee8 100644 --- a/docs/case.js +++ b/docs/case.js @@ -10395,7 +10395,7 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _recomputeColumnSize: function () { var o = this.options; o.regionColumnSize = this.table.getRegionColumnSize(); - var columnSize = this.table.getColumnSize(); + var columnSize = this.table.getColumnSize().slice(); if (o.freezeCols.length > 1) { for (var i = 0; i < o.freezeCols.length - 1; i++) { columnSize.splice(1, 0, 0); diff --git a/docs/widget.js b/docs/widget.js index 2bc53e8ab..b45324fa8 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -11360,14 +11360,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { action: function () { self._showSearcherPane(); self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setValue(self.storeValue); + self.searcherPane.setSelectedValue(self.storeValue.value); } }, { eventName: BI.Searcher.EVENT_STOP, action: function () { self._showAdapter(); // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setValue(self.storeValue); + self.adapter.setSelectedValue(self.storeValue.value); BI.nextTick(function () { self.adapter.populate(); }); @@ -11430,17 +11430,17 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, setSelectedValue: function (v) { + this.storeValue.value = v || {}; this.adapter.setSelectedValue(v); + this.trigger.setValue({ + value: v || {} + }); }, setValue: function (v) { - this.storeValue.value = v || {}; this.adapter.setValue({ value: v || {} }); - this.trigger.setValue({ - value: v || {} - }); }, stopSearch: function () { @@ -11497,7 +11497,7 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { setValue: function (v) { v || (v = {}); - this.popup.setValue(v.value); + this.popup.setValue(v); }, setSelectedValue: function (v) { @@ -12029,8 +12029,12 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { }, setValue: function (v) { + this.setSelectedValue(v.value); + }, + + setSelectedValue: function (v) { v || (v = {}); - this.partTree.setSelectedValue(v.value); + this.partTree.setSelectedValue(v); }, getValue: function () { diff --git a/src/case/table/table.dynamicsummarylayertree.js b/src/case/table/table.dynamicsummarylayertree.js index da02b8c14..7377c8956 100644 --- a/src/case/table/table.dynamicsummarylayertree.js +++ b/src/case/table/table.dynamicsummarylayertree.js @@ -160,7 +160,7 @@ BI.DynamicSummaryLayerTreeTable = BI.inherit(BI.Widget, { _recomputeColumnSize: function () { var o = this.options; o.regionColumnSize = this.table.getRegionColumnSize(); - var columnSize = this.table.getColumnSize(); + var columnSize = this.table.getColumnSize().slice(); if (o.freezeCols.length > 1) { for (var i = 0; i < o.freezeCols.length - 1; i++) { columnSize.splice(1, 0, 0); diff --git a/src/widget/multiselecttree/multiselecttree.js b/src/widget/multiselecttree/multiselecttree.js index 0b5c91bb1..8fda506f1 100644 --- a/src/widget/multiselecttree/multiselecttree.js +++ b/src/widget/multiselecttree/multiselecttree.js @@ -57,14 +57,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { action: function () { self._showSearcherPane(); self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setValue(self.storeValue); + self.searcherPane.setSelectedValue(self.storeValue.value); } }, { eventName: BI.Searcher.EVENT_STOP, action: function () { self._showAdapter(); // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setValue(self.storeValue); + self.adapter.setSelectedValue(self.storeValue.value); BI.nextTick(function () { self.adapter.populate(); }); @@ -127,17 +127,17 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, setSelectedValue: function (v) { + this.storeValue.value = v || {}; this.adapter.setSelectedValue(v); + this.trigger.setValue({ + value: v || {} + }); }, setValue: function (v) { - this.storeValue.value = v || {}; this.adapter.setValue({ value: v || {} }); - this.trigger.setValue({ - value: v || {} - }); }, stopSearch: function () { diff --git a/src/widget/multiselecttree/multiselecttree.popup.js b/src/widget/multiselecttree/multiselecttree.popup.js index 72a235077..b6e3e55a2 100644 --- a/src/widget/multiselecttree/multiselecttree.popup.js +++ b/src/widget/multiselecttree/multiselecttree.popup.js @@ -34,7 +34,7 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { setValue: function (v) { v || (v = {}); - this.popup.setValue(v.value); + this.popup.setValue(v); }, setSelectedValue: function (v) { diff --git a/src/widget/multitree/multi.tree.search.pane.js b/src/widget/multitree/multi.tree.search.pane.js index 07e663a87..b02dcb94a 100644 --- a/src/widget/multitree/multi.tree.search.pane.js +++ b/src/widget/multitree/multi.tree.search.pane.js @@ -44,8 +44,12 @@ BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { }, setValue: function (v) { + this.setSelectedValue(v.value); + }, + + setSelectedValue: function (v) { v || (v = {}); - this.partTree.setSelectedValue(v.value); + this.partTree.setSelectedValue(v); }, getValue: function () { From 1bc0774fed2da424388379dbdc2fda8d128d460b Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 2 Jun 2017 15:22:37 +0800 Subject: [PATCH 18/27] add --- bi/base.js | 6 +++--- docs/base.js | 6 +++--- src/base/single/editor/editor.multifile.js | 2 +- src/base/single/input/file.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bi/base.js b/bi/base.js index b656b208b..c12cc67a1 100644 --- a/bi/base.js +++ b/bi/base.js @@ -18182,7 +18182,7 @@ BI.MultifileEditor = BI.inherit(BI.Single, { return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-multifile-editor", multiple: false, - maxSize: 1024 * 1024, + maxSize: -1,//1024 * 1024 accept: "", url: "" }) @@ -18943,7 +18943,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** url: "", multiple: true, accept: "", /**'*.jpg; *.zip'**/ - maxSize: 1024 * 1024 + maxSize: -1 //1024 * 1024 }) }, @@ -19019,7 +19019,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** }, 1000); }; _wrap.url = o.url ? o.url : BI.servletURL - + '?op=fr_attach&cmd=ah_upload'; + + '?op=fr_attach&cmd=ah_upload'; _wrap.fileType = o.accept; //文件类型限制 _wrap.attach_array = []; _wrap.attach_names = []; diff --git a/docs/base.js b/docs/base.js index b656b208b..c12cc67a1 100644 --- a/docs/base.js +++ b/docs/base.js @@ -18182,7 +18182,7 @@ BI.MultifileEditor = BI.inherit(BI.Single, { return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-multifile-editor", multiple: false, - maxSize: 1024 * 1024, + maxSize: -1,//1024 * 1024 accept: "", url: "" }) @@ -18943,7 +18943,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** url: "", multiple: true, accept: "", /**'*.jpg; *.zip'**/ - maxSize: 1024 * 1024 + maxSize: -1 //1024 * 1024 }) }, @@ -19019,7 +19019,7 @@ BI.shortcut("bi.checkbox", BI.Checkbox);/** }, 1000); }; _wrap.url = o.url ? o.url : BI.servletURL - + '?op=fr_attach&cmd=ah_upload'; + + '?op=fr_attach&cmd=ah_upload'; _wrap.fileType = o.accept; //文件类型限制 _wrap.attach_array = []; _wrap.attach_names = []; diff --git a/src/base/single/editor/editor.multifile.js b/src/base/single/editor/editor.multifile.js index dd25c7c0e..b004217ec 100644 --- a/src/base/single/editor/editor.multifile.js +++ b/src/base/single/editor/editor.multifile.js @@ -12,7 +12,7 @@ BI.MultifileEditor = BI.inherit(BI.Single, { return BI.extend(conf, { baseCls: (conf.baseCls || "") + " bi-multifile-editor", multiple: false, - maxSize: 1024 * 1024, + maxSize: -1,//1024 * 1024 accept: "", url: "" }) diff --git a/src/base/single/input/file.js b/src/base/single/input/file.js index 8b4d57a11..8f4c75f83 100644 --- a/src/base/single/input/file.js +++ b/src/base/single/input/file.js @@ -399,7 +399,7 @@ url: "", multiple: true, accept: "", /**'*.jpg; *.zip'**/ - maxSize: 1024 * 1024 + maxSize: -1 //1024 * 1024 }) }, @@ -475,7 +475,7 @@ }, 1000); }; _wrap.url = o.url ? o.url : BI.servletURL - + '?op=fr_attach&cmd=ah_upload'; + + '?op=fr_attach&cmd=ah_upload'; _wrap.fileType = o.accept; //文件类型限制 _wrap.attach_array = []; _wrap.attach_names = []; From 07ff967a0dda89e00c5476640851e4e9194c6aac Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 2 Jun 2017 17:27:50 +0800 Subject: [PATCH 19/27] add --- bi/base.js | 75 +++++++++---------- bi/widget.js | 32 ++++---- docs/base.js | 75 +++++++++---------- docs/widget.js | 32 ++++---- src/base/combination/combo.js | 13 ++-- src/base/combination/expander.js | 25 ++++--- src/base/combination/switcher.js | 2 +- src/base/tree/asynctree.js | 22 +++--- src/base/tree/parttree.js | 8 +- src/base/tree/treeview.js | 5 +- src/widget/multiselecttree/multiselecttree.js | 32 ++++---- 11 files changed, 159 insertions(+), 162 deletions(-) diff --git a/bi/base.js b/bi/base.js index c12cc67a1..947c621ac 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, { this._buildTree(map, path); return; } - var storeValues = BI.deepClone(this.selectedValues); + var storeValues = BI.deepClone(this.options.paras.selectedValues); var treeNode = this._getTree(storeValues, path); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); }, @@ -1952,8 +1952,7 @@ BI.TreeView = BI.inherit(BI.Pane, { }, setSelectedValue: function (value) { - this.options.paras.selectedValues = value || {}; - this.selectedValues = BI.deepClone(value) || {}; + this.options.paras.selectedValues = BI.deepClone(value || {}); }, updateValue: function (values, param) { @@ -2105,7 +2104,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { if (treeNode.checked === true) { } else { var tNode = treeNode; - var pNode = this._getTree(this.selectedValues, parentValues); + var pNode = this._getTree(this.options.paras.selectedValues, parentValues); if (BI.isNotNull(pNode[name])) { delete pNode[name]; } @@ -2113,7 +2112,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { parentValues = parentValues.slice(0, parentValues.length - 1); tNode = tNode.getParentNode(); if (tNode != null) { - pNode = this._getTree(this.selectedValues, parentValues); + pNode = this._getTree(this.options.paras.selectedValues, parentValues); name = this._getNodeValue(tNode); delete pNode[name]; } @@ -2127,10 +2126,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { var self = this, o = this.options; var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var op = BI.extend({}, o.paras, { - "id": treeNode.id, - "times": 1, - "parentValues": parentValues.concat(this._getNodeValue(treeNode)), - "checkState": treeNode.getCheckStatus() + id: treeNode.id, + times: 1, + parentValues: parentValues.concat(this._getNodeValue(treeNode)), + checkState: treeNode.getCheckStatus() }); var complete = function (d) { var nodes = d.items || []; @@ -2178,7 +2177,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { }, 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 () { @@ -2187,20 +2186,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { } var checkedValues = this._getSelectedValues(); 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 this._join(checkedValues, this.selectedValues); + return this._join(checkedValues, this.options.paras.selectedValues); }, //生成树方法 stroke: function (config) { delete this.options.keyword; BI.extend(this.options.paras, config); - //取消选中时使用 - this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {}; var setting = this._configSetting(); this._initTree(setting); } @@ -2253,7 +2250,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { //如果选中的值中不存在该值不处理 - var t = this.selectedValues; + var t = this.options.paras.selectedValues; var p = parentValues.concat(name); for (var i = 0, len = p.length; i < len; i++) { t = t[p[i]]; @@ -2266,11 +2263,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { } o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_SELECT_DATA, - selectedValues: this.selectedValues, notSelectedValue: name, parentValues: parentValues }), function (new_values) { - self.selectedValues = new_values; + self.options.paras.selectedValues = new_values; BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); } @@ -2367,9 +2363,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { delete o.paras.keyword; BI.extend(o.paras, config); delete o.paras.lastSearchValue; - //取消选中时使用 - this.selectedValues = BI.deepClone(o.paras.selectedValues) || {}; - //delete this.options.paras.selectedValues; var setting = this._configSetting(); this._initTree(setting, o.paras.keyword); } @@ -2920,7 +2913,7 @@ BI.Combo = BI.inherit(BI.Widget, { this._initCombo(); this._initPullDownAction(); 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) { self._popupView(); } @@ -2938,12 +2931,12 @@ BI.Combo = BI.inherit(BI.Widget, { }); 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.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); } }); @@ -2990,14 +2983,14 @@ BI.Combo = BI.inherit(BI.Widget, { switch (ev) { case "hover": 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Combo.EVENT_EXPAND); } }); 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Combo.EVENT_COLLAPSE); @@ -3007,7 +3000,7 @@ BI.Combo = BI.inherit(BI.Widget, { case "click": var debounce = BI.debounce(function (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(); if (self.isViewVisible()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); @@ -3220,6 +3213,7 @@ BI.Combo = BI.inherit(BI.Widget, { _setEnable: function (arg) { BI.Combo.superclass._setEnable.apply(this, arguments); + !arg && this.element.removeClass(this.options.hoverClass); !arg && this.isViewVisible() && this._hideView(); }, @@ -3317,13 +3311,13 @@ BI.Expander = BI.inherit(BI.Widget, { this._initExpander(); this._initPullDownAction(); this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (type === BI.Events.EXPAND) { - self._popupView(); - } - if (type === BI.Events.COLLAPSE) { - self._hideView(); - } - if (self.isEnabled() && this.isEnabled()) { + if (self.isEnabled() && self.isValid()) { + if (type === BI.Events.EXPAND) { + self._popupView(); + } + if (type === BI.Events.COLLAPSE) { + self._hideView(); + } if (type === BI.Events.EXPAND) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_EXPAND); @@ -3339,11 +3333,11 @@ BI.Expander = BI.inherit(BI.Widget, { }); 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); } }, function () { - if (self.isEnabled() && self.expander.isEnabled()) { + if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) { self.element.removeClass(o.hoverClass); } }); @@ -3379,13 +3373,13 @@ BI.Expander = BI.inherit(BI.Widget, { switch (e) { case "hover": 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander); self.fireEvent(BI.Expander.EVENT_EXPAND); } }, 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander); self.fireEvent(BI.Expander.EVENT_COLLAPSE); @@ -3396,7 +3390,7 @@ BI.Expander = BI.inherit(BI.Widget, { if (e) { self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (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(); if (self.isExpanded()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander); @@ -3487,6 +3481,7 @@ BI.Expander = BI.inherit(BI.Widget, { _setEnable: function (arg) { BI.Expander.superclass._setEnable.apply(this, arguments); + !arg && this.element.removeClass(this.options.hoverClass); !arg && this.isViewVisible() && this._hideView(); }, @@ -4484,7 +4479,7 @@ BI.Switcher = BI.inherit(BI.Widget, { this._initSwitcher(); this._initPullDownAction(); 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) { self._popupView(); } diff --git a/bi/widget.js b/bi/widget.js index b45324fa8..f4a98a86b 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -11322,34 +11322,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { itemsCreator: o.itemsCreator }); this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { - if (self.trigger.isSearching()) { + if (self.searcher.isSearching()) { self.storeValue = {value: self.searcherPane.getValue()}; } else { self.storeValue = {value: self.adapter.getValue()}; } + self.setSelectedValue(self.storeValue.value); 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", cls: "bi-border-left bi-border-right bi-border-bottom", keywordGetter: function () { - return self.trigger.getKeyword(); + return self.searcher.getKeyword(); }, itemsCreator: function (op, callback) { - op.keyword = self.trigger.getKeyword(); + op.keyword = self.searcher.getKeyword(); o.itemsCreator(op, callback); } }); this.searcherPane.setVisible(false); - this.trigger = BI.createWidget({ + this.searcher = BI.createWidget({ type: "bi.searcher", isAutoSearch: false, isAutoSync: false, onSearch: function (op, callback) { callback({ - keyword: self.trigger.getKeyword() + keyword: self.searcher.getKeyword() }); }, adapter: this.adapter, @@ -11359,15 +11361,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { eventName: BI.Searcher.EVENT_START, action: function () { self._showSearcherPane(); - self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setSelectedValue(self.storeValue.value); + // self.storeValue = {value: self.adapter.getValue()}; + // self.searcherPane.setSelectedValue(self.storeValue.value); } }, { eventName: BI.Searcher.EVENT_STOP, action: function () { self._showAdapter(); // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setSelectedValue(self.storeValue.value); + // self.adapter.setSelectedValue(self.storeValue.value); BI.nextTick(function () { self.adapter.populate(); }); @@ -11375,11 +11377,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, { eventName: BI.Searcher.EVENT_CHANGE, action: function () { - if (self.trigger.isSearching()) { + if (self.searcher.isSearching()) { self.storeValue = {value: self.searcherPane.getValue()}; } else { self.storeValue = {value: self.adapter.getValue()}; } + self.setSelectedValue(self.storeValue.value); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); } }, { @@ -11394,7 +11397,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { type: "bi.vtape", element: this, items: [{ - el: this.trigger, + el: this.searcher, height: 30 }, { el: this.adapter, @@ -11432,7 +11435,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { setSelectedValue: function (v) { this.storeValue.value = v || {}; this.adapter.setSelectedValue(v); - this.trigger.setValue({ + this.searcherPane.setSelectedValue(v); + this.searcher.setValue({ value: v || {} }); }, @@ -11444,7 +11448,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, stopSearch: function () { - this.trigger.stopSearch(); + this.searcher.stopSearch(); }, updateValue: function (v) { @@ -11456,7 +11460,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, populate: function () { - this.trigger.populate.apply(this.trigger, arguments); + this.searcher.populate.apply(this.searcher, arguments); this.adapter.populate.apply(this.adapter, arguments); } }); diff --git a/docs/base.js b/docs/base.js index c12cc67a1..947c621ac 100644 --- a/docs/base.js +++ b/docs/base.js @@ -1742,7 +1742,7 @@ BI.TreeView = BI.inherit(BI.Pane, { this._buildTree(map, path); return; } - var storeValues = BI.deepClone(this.selectedValues); + var storeValues = BI.deepClone(this.options.paras.selectedValues); var treeNode = this._getTree(storeValues, path); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); }, @@ -1952,8 +1952,7 @@ BI.TreeView = BI.inherit(BI.Pane, { }, setSelectedValue: function (value) { - this.options.paras.selectedValues = value || {}; - this.selectedValues = BI.deepClone(value) || {}; + this.options.paras.selectedValues = BI.deepClone(value || {}); }, updateValue: function (values, param) { @@ -2105,7 +2104,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { if (treeNode.checked === true) { } else { var tNode = treeNode; - var pNode = this._getTree(this.selectedValues, parentValues); + var pNode = this._getTree(this.options.paras.selectedValues, parentValues); if (BI.isNotNull(pNode[name])) { delete pNode[name]; } @@ -2113,7 +2112,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { parentValues = parentValues.slice(0, parentValues.length - 1); tNode = tNode.getParentNode(); if (tNode != null) { - pNode = this._getTree(this.selectedValues, parentValues); + pNode = this._getTree(this.options.paras.selectedValues, parentValues); name = this._getNodeValue(tNode); delete pNode[name]; } @@ -2127,10 +2126,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { var self = this, o = this.options; var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var op = BI.extend({}, o.paras, { - "id": treeNode.id, - "times": 1, - "parentValues": parentValues.concat(this._getNodeValue(treeNode)), - "checkState": treeNode.getCheckStatus() + id: treeNode.id, + times: 1, + parentValues: parentValues.concat(this._getNodeValue(treeNode)), + checkState: treeNode.getCheckStatus() }); var complete = function (d) { var nodes = d.items || []; @@ -2178,7 +2177,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { }, 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 () { @@ -2187,20 +2186,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { } var checkedValues = this._getSelectedValues(); 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 this._join(checkedValues, this.selectedValues); + return this._join(checkedValues, this.options.paras.selectedValues); }, //生成树方法 stroke: function (config) { delete this.options.keyword; BI.extend(this.options.paras, config); - //取消选中时使用 - this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {}; var setting = this._configSetting(); this._initTree(setting); } @@ -2253,7 +2250,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { //如果选中的值中不存在该值不处理 - var t = this.selectedValues; + var t = this.options.paras.selectedValues; var p = parentValues.concat(name); for (var i = 0, len = p.length; i < len; i++) { t = t[p[i]]; @@ -2266,11 +2263,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { } o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_SELECT_DATA, - selectedValues: this.selectedValues, notSelectedValue: name, parentValues: parentValues }), function (new_values) { - self.selectedValues = new_values; + self.options.paras.selectedValues = new_values; BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); } @@ -2367,9 +2363,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { delete o.paras.keyword; BI.extend(o.paras, config); delete o.paras.lastSearchValue; - //取消选中时使用 - this.selectedValues = BI.deepClone(o.paras.selectedValues) || {}; - //delete this.options.paras.selectedValues; var setting = this._configSetting(); this._initTree(setting, o.paras.keyword); } @@ -2920,7 +2913,7 @@ BI.Combo = BI.inherit(BI.Widget, { this._initCombo(); this._initPullDownAction(); 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) { self._popupView(); } @@ -2938,12 +2931,12 @@ BI.Combo = BI.inherit(BI.Widget, { }); 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.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); } }); @@ -2990,14 +2983,14 @@ BI.Combo = BI.inherit(BI.Widget, { switch (ev) { case "hover": 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Combo.EVENT_EXPAND); } }); 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Combo.EVENT_COLLAPSE); @@ -3007,7 +3000,7 @@ BI.Combo = BI.inherit(BI.Widget, { case "click": var debounce = BI.debounce(function (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(); if (self.isViewVisible()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); @@ -3220,6 +3213,7 @@ BI.Combo = BI.inherit(BI.Widget, { _setEnable: function (arg) { BI.Combo.superclass._setEnable.apply(this, arguments); + !arg && this.element.removeClass(this.options.hoverClass); !arg && this.isViewVisible() && this._hideView(); }, @@ -3317,13 +3311,13 @@ BI.Expander = BI.inherit(BI.Widget, { this._initExpander(); this._initPullDownAction(); this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (type === BI.Events.EXPAND) { - self._popupView(); - } - if (type === BI.Events.COLLAPSE) { - self._hideView(); - } - if (self.isEnabled() && this.isEnabled()) { + if (self.isEnabled() && self.isValid()) { + if (type === BI.Events.EXPAND) { + self._popupView(); + } + if (type === BI.Events.COLLAPSE) { + self._hideView(); + } if (type === BI.Events.EXPAND) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_EXPAND); @@ -3339,11 +3333,11 @@ BI.Expander = BI.inherit(BI.Widget, { }); 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); } }, function () { - if (self.isEnabled() && self.expander.isEnabled()) { + if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) { self.element.removeClass(o.hoverClass); } }); @@ -3379,13 +3373,13 @@ BI.Expander = BI.inherit(BI.Widget, { switch (e) { case "hover": 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander); self.fireEvent(BI.Expander.EVENT_EXPAND); } }, 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander); self.fireEvent(BI.Expander.EVENT_COLLAPSE); @@ -3396,7 +3390,7 @@ BI.Expander = BI.inherit(BI.Widget, { if (e) { self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (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(); if (self.isExpanded()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander); @@ -3487,6 +3481,7 @@ BI.Expander = BI.inherit(BI.Widget, { _setEnable: function (arg) { BI.Expander.superclass._setEnable.apply(this, arguments); + !arg && this.element.removeClass(this.options.hoverClass); !arg && this.isViewVisible() && this._hideView(); }, @@ -4484,7 +4479,7 @@ BI.Switcher = BI.inherit(BI.Widget, { this._initSwitcher(); this._initPullDownAction(); 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) { self._popupView(); } diff --git a/docs/widget.js b/docs/widget.js index b45324fa8..f4a98a86b 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -11322,34 +11322,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { itemsCreator: o.itemsCreator }); this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { - if (self.trigger.isSearching()) { + if (self.searcher.isSearching()) { self.storeValue = {value: self.searcherPane.getValue()}; } else { self.storeValue = {value: self.adapter.getValue()}; } + self.setSelectedValue(self.storeValue.value); 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", cls: "bi-border-left bi-border-right bi-border-bottom", keywordGetter: function () { - return self.trigger.getKeyword(); + return self.searcher.getKeyword(); }, itemsCreator: function (op, callback) { - op.keyword = self.trigger.getKeyword(); + op.keyword = self.searcher.getKeyword(); o.itemsCreator(op, callback); } }); this.searcherPane.setVisible(false); - this.trigger = BI.createWidget({ + this.searcher = BI.createWidget({ type: "bi.searcher", isAutoSearch: false, isAutoSync: false, onSearch: function (op, callback) { callback({ - keyword: self.trigger.getKeyword() + keyword: self.searcher.getKeyword() }); }, adapter: this.adapter, @@ -11359,15 +11361,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { eventName: BI.Searcher.EVENT_START, action: function () { self._showSearcherPane(); - self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setSelectedValue(self.storeValue.value); + // self.storeValue = {value: self.adapter.getValue()}; + // self.searcherPane.setSelectedValue(self.storeValue.value); } }, { eventName: BI.Searcher.EVENT_STOP, action: function () { self._showAdapter(); // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setSelectedValue(self.storeValue.value); + // self.adapter.setSelectedValue(self.storeValue.value); BI.nextTick(function () { self.adapter.populate(); }); @@ -11375,11 +11377,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, { eventName: BI.Searcher.EVENT_CHANGE, action: function () { - if (self.trigger.isSearching()) { + if (self.searcher.isSearching()) { self.storeValue = {value: self.searcherPane.getValue()}; } else { self.storeValue = {value: self.adapter.getValue()}; } + self.setSelectedValue(self.storeValue.value); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); } }, { @@ -11394,7 +11397,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { type: "bi.vtape", element: this, items: [{ - el: this.trigger, + el: this.searcher, height: 30 }, { el: this.adapter, @@ -11432,7 +11435,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { setSelectedValue: function (v) { this.storeValue.value = v || {}; this.adapter.setSelectedValue(v); - this.trigger.setValue({ + this.searcherPane.setSelectedValue(v); + this.searcher.setValue({ value: v || {} }); }, @@ -11444,7 +11448,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, stopSearch: function () { - this.trigger.stopSearch(); + this.searcher.stopSearch(); }, updateValue: function (v) { @@ -11456,7 +11460,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, populate: function () { - this.trigger.populate.apply(this.trigger, arguments); + this.searcher.populate.apply(this.searcher, arguments); this.adapter.populate.apply(this.adapter, arguments); } }); diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 373fbf6ff..18ef17019 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -34,7 +34,7 @@ BI.Combo = BI.inherit(BI.Widget, { this._initCombo(); this._initPullDownAction(); 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) { self._popupView(); } @@ -52,12 +52,12 @@ BI.Combo = BI.inherit(BI.Widget, { }); 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.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); } }); @@ -104,14 +104,14 @@ BI.Combo = BI.inherit(BI.Widget, { switch (ev) { case "hover": 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); self.fireEvent(BI.Combo.EVENT_EXPAND); } }); 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, "", self.combo); self.fireEvent(BI.Combo.EVENT_COLLAPSE); @@ -121,7 +121,7 @@ BI.Combo = BI.inherit(BI.Widget, { case "click": var debounce = BI.debounce(function (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(); if (self.isViewVisible()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.combo); @@ -334,6 +334,7 @@ BI.Combo = BI.inherit(BI.Widget, { _setEnable: function (arg) { BI.Combo.superclass._setEnable.apply(this, arguments); + !arg && this.element.removeClass(this.options.hoverClass); !arg && this.isViewVisible() && this._hideView(); }, diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index 5bfdb89a1..a204124d3 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -28,13 +28,13 @@ BI.Expander = BI.inherit(BI.Widget, { this._initExpander(); this._initPullDownAction(); this.expander.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (type === BI.Events.EXPAND) { - self._popupView(); - } - if (type === BI.Events.COLLAPSE) { - self._hideView(); - } - if (self.isEnabled() && this.isEnabled()) { + if (self.isEnabled() && self.isValid()) { + if (type === BI.Events.EXPAND) { + self._popupView(); + } + if (type === BI.Events.COLLAPSE) { + self._hideView(); + } if (type === BI.Events.EXPAND) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Expander.EVENT_EXPAND); @@ -50,11 +50,11 @@ BI.Expander = BI.inherit(BI.Widget, { }); 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); } }, function () { - if (self.isEnabled() && self.expander.isEnabled()) { + if (self.isEnabled() && self.isValid() && self.expander.isEnabled() && self.expander.isValid()) { self.element.removeClass(o.hoverClass); } }); @@ -90,13 +90,13 @@ BI.Expander = BI.inherit(BI.Widget, { switch (e) { case "hover": 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, '', self.expander); self.fireEvent(BI.Expander.EVENT_EXPAND); } }, 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.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, '', self.expander); self.fireEvent(BI.Expander.EVENT_COLLAPSE); @@ -107,7 +107,7 @@ BI.Expander = BI.inherit(BI.Widget, { if (e) { self.element.off(e + "." + self.getName()).on(e + "." + self.getName(), BI.debounce(function (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(); if (self.isExpanded()) { self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, "", self.expander); @@ -198,6 +198,7 @@ BI.Expander = BI.inherit(BI.Widget, { _setEnable: function (arg) { BI.Expander.superclass._setEnable.apply(this, arguments); + !arg && this.element.removeClass(this.options.hoverClass); !arg && this.isViewVisible() && this._hideView(); }, diff --git a/src/base/combination/switcher.js b/src/base/combination/switcher.js index f279eaabb..9428fa81c 100644 --- a/src/base/combination/switcher.js +++ b/src/base/combination/switcher.js @@ -28,7 +28,7 @@ BI.Switcher = BI.inherit(BI.Widget, { this._initSwitcher(); this._initPullDownAction(); 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) { self._popupView(); } diff --git a/src/base/tree/asynctree.js b/src/base/tree/asynctree.js index 301b59963..62bdcae61 100644 --- a/src/base/tree/asynctree.js +++ b/src/base/tree/asynctree.js @@ -105,7 +105,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { if (treeNode.checked === true) { } else { var tNode = treeNode; - var pNode = this._getTree(this.selectedValues, parentValues); + var pNode = this._getTree(this.options.paras.selectedValues, parentValues); if (BI.isNotNull(pNode[name])) { delete pNode[name]; } @@ -113,7 +113,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { parentValues = parentValues.slice(0, parentValues.length - 1); tNode = tNode.getParentNode(); if (tNode != null) { - pNode = this._getTree(this.selectedValues, parentValues); + pNode = this._getTree(this.options.paras.selectedValues, parentValues); name = this._getNodeValue(tNode); delete pNode[name]; } @@ -127,10 +127,10 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { var self = this, o = this.options; var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var op = BI.extend({}, o.paras, { - "id": treeNode.id, - "times": 1, - "parentValues": parentValues.concat(this._getNodeValue(treeNode)), - "checkState": treeNode.getCheckStatus() + id: treeNode.id, + times: 1, + parentValues: parentValues.concat(this._getNodeValue(treeNode)), + checkState: treeNode.getCheckStatus() }); var complete = function (d) { var nodes = d.items || []; @@ -178,7 +178,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { }, 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 () { @@ -187,20 +187,18 @@ BI.AsyncTree = BI.inherit(BI.TreeView, { } var checkedValues = this._getSelectedValues(); 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 this._join(checkedValues, this.selectedValues); + return this._join(checkedValues, this.options.paras.selectedValues); }, //生成树方法 stroke: function (config) { delete this.options.keyword; BI.extend(this.options.paras, config); - //取消选中时使用 - this.selectedValues = BI.deepClone(this.options.paras.selectedValues) || {}; var setting = this._configSetting(); this._initTree(setting); } diff --git a/src/base/tree/parttree.js b/src/base/tree/parttree.js index 625fed4e0..adc7088dc 100644 --- a/src/base/tree/parttree.js +++ b/src/base/tree/parttree.js @@ -45,7 +45,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { //如果选中的值中不存在该值不处理 - var t = this.selectedValues; + var t = this.options.paras.selectedValues; var p = parentValues.concat(name); for (var i = 0, len = p.length; i < len; i++) { t = t[p[i]]; @@ -58,11 +58,10 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { } o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_SELECT_DATA, - selectedValues: this.selectedValues, notSelectedValue: name, parentValues: parentValues }), function (new_values) { - self.selectedValues = new_values; + self.options.paras.selectedValues = new_values; BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); } @@ -159,9 +158,6 @@ BI.PartTree = BI.inherit(BI.AsyncTree, { delete o.paras.keyword; BI.extend(o.paras, config); delete o.paras.lastSearchValue; - //取消选中时使用 - this.selectedValues = BI.deepClone(o.paras.selectedValues) || {}; - //delete this.options.paras.selectedValues; var setting = this._configSetting(); this._initTree(setting, o.paras.keyword); } diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index bf87dc7c6..4e74c9967 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -241,7 +241,7 @@ BI.TreeView = BI.inherit(BI.Pane, { this._buildTree(map, path); return; } - var storeValues = BI.deepClone(this.selectedValues); + var storeValues = BI.deepClone(this.options.paras.selectedValues); var treeNode = this._getTree(storeValues, path); this._addTreeNode(map, parent, this._getNodeValue(node), treeNode); }, @@ -451,8 +451,7 @@ BI.TreeView = BI.inherit(BI.Pane, { }, setSelectedValue: function (value) { - this.options.paras.selectedValues = value || {}; - this.selectedValues = BI.deepClone(value) || {}; + this.options.paras.selectedValues = BI.deepClone(value || {}); }, updateValue: function (values, param) { diff --git a/src/widget/multiselecttree/multiselecttree.js b/src/widget/multiselecttree/multiselecttree.js index 8fda506f1..f51bdca39 100644 --- a/src/widget/multiselecttree/multiselecttree.js +++ b/src/widget/multiselecttree/multiselecttree.js @@ -19,34 +19,36 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { itemsCreator: o.itemsCreator }); this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { - if (self.trigger.isSearching()) { + if (self.searcher.isSearching()) { self.storeValue = {value: self.searcherPane.getValue()}; } else { self.storeValue = {value: self.adapter.getValue()}; } + self.setSelectedValue(self.storeValue.value); 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", cls: "bi-border-left bi-border-right bi-border-bottom", keywordGetter: function () { - return self.trigger.getKeyword(); + return self.searcher.getKeyword(); }, itemsCreator: function (op, callback) { - op.keyword = self.trigger.getKeyword(); + op.keyword = self.searcher.getKeyword(); o.itemsCreator(op, callback); } }); this.searcherPane.setVisible(false); - this.trigger = BI.createWidget({ + this.searcher = BI.createWidget({ type: "bi.searcher", isAutoSearch: false, isAutoSync: false, onSearch: function (op, callback) { callback({ - keyword: self.trigger.getKeyword() + keyword: self.searcher.getKeyword() }); }, adapter: this.adapter, @@ -56,15 +58,15 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { eventName: BI.Searcher.EVENT_START, action: function () { self._showSearcherPane(); - self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setSelectedValue(self.storeValue.value); + // self.storeValue = {value: self.adapter.getValue()}; + // self.searcherPane.setSelectedValue(self.storeValue.value); } }, { eventName: BI.Searcher.EVENT_STOP, action: function () { self._showAdapter(); // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setSelectedValue(self.storeValue.value); + // self.adapter.setSelectedValue(self.storeValue.value); BI.nextTick(function () { self.adapter.populate(); }); @@ -72,11 +74,12 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, { eventName: BI.Searcher.EVENT_CHANGE, action: function () { - if (self.trigger.isSearching()) { + if (self.searcher.isSearching()) { self.storeValue = {value: self.searcherPane.getValue()}; } else { self.storeValue = {value: self.adapter.getValue()}; } + self.setSelectedValue(self.storeValue.value); self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); } }, { @@ -91,7 +94,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { type: "bi.vtape", element: this, items: [{ - el: this.trigger, + el: this.searcher, height: 30 }, { el: this.adapter, @@ -129,7 +132,8 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { setSelectedValue: function (v) { this.storeValue.value = v || {}; this.adapter.setSelectedValue(v); - this.trigger.setValue({ + this.searcherPane.setSelectedValue(v); + this.searcher.setValue({ value: v || {} }); }, @@ -141,7 +145,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, stopSearch: function () { - this.trigger.stopSearch(); + this.searcher.stopSearch(); }, updateValue: function (v) { @@ -153,7 +157,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, populate: function () { - this.trigger.populate.apply(this.trigger, arguments); + this.searcher.populate.apply(this.searcher, arguments); this.adapter.populate.apply(this.adapter, arguments); } }); From d2a7ca5614c1e5d7ffbbea7b8973bc8e9e825a3f Mon Sep 17 00:00:00 2001 From: "DESKTOP-QVKS9CG\\Young" Date: Mon, 5 Jun 2017 16:50:36 +0800 Subject: [PATCH 20/27] tree --- bi/base.js | 10 ++++++++++ bi/widget.js | 4 +--- docs/base.js | 10 ++++++++++ docs/widget.js | 4 +--- src/base/tree/treeview.js | 10 ++++++++++ src/widget/multiselecttree/multiselecttree.js | 4 +--- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/bi/base.js b/bi/base.js index 947c621ac..525841fd9 100644 --- a/bi/base.js +++ b/bi/base.js @@ -1937,6 +1937,16 @@ BI.TreeView = BI.inherit(BI.Pane, { }, checkAll: function (checked) { + function setNode(children) { + BI.each(children, function (i, child) { + child.halfCheck = false; + setNode(child.children); + }); + } + BI.each(this.nodes.getNodes(), function (i, node) { + node.halfCheck = false; + setNode(node.children); + }); this.nodes && this.nodes.checkAllNodes(checked); }, diff --git a/bi/widget.js b/bi/widget.js index f4a98a86b..39789204c 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -11442,9 +11442,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, setValue: function (v) { - this.adapter.setValue({ - value: v || {} - }); + this.adapter.setValue(v); }, stopSearch: function () { diff --git a/docs/base.js b/docs/base.js index 947c621ac..525841fd9 100644 --- a/docs/base.js +++ b/docs/base.js @@ -1937,6 +1937,16 @@ BI.TreeView = BI.inherit(BI.Pane, { }, checkAll: function (checked) { + function setNode(children) { + BI.each(children, function (i, child) { + child.halfCheck = false; + setNode(child.children); + }); + } + BI.each(this.nodes.getNodes(), function (i, node) { + node.halfCheck = false; + setNode(node.children); + }); this.nodes && this.nodes.checkAllNodes(checked); }, diff --git a/docs/widget.js b/docs/widget.js index f4a98a86b..39789204c 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -11442,9 +11442,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, setValue: function (v) { - this.adapter.setValue({ - value: v || {} - }); + this.adapter.setValue(v); }, stopSearch: function () { diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 4e74c9967..6ada95083 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -436,6 +436,16 @@ BI.TreeView = BI.inherit(BI.Pane, { }, checkAll: function (checked) { + function setNode(children) { + BI.each(children, function (i, child) { + child.halfCheck = false; + setNode(child.children); + }); + } + BI.each(this.nodes.getNodes(), function (i, node) { + node.halfCheck = false; + setNode(node.children); + }); this.nodes && this.nodes.checkAllNodes(checked); }, diff --git a/src/widget/multiselecttree/multiselecttree.js b/src/widget/multiselecttree/multiselecttree.js index f51bdca39..54653c10f 100644 --- a/src/widget/multiselecttree/multiselecttree.js +++ b/src/widget/multiselecttree/multiselecttree.js @@ -139,9 +139,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { }, setValue: function (v) { - this.adapter.setValue({ - value: v || {} - }); + this.adapter.setValue(v); }, stopSearch: function () { From 7528b86a78480987351a80abfdd0b016d0d9b736 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 5 Jun 2017 17:24:19 +0800 Subject: [PATCH 21/27] add --- bi/base.js | 19 +++++++++++++++---- docs/base.js | 19 +++++++++++++++---- src/base/combination/combo.js | 8 ++++++-- src/base/combination/expander.js | 2 +- src/base/combination/switcher.js | 7 ++++++- src/base/table/table.resizable.js | 2 ++ 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/bi/base.js b/bi/base.js index 947c621ac..a042a6c63 100644 --- a/bi/base.js +++ b/bi/base.js @@ -2920,10 +2920,14 @@ BI.Combo = BI.inherit(BI.Widget, { if (type === BI.Events.COLLAPSE) { self._hideView(); } - if (type === BI.Events.EXPAND || type === BI.Events.COLLAPSE) { + if (type === BI.Events.EXPAND) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.Combo.EVENT_EXPAND); + } + if (type === BI.Events.COLLAPSE) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.isViewVisible() && self.fireEvent(BI.Combo.EVENT_COLLAPSE); } - if (type === BI.Events.CLICK) { self.fireEvent(BI.Combo.EVENT_TRIGGER_CHANGE, obj); } @@ -3324,7 +3328,7 @@ BI.Expander = BI.inherit(BI.Widget, { } if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - self.fireEvent(BI.Expander.EVENT_COLLAPSE); + self.isViewVisible() && self.fireEvent(BI.Expander.EVENT_COLLAPSE); } if (type === BI.Events.CLICK) { self.fireEvent(BI.Expander.EVENT_TRIGGER_CHANGE, value, obj); @@ -4486,8 +4490,13 @@ BI.Switcher = BI.inherit(BI.Widget, { if (type === BI.Events.COLLAPSE) { self._hideView(); } - if (type === BI.Events.EXPAND || type === BI.Events.COLLAPSE) { + if (type === BI.Events.EXPAND) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.Switcher.EVENT_EXPAND); + } + if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.isViewVisible() && self.fireEvent(BI.Switcher.EVENT_COLLAPSE); } if (type === BI.Events.CLICK) { self.fireEvent(BI.Switcher.EVENT_TRIGGER_CHANGE, value, obj); @@ -32490,6 +32499,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { mergeCols: [], mergeRule: BI.emptyFn, columnSize: [], + minColumnSize: [], + maxColumnSize: [], freezeCols: [], header: [], items: [], diff --git a/docs/base.js b/docs/base.js index 947c621ac..a042a6c63 100644 --- a/docs/base.js +++ b/docs/base.js @@ -2920,10 +2920,14 @@ BI.Combo = BI.inherit(BI.Widget, { if (type === BI.Events.COLLAPSE) { self._hideView(); } - if (type === BI.Events.EXPAND || type === BI.Events.COLLAPSE) { + if (type === BI.Events.EXPAND) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.Combo.EVENT_EXPAND); + } + if (type === BI.Events.COLLAPSE) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.isViewVisible() && self.fireEvent(BI.Combo.EVENT_COLLAPSE); } - if (type === BI.Events.CLICK) { self.fireEvent(BI.Combo.EVENT_TRIGGER_CHANGE, obj); } @@ -3324,7 +3328,7 @@ BI.Expander = BI.inherit(BI.Widget, { } if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - self.fireEvent(BI.Expander.EVENT_COLLAPSE); + self.isViewVisible() && self.fireEvent(BI.Expander.EVENT_COLLAPSE); } if (type === BI.Events.CLICK) { self.fireEvent(BI.Expander.EVENT_TRIGGER_CHANGE, value, obj); @@ -4486,8 +4490,13 @@ BI.Switcher = BI.inherit(BI.Widget, { if (type === BI.Events.COLLAPSE) { self._hideView(); } - if (type === BI.Events.EXPAND || type === BI.Events.COLLAPSE) { + if (type === BI.Events.EXPAND) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.Switcher.EVENT_EXPAND); + } + if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.isViewVisible() && self.fireEvent(BI.Switcher.EVENT_COLLAPSE); } if (type === BI.Events.CLICK) { self.fireEvent(BI.Switcher.EVENT_TRIGGER_CHANGE, value, obj); @@ -32490,6 +32499,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { mergeCols: [], mergeRule: BI.emptyFn, columnSize: [], + minColumnSize: [], + maxColumnSize: [], freezeCols: [], header: [], items: [], diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 18ef17019..2f79b2930 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -41,10 +41,14 @@ BI.Combo = BI.inherit(BI.Widget, { if (type === BI.Events.COLLAPSE) { self._hideView(); } - if (type === BI.Events.EXPAND || type === BI.Events.COLLAPSE) { + if (type === BI.Events.EXPAND) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.Combo.EVENT_EXPAND); + } + if (type === BI.Events.COLLAPSE) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.isViewVisible() && self.fireEvent(BI.Combo.EVENT_COLLAPSE); } - if (type === BI.Events.CLICK) { self.fireEvent(BI.Combo.EVENT_TRIGGER_CHANGE, obj); } diff --git a/src/base/combination/expander.js b/src/base/combination/expander.js index a204124d3..8c57326af 100644 --- a/src/base/combination/expander.js +++ b/src/base/combination/expander.js @@ -41,7 +41,7 @@ BI.Expander = BI.inherit(BI.Widget, { } if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - self.fireEvent(BI.Expander.EVENT_COLLAPSE); + self.isViewVisible() && self.fireEvent(BI.Expander.EVENT_COLLAPSE); } if (type === BI.Events.CLICK) { self.fireEvent(BI.Expander.EVENT_TRIGGER_CHANGE, value, obj); diff --git a/src/base/combination/switcher.js b/src/base/combination/switcher.js index 9428fa81c..a4edaec70 100644 --- a/src/base/combination/switcher.js +++ b/src/base/combination/switcher.js @@ -35,8 +35,13 @@ BI.Switcher = BI.inherit(BI.Widget, { if (type === BI.Events.COLLAPSE) { self._hideView(); } - if (type === BI.Events.EXPAND || type === BI.Events.COLLAPSE) { + if (type === BI.Events.EXPAND) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.Switcher.EVENT_EXPAND); + } + if (type === BI.Events.COLLAPSE) { self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.isViewVisible() && self.fireEvent(BI.Switcher.EVENT_COLLAPSE); } if (type === BI.Events.CLICK) { self.fireEvent(BI.Switcher.EVENT_TRIGGER_CHANGE, value, obj); diff --git a/src/base/table/table.resizable.js b/src/base/table/table.resizable.js index 1055ef37a..2a9194294 100644 --- a/src/base/table/table.resizable.js +++ b/src/base/table/table.resizable.js @@ -22,6 +22,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { mergeCols: [], mergeRule: BI.emptyFn, columnSize: [], + minColumnSize: [], + maxColumnSize: [], freezeCols: [], header: [], items: [], From dd7032324ba46f853823a4e86d6276f245dba6fe Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 5 Jun 2017 18:43:51 +0800 Subject: [PATCH 22/27] columnresizer --- bi/base.css | 6 +++ bi/base.js | 46 +++++++++++++++---- docs/base.css | 6 +++ docs/base.js | 46 +++++++++++++++---- src/base/table/table.resizable.cell.js | 22 ++++++++- src/base/table/table.resizable.js | 24 +++++++--- src/css/base/table/table.resizable.cell.css | 3 ++ src/css/base/table/table.resizable.css | 3 ++ src/less/base/table/table.resizable.cell.less | 5 ++ src/less/base/table/table.resizable.less | 5 +- 10 files changed, 138 insertions(+), 28 deletions(-) diff --git a/bi/base.css b/bi/base.css index b9ac8ced1..5d30a881e 100644 --- a/bi/base.css +++ b/bi/base.css @@ -1289,6 +1289,9 @@ li.CodeMirror-hint-active { .bi-resizable-table-cell .resizable-table-cell-resizer-container.dragging .resizable-table-cell-resizer-knob { background-color: #3f8ce8; } +.bi-resizable-table-cell .resizable-table-cell-resizer-container.suitable .resizable-table-cell-resizer-knob { + background-color: #58cc7d; +} /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ @@ -1297,6 +1300,9 @@ li.CodeMirror-hint-active { z-index: 1; background-color: #3f8ce8; } +.bi-resizable-table .resizable-table-resizer.suitable { + background-color: #58cc7d; +} .bi-resizable-table .resizable-table-region-resizer { cursor: ew-resize; z-index: 1; diff --git a/bi/base.js b/bi/base.js index d6145caa9..387de77a2 100644 --- a/bi/base.js +++ b/bi/base.js @@ -32403,6 +32403,9 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { return BI.extend(BI.ResizableTableCell.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-resizable-table-cell", cell: {}, + minSize: 15, + // suitableSize, + maxSize: Number.MAX_VALUE, start: BI.emptyFn, resize: BI.emptyFn, stop: BI.emptyFn @@ -32416,22 +32419,37 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { var startDrag = false; var size = 0, offset = 0, defaultSize = o.width; + + function optimizeSize(size) { + size = BI.clamp(size, o.minSize, o.maxSize || Number.MAX_VALUE); + if (o.suitableSize) { + if (Math.abs(o.suitableSize - size) < 5) { + size = o.suitableSize; + self.handler.element.addClass("suitable"); + } else { + self.handler.element.removeClass("suitable"); + } + } + return size; + } + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { if (mouseMoveTracker.isDragging()) { startDrag = true; offset += deltaX; - size = BI.clamp(defaultSize + offset, 15, Number.MAX_VALUE); + size = optimizeSize(defaultSize + offset); self.handler.element.addClass("dragging"); o.resize(size); } }, function () { if (startDrag === true) { - size = BI.clamp(size, 15, Number.MAX_VALUE); + size = optimizeSize(size); o.stop(size); size = 0; offset = 0; defaultSize = o.width; self.handler.element.removeClass("dragging"); + self.handler.element.removeClass("suitable"); startDrag = false; } mouseMoveTracker.releaseMouseMoves(); @@ -32699,14 +32717,20 @@ BI.ResizableTable = BI.inherit(BI.Widget, { _formatHeader: function (header) { var self = this, o = this.options; var result = []; - var resize = function (j, size) { + var resize = function (j, i, size) { self.resizer.setVisible(true); var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); - + if (o.minColumnSize[i]) { + if (Math.abs(size - o.minColumnSize[i]) < 5) { + self.resizer.element.addClass("suitable"); + } else { + self.resizer.element.removeClass("suitable"); + } + } self._setResizerPosition(self._getResizerLeft(j) + size, (o.header.length - 1) * o.headerRowSize); }; - var stop = function (j, size) { + var stop = function (j, i, size) { self.resizer.setVisible(false); var columnSize = o.columnSize.slice(); columnSize[j] = size; @@ -32726,8 +32750,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { result[i][j] = { type: "bi.resizable_table_cell", cell: col, - resize: BI.bind(resize, null, j), - stop: BI.bind(stop, null, j) + suitableSize: o.minColumnSize[i], + maxSize: o.maxColumnSize[i], + resize: BI.bind(resize, null, j, i), + stop: BI.bind(stop, null, j, i) }; if (o.isNeedMerge) { var r = i; @@ -32735,8 +32761,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { result[r - 1][j] = { type: "bi.resizable_table_cell", cell: result[r - 1][j], - resize: BI.bind(resize, null, j), - stop: BI.bind(stop, null, j) + suitableSize: o.minColumnSize[i], + maxSize: o.maxColumnSize[i], + resize: BI.bind(resize, null, j, i), + stop: BI.bind(stop, null, j, i) }; r--; } diff --git a/docs/base.css b/docs/base.css index b9ac8ced1..5d30a881e 100644 --- a/docs/base.css +++ b/docs/base.css @@ -1289,6 +1289,9 @@ li.CodeMirror-hint-active { .bi-resizable-table-cell .resizable-table-cell-resizer-container.dragging .resizable-table-cell-resizer-knob { background-color: #3f8ce8; } +.bi-resizable-table-cell .resizable-table-cell-resizer-container.suitable .resizable-table-cell-resizer-knob { + background-color: #58cc7d; +} /****添加计算宽度的--运算符直接需要space****/ /****** common color(常用颜色,可用于普遍场景) *****/ /**** custom color(自定义颜色,用于特定场景) ****/ @@ -1297,6 +1300,9 @@ li.CodeMirror-hint-active { z-index: 1; background-color: #3f8ce8; } +.bi-resizable-table .resizable-table-resizer.suitable { + background-color: #58cc7d; +} .bi-resizable-table .resizable-table-region-resizer { cursor: ew-resize; z-index: 1; diff --git a/docs/base.js b/docs/base.js index d6145caa9..387de77a2 100644 --- a/docs/base.js +++ b/docs/base.js @@ -32403,6 +32403,9 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { return BI.extend(BI.ResizableTableCell.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-resizable-table-cell", cell: {}, + minSize: 15, + // suitableSize, + maxSize: Number.MAX_VALUE, start: BI.emptyFn, resize: BI.emptyFn, stop: BI.emptyFn @@ -32416,22 +32419,37 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { var startDrag = false; var size = 0, offset = 0, defaultSize = o.width; + + function optimizeSize(size) { + size = BI.clamp(size, o.minSize, o.maxSize || Number.MAX_VALUE); + if (o.suitableSize) { + if (Math.abs(o.suitableSize - size) < 5) { + size = o.suitableSize; + self.handler.element.addClass("suitable"); + } else { + self.handler.element.removeClass("suitable"); + } + } + return size; + } + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { if (mouseMoveTracker.isDragging()) { startDrag = true; offset += deltaX; - size = BI.clamp(defaultSize + offset, 15, Number.MAX_VALUE); + size = optimizeSize(defaultSize + offset); self.handler.element.addClass("dragging"); o.resize(size); } }, function () { if (startDrag === true) { - size = BI.clamp(size, 15, Number.MAX_VALUE); + size = optimizeSize(size); o.stop(size); size = 0; offset = 0; defaultSize = o.width; self.handler.element.removeClass("dragging"); + self.handler.element.removeClass("suitable"); startDrag = false; } mouseMoveTracker.releaseMouseMoves(); @@ -32699,14 +32717,20 @@ BI.ResizableTable = BI.inherit(BI.Widget, { _formatHeader: function (header) { var self = this, o = this.options; var result = []; - var resize = function (j, size) { + var resize = function (j, i, size) { self.resizer.setVisible(true); var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); - + if (o.minColumnSize[i]) { + if (Math.abs(size - o.minColumnSize[i]) < 5) { + self.resizer.element.addClass("suitable"); + } else { + self.resizer.element.removeClass("suitable"); + } + } self._setResizerPosition(self._getResizerLeft(j) + size, (o.header.length - 1) * o.headerRowSize); }; - var stop = function (j, size) { + var stop = function (j, i, size) { self.resizer.setVisible(false); var columnSize = o.columnSize.slice(); columnSize[j] = size; @@ -32726,8 +32750,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { result[i][j] = { type: "bi.resizable_table_cell", cell: col, - resize: BI.bind(resize, null, j), - stop: BI.bind(stop, null, j) + suitableSize: o.minColumnSize[i], + maxSize: o.maxColumnSize[i], + resize: BI.bind(resize, null, j, i), + stop: BI.bind(stop, null, j, i) }; if (o.isNeedMerge) { var r = i; @@ -32735,8 +32761,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { result[r - 1][j] = { type: "bi.resizable_table_cell", cell: result[r - 1][j], - resize: BI.bind(resize, null, j), - stop: BI.bind(stop, null, j) + suitableSize: o.minColumnSize[i], + maxSize: o.maxColumnSize[i], + resize: BI.bind(resize, null, j, i), + stop: BI.bind(stop, null, j, i) }; r--; } diff --git a/src/base/table/table.resizable.cell.js b/src/base/table/table.resizable.cell.js index ad8c08a03..be9a9f55d 100644 --- a/src/base/table/table.resizable.cell.js +++ b/src/base/table/table.resizable.cell.js @@ -11,6 +11,9 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { return BI.extend(BI.ResizableTableCell.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-resizable-table-cell", cell: {}, + minSize: 15, + // suitableSize, + maxSize: Number.MAX_VALUE, start: BI.emptyFn, resize: BI.emptyFn, stop: BI.emptyFn @@ -24,22 +27,37 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { var startDrag = false; var size = 0, offset = 0, defaultSize = o.width; + + function optimizeSize(size) { + size = BI.clamp(size, o.minSize, o.maxSize || Number.MAX_VALUE); + if (o.suitableSize) { + if (Math.abs(o.suitableSize - size) < 5) { + size = o.suitableSize; + self.handler.element.addClass("suitable"); + } else { + self.handler.element.removeClass("suitable"); + } + } + return size; + } + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { if (mouseMoveTracker.isDragging()) { startDrag = true; offset += deltaX; - size = BI.clamp(defaultSize + offset, 15, Number.MAX_VALUE); + size = optimizeSize(defaultSize + offset); self.handler.element.addClass("dragging"); o.resize(size); } }, function () { if (startDrag === true) { - size = BI.clamp(size, 15, Number.MAX_VALUE); + size = optimizeSize(size); o.stop(size); size = 0; offset = 0; defaultSize = o.width; self.handler.element.removeClass("dragging"); + self.handler.element.removeClass("suitable"); startDrag = false; } mouseMoveTracker.releaseMouseMoves(); diff --git a/src/base/table/table.resizable.js b/src/base/table/table.resizable.js index 2a9194294..edd654275 100644 --- a/src/base/table/table.resizable.js +++ b/src/base/table/table.resizable.js @@ -212,14 +212,20 @@ BI.ResizableTable = BI.inherit(BI.Widget, { _formatHeader: function (header) { var self = this, o = this.options; var result = []; - var resize = function (j, size) { + var resize = function (j, i, size) { self.resizer.setVisible(true); var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); - + if (o.minColumnSize[i]) { + if (Math.abs(size - o.minColumnSize[i]) < 5) { + self.resizer.element.addClass("suitable"); + } else { + self.resizer.element.removeClass("suitable"); + } + } self._setResizerPosition(self._getResizerLeft(j) + size, (o.header.length - 1) * o.headerRowSize); }; - var stop = function (j, size) { + var stop = function (j, i, size) { self.resizer.setVisible(false); var columnSize = o.columnSize.slice(); columnSize[j] = size; @@ -239,8 +245,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { result[i][j] = { type: "bi.resizable_table_cell", cell: col, - resize: BI.bind(resize, null, j), - stop: BI.bind(stop, null, j) + suitableSize: o.minColumnSize[i], + maxSize: o.maxColumnSize[i], + resize: BI.bind(resize, null, j, i), + stop: BI.bind(stop, null, j, i) }; if (o.isNeedMerge) { var r = i; @@ -248,8 +256,10 @@ BI.ResizableTable = BI.inherit(BI.Widget, { result[r - 1][j] = { type: "bi.resizable_table_cell", cell: result[r - 1][j], - resize: BI.bind(resize, null, j), - stop: BI.bind(stop, null, j) + suitableSize: o.minColumnSize[i], + maxSize: o.maxColumnSize[i], + resize: BI.bind(resize, null, j, i), + stop: BI.bind(stop, null, j, i) }; r--; } diff --git a/src/css/base/table/table.resizable.cell.css b/src/css/base/table/table.resizable.cell.css index d080f2994..214340d95 100644 --- a/src/css/base/table/table.resizable.cell.css +++ b/src/css/base/table/table.resizable.cell.css @@ -9,3 +9,6 @@ .bi-resizable-table-cell .resizable-table-cell-resizer-container.dragging .resizable-table-cell-resizer-knob { background-color: #3f8ce8; } +.bi-resizable-table-cell .resizable-table-cell-resizer-container.suitable .resizable-table-cell-resizer-knob { + background-color: #58cc7d; +} diff --git a/src/css/base/table/table.resizable.css b/src/css/base/table/table.resizable.css index 71921f5f6..fc7321608 100644 --- a/src/css/base/table/table.resizable.css +++ b/src/css/base/table/table.resizable.css @@ -6,6 +6,9 @@ z-index: 1; background-color: #3f8ce8; } +.bi-resizable-table .resizable-table-resizer.suitable { + background-color: #58cc7d; +} .bi-resizable-table .resizable-table-region-resizer { cursor: ew-resize; z-index: 1; diff --git a/src/less/base/table/table.resizable.cell.less b/src/less/base/table/table.resizable.cell.less index ea7ca49fb..63d67d400 100644 --- a/src/less/base/table/table.resizable.cell.less +++ b/src/less/base/table/table.resizable.cell.less @@ -9,5 +9,10 @@ background-color: @color-bi-background-highlight; } } + &.suitable{ + & .resizable-table-cell-resizer-knob { + background-color: @color-bi-background-success; + } + } } } \ No newline at end of file diff --git a/src/less/base/table/table.resizable.less b/src/less/base/table/table.resizable.less index 737a5e8db..d9ad74635 100644 --- a/src/less/base/table/table.resizable.less +++ b/src/less/base/table/table.resizable.less @@ -1,10 +1,13 @@ @import "../../bibase"; .bi-resizable-table { - & .resizable-table-resizer{ + & .resizable-table-resizer { cursor: ew-resize; z-index: 1; background-color: @color-bi-background-highlight; + &.suitable { + background-color: @color-bi-background-success; + } } & .resizable-table-region-resizer { cursor: ew-resize; From b9a88919b1d0cb788d20ac3e63db98f90b5b495b Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 5 Jun 2017 18:53:06 +0800 Subject: [PATCH 23/27] add --- bi/base.js | 2 +- docs/base.js | 2 +- src/base/table/table.resizable.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bi/base.js b/bi/base.js index 387de77a2..2e3c1b429 100644 --- a/bi/base.js +++ b/bi/base.js @@ -32722,7 +32722,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); if (o.minColumnSize[i]) { - if (Math.abs(size - o.minColumnSize[i]) < 5) { + if (size === o.minColumnSize[i]) { self.resizer.element.addClass("suitable"); } else { self.resizer.element.removeClass("suitable"); diff --git a/docs/base.js b/docs/base.js index 387de77a2..2e3c1b429 100644 --- a/docs/base.js +++ b/docs/base.js @@ -32722,7 +32722,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); if (o.minColumnSize[i]) { - if (Math.abs(size - o.minColumnSize[i]) < 5) { + if (size === o.minColumnSize[i]) { self.resizer.element.addClass("suitable"); } else { self.resizer.element.removeClass("suitable"); diff --git a/src/base/table/table.resizable.js b/src/base/table/table.resizable.js index edd654275..8ed7572c6 100644 --- a/src/base/table/table.resizable.js +++ b/src/base/table/table.resizable.js @@ -217,7 +217,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); if (o.minColumnSize[i]) { - if (Math.abs(size - o.minColumnSize[i]) < 5) { + if (size === o.minColumnSize[i]) { self.resizer.element.addClass("suitable"); } else { self.resizer.element.removeClass("suitable"); From ee6c040ef099474e0da1ec2b58e99193c2e8b07a Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 5 Jun 2017 20:48:57 +0800 Subject: [PATCH 24/27] add --- bi/base.js | 26 +++++++++++++------------- docs/base.js | 26 +++++++++++++------------- src/base/table/table.resizable.cell.js | 10 +++++----- src/base/table/table.resizable.js | 16 ++++++++-------- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/bi/base.js b/bi/base.js index 2e3c1b429..6df42bb8b 100644 --- a/bi/base.js +++ b/bi/base.js @@ -32420,17 +32420,17 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { var startDrag = false; var size = 0, offset = 0, defaultSize = o.width; - function optimizeSize(size) { - size = BI.clamp(size, o.minSize, o.maxSize || Number.MAX_VALUE); + function optimizeSize(s) { + var optSize = BI.clamp(s, o.minSize, o.maxSize || Number.MAX_VALUE); if (o.suitableSize) { - if (Math.abs(o.suitableSize - size) < 5) { - size = o.suitableSize; + if (Math.abs(o.suitableSize - optSize) < 5) { + optSize = o.suitableSize; self.handler.element.addClass("suitable"); } else { self.handler.element.removeClass("suitable"); } } - return size; + return optSize; } var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { @@ -32717,12 +32717,12 @@ BI.ResizableTable = BI.inherit(BI.Widget, { _formatHeader: function (header) { var self = this, o = this.options; var result = []; - var resize = function (j, i, size) { + var resize = function (j, size) { self.resizer.setVisible(true); var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); - if (o.minColumnSize[i]) { - if (size === o.minColumnSize[i]) { + if (o.minColumnSize[j]) { + if (size === o.minColumnSize[j]) { self.resizer.element.addClass("suitable"); } else { self.resizer.element.removeClass("suitable"); @@ -32730,7 +32730,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { } self._setResizerPosition(self._getResizerLeft(j) + size, (o.header.length - 1) * o.headerRowSize); }; - var stop = function (j, i, size) { + var stop = function (j, size) { self.resizer.setVisible(false); var columnSize = o.columnSize.slice(); columnSize[j] = size; @@ -32752,8 +32752,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { cell: col, suitableSize: o.minColumnSize[i], maxSize: o.maxColumnSize[i], - resize: BI.bind(resize, null, j, i), - stop: BI.bind(stop, null, j, i) + resize: BI.bind(resize, null, j), + stop: BI.bind(stop, null, j) }; if (o.isNeedMerge) { var r = i; @@ -32763,8 +32763,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { cell: result[r - 1][j], suitableSize: o.minColumnSize[i], maxSize: o.maxColumnSize[i], - resize: BI.bind(resize, null, j, i), - stop: BI.bind(stop, null, j, i) + resize: BI.bind(resize, null, j), + stop: BI.bind(stop, null, j) }; r--; } diff --git a/docs/base.js b/docs/base.js index 2e3c1b429..6df42bb8b 100644 --- a/docs/base.js +++ b/docs/base.js @@ -32420,17 +32420,17 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { var startDrag = false; var size = 0, offset = 0, defaultSize = o.width; - function optimizeSize(size) { - size = BI.clamp(size, o.minSize, o.maxSize || Number.MAX_VALUE); + function optimizeSize(s) { + var optSize = BI.clamp(s, o.minSize, o.maxSize || Number.MAX_VALUE); if (o.suitableSize) { - if (Math.abs(o.suitableSize - size) < 5) { - size = o.suitableSize; + if (Math.abs(o.suitableSize - optSize) < 5) { + optSize = o.suitableSize; self.handler.element.addClass("suitable"); } else { self.handler.element.removeClass("suitable"); } } - return size; + return optSize; } var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { @@ -32717,12 +32717,12 @@ BI.ResizableTable = BI.inherit(BI.Widget, { _formatHeader: function (header) { var self = this, o = this.options; var result = []; - var resize = function (j, i, size) { + var resize = function (j, size) { self.resizer.setVisible(true); var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); - if (o.minColumnSize[i]) { - if (size === o.minColumnSize[i]) { + if (o.minColumnSize[j]) { + if (size === o.minColumnSize[j]) { self.resizer.element.addClass("suitable"); } else { self.resizer.element.removeClass("suitable"); @@ -32730,7 +32730,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { } self._setResizerPosition(self._getResizerLeft(j) + size, (o.header.length - 1) * o.headerRowSize); }; - var stop = function (j, i, size) { + var stop = function (j, size) { self.resizer.setVisible(false); var columnSize = o.columnSize.slice(); columnSize[j] = size; @@ -32752,8 +32752,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { cell: col, suitableSize: o.minColumnSize[i], maxSize: o.maxColumnSize[i], - resize: BI.bind(resize, null, j, i), - stop: BI.bind(stop, null, j, i) + resize: BI.bind(resize, null, j), + stop: BI.bind(stop, null, j) }; if (o.isNeedMerge) { var r = i; @@ -32763,8 +32763,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { cell: result[r - 1][j], suitableSize: o.minColumnSize[i], maxSize: o.maxColumnSize[i], - resize: BI.bind(resize, null, j, i), - stop: BI.bind(stop, null, j, i) + resize: BI.bind(resize, null, j), + stop: BI.bind(stop, null, j) }; r--; } diff --git a/src/base/table/table.resizable.cell.js b/src/base/table/table.resizable.cell.js index be9a9f55d..cd1d565c8 100644 --- a/src/base/table/table.resizable.cell.js +++ b/src/base/table/table.resizable.cell.js @@ -28,17 +28,17 @@ BI.ResizableTableCell = BI.inherit(BI.Widget, { var startDrag = false; var size = 0, offset = 0, defaultSize = o.width; - function optimizeSize(size) { - size = BI.clamp(size, o.minSize, o.maxSize || Number.MAX_VALUE); + function optimizeSize(s) { + var optSize = BI.clamp(s, o.minSize, o.maxSize || Number.MAX_VALUE); if (o.suitableSize) { - if (Math.abs(o.suitableSize - size) < 5) { - size = o.suitableSize; + if (Math.abs(o.suitableSize - optSize) < 5) { + optSize = o.suitableSize; self.handler.element.addClass("suitable"); } else { self.handler.element.removeClass("suitable"); } } - return size; + return optSize; } var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { diff --git a/src/base/table/table.resizable.js b/src/base/table/table.resizable.js index 8ed7572c6..bca89e215 100644 --- a/src/base/table/table.resizable.js +++ b/src/base/table/table.resizable.js @@ -212,12 +212,12 @@ BI.ResizableTable = BI.inherit(BI.Widget, { _formatHeader: function (header) { var self = this, o = this.options; var result = []; - var resize = function (j, i, size) { + var resize = function (j, size) { self.resizer.setVisible(true); var height = o.headerRowSize + self._getRegionRowSize()[1]; self.resizer.setHeight(height); - if (o.minColumnSize[i]) { - if (size === o.minColumnSize[i]) { + if (o.minColumnSize[j]) { + if (size === o.minColumnSize[j]) { self.resizer.element.addClass("suitable"); } else { self.resizer.element.removeClass("suitable"); @@ -225,7 +225,7 @@ BI.ResizableTable = BI.inherit(BI.Widget, { } self._setResizerPosition(self._getResizerLeft(j) + size, (o.header.length - 1) * o.headerRowSize); }; - var stop = function (j, i, size) { + var stop = function (j, size) { self.resizer.setVisible(false); var columnSize = o.columnSize.slice(); columnSize[j] = size; @@ -247,8 +247,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { cell: col, suitableSize: o.minColumnSize[i], maxSize: o.maxColumnSize[i], - resize: BI.bind(resize, null, j, i), - stop: BI.bind(stop, null, j, i) + resize: BI.bind(resize, null, j), + stop: BI.bind(stop, null, j) }; if (o.isNeedMerge) { var r = i; @@ -258,8 +258,8 @@ BI.ResizableTable = BI.inherit(BI.Widget, { cell: result[r - 1][j], suitableSize: o.minColumnSize[i], maxSize: o.maxColumnSize[i], - resize: BI.bind(resize, null, j, i), - stop: BI.bind(stop, null, j, i) + resize: BI.bind(resize, null, j), + stop: BI.bind(stop, null, j) }; r--; } From 7ca0803b60ef2b0c3d1acfcf2453c6a8cc41d512 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 6 Jun 2017 09:27:25 +0800 Subject: [PATCH 25/27] update --- bi/widget.js | 32 +++++++++-------------- docs/widget.js | 32 +++++++++-------------- src/widget/downlist/item.downlistgroup.js | 32 +++++++++-------------- 3 files changed, 36 insertions(+), 60 deletions(-) diff --git a/bi/widget.js b/bi/widget.js index 39789204c..dd99f936f 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -5792,7 +5792,7 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe logic: { dynamic: false }, - invalid: true, + // invalid: true, iconCls1: "dot-e-font", iconCls2: "pull-right-e-font" }) @@ -5808,26 +5808,26 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe text: o.text, value: o.value, height: o.height - }) + }); this.icon1 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls1, width: 25, forceNotSelected: true - }) + }); this.icon2 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls2, width: 25, forceNotSelected: true - }) + }); var blank = BI.createWidget({ type: "bi.layout", width: 25 - }) + }); BI.createWidget({ type: "bi.absolute", element: this, @@ -5837,7 +5837,7 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe bottom: 0, right: 0 }] - }) + }); BI.createWidget(BI.extend({ element: this @@ -5845,19 +5845,11 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) })))); - this.element.on("mouseenter." + this.getName(), function (e) { - if (self.element.__isMouseInBounds__(e) && self.isEnabled()) { + this.element.hover(function () { + if (self.isEnabled()) { self.hover(); - } else { - self.dishover(); - } - }); - this.element.on("mousemove." + this.getName(), function (e) { - if (!self.element.__isMouseInBounds__(e) && self.isEnabled()) { - self.dishover() } - }); - this.element.on("mouseleave." + this.getName(), function () { + }, function () { if (self.isEnabled()) { self.dishover() } @@ -5895,11 +5887,11 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe setValue: function (v) { var self = this, o = this.options; v = BI.isArray(v) ? v : [v]; - BI.find(v, function(idx, value){ - if(BI.contains(o.childValues, value)){ + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { self.icon1.setSelected(true); return true; - }else{ + } else { self.icon1.setSelected(false); } }) diff --git a/docs/widget.js b/docs/widget.js index 39789204c..dd99f936f 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -5792,7 +5792,7 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe logic: { dynamic: false }, - invalid: true, + // invalid: true, iconCls1: "dot-e-font", iconCls2: "pull-right-e-font" }) @@ -5808,26 +5808,26 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe text: o.text, value: o.value, height: o.height - }) + }); this.icon1 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls1, width: 25, forceNotSelected: true - }) + }); this.icon2 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls2, width: 25, forceNotSelected: true - }) + }); var blank = BI.createWidget({ type: "bi.layout", width: 25 - }) + }); BI.createWidget({ type: "bi.absolute", element: this, @@ -5837,7 +5837,7 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe bottom: 0, right: 0 }] - }) + }); BI.createWidget(BI.extend({ element: this @@ -5845,19 +5845,11 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) })))); - this.element.on("mouseenter." + this.getName(), function (e) { - if (self.element.__isMouseInBounds__(e) && self.isEnabled()) { + this.element.hover(function () { + if (self.isEnabled()) { self.hover(); - } else { - self.dishover(); - } - }); - this.element.on("mousemove." + this.getName(), function (e) { - if (!self.element.__isMouseInBounds__(e) && self.isEnabled()) { - self.dishover() } - }); - this.element.on("mouseleave." + this.getName(), function () { + }, function () { if (self.isEnabled()) { self.dishover() } @@ -5895,11 +5887,11 @@ BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inhe setValue: function (v) { var self = this, o = this.options; v = BI.isArray(v) ? v : [v]; - BI.find(v, function(idx, value){ - if(BI.contains(o.childValues, value)){ + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { self.icon1.setSelected(true); return true; - }else{ + } else { self.icon1.setSelected(false); } }) diff --git a/src/widget/downlist/item.downlistgroup.js b/src/widget/downlist/item.downlistgroup.js index 59a301e1d..8d55da9f4 100644 --- a/src/widget/downlist/item.downlistgroup.js +++ b/src/widget/downlist/item.downlistgroup.js @@ -6,7 +6,7 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { logic: { dynamic: false }, - invalid: true, + // invalid: true, iconCls1: "dot-e-font", iconCls2: "pull-right-e-font" }) @@ -22,26 +22,26 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { text: o.text, value: o.value, height: o.height - }) + }); this.icon1 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls1, width: 25, forceNotSelected: true - }) + }); this.icon2 = BI.createWidget({ type: "bi.icon_button", cls: o.iconCls2, width: 25, forceNotSelected: true - }) + }); var blank = BI.createWidget({ type: "bi.layout", width: 25 - }) + }); BI.createWidget({ type: "bi.absolute", element: this, @@ -51,7 +51,7 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { bottom: 0, right: 0 }] - }) + }); BI.createWidget(BI.extend({ element: this @@ -59,19 +59,11 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) })))); - this.element.on("mouseenter." + this.getName(), function (e) { - if (self.element.__isMouseInBounds__(e) && self.isEnabled()) { + this.element.hover(function () { + if (self.isEnabled()) { self.hover(); - } else { - self.dishover(); - } - }); - this.element.on("mousemove." + this.getName(), function (e) { - if (!self.element.__isMouseInBounds__(e) && self.isEnabled()) { - self.dishover() } - }); - this.element.on("mouseleave." + this.getName(), function () { + }, function () { if (self.isEnabled()) { self.dishover() } @@ -109,11 +101,11 @@ BI.DownListGroupItem = BI.inherit(BI.BasicButton, { setValue: function (v) { var self = this, o = this.options; v = BI.isArray(v) ? v : [v]; - BI.find(v, function(idx, value){ - if(BI.contains(o.childValues, value)){ + BI.find(v, function (idx, value) { + if (BI.contains(o.childValues, value)) { self.icon1.setSelected(true); return true; - }else{ + } else { self.icon1.setSelected(false); } }) From 6c386ebd1158edc7cf79fe9c4bc2582c484099b0 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 6 Jun 2017 12:10:24 +0800 Subject: [PATCH 26/27] =?UTF-8?q?=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bi/base.js | 107 ++++++++++++++++++++--------- bi/core.js | 7 +- docs/base.js | 107 ++++++++++++++++++++--------- docs/core.js | 7 +- src/base/table/table.collection.js | 66 ++++++++++++------ src/base/table/table.grid.js | 41 +++++++---- src/core/widget.js | 7 +- 7 files changed, 231 insertions(+), 111 deletions(-) diff --git a/bi/base.js b/bi/base.js index 6df42bb8b..9aa2a6024 100644 --- a/bi/base.js +++ b/bi/base.js @@ -29054,11 +29054,26 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; }, + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + _populateScrollbar: function () { var o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -29072,8 +29087,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; } }); - this.topScrollbar.setContentSize(o.items.length * o.rowSize); - this.topScrollbar.setSize(this._height - o.header.length * o.headerRowSize); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); this.topScrollbar.populate(); @@ -29088,7 +29103,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.rightScrollbar.populate(); var items = this.scrollBarLayout.attr("items"); - items[0].top = o.header.length * o.headerRowSize; + items[0].top = this._getFreezeHeaderHeight(); items[1].top = this._height; items[2].top = this._height; items[2].left = regionSize; @@ -29099,8 +29114,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -29116,13 +29130,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); var otlw = regionSize; - var otlh = o.header.length * o.headerRowSize; + var otlh = this._getFreezeHeaderHeight(); var otrw = this._width - regionSize; - var otrh = o.header.length * o.headerRowSize; + var otrh = this._getFreezeHeaderHeight(); var oblw = regionSize; - var oblh = this._height - o.header.length * o.headerRowSize; + var oblh = this._height - otlh; var obrw = this._width - regionSize; - var obrh = this._height - o.header.length * o.headerRowSize; + var obrh = this._height - otrh; var tlw = otlw + this._scrollBarSize; var tlh = otlh + this._scrollBarSize; @@ -29166,9 +29180,9 @@ BI.CollectionTable = BI.inherit(BI.Widget, { var items = this.contextLayout.attr("items"); items[1].left = regionSize; - items[2].top = o.header.length * o.headerRowSize; + items[2].top = this._getFreezeHeaderHeight(); items[3].left = regionSize; - items[3].top = o.header.length * o.headerRowSize; + items[3].top = this._getFreezeHeaderHeight(); this.contextLayout.attr("items", items); this.contextLayout.resize(); @@ -29184,8 +29198,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }; run(this.topLeftItems, o.header, leftHeader); run(this.topRightItems, o.header, rightHeader); - run(this.bottomLeftItems, o.items, leftItems); - run(this.bottomRightItems, o.items, rightItems); + run(this.bottomLeftItems, this._getActualItems(), leftItems); + run(this.bottomRightItems, this._getActualItems(), rightItems); this.topLeftCollection._populate(leftHeader); this.topRightCollection._populate(rightHeader); @@ -29196,13 +29210,23 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _digest: function () { var o = this.options; var freezeColLength = this._getFreezeColLength(); - this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); - this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); - this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); - this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } }, - _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols) { + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; var self = this, o = this.options; var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; var summaryColumnSize = []; @@ -29252,7 +29276,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { } cache[i][j] = cols[j]; map[i][j] = {}; - if (mergeCols === true || mergeCols.indexOf(j) > -1) { + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { if (i === 0 && j === startCol) { createOneEl(0, startCol); } else if (j === startCol && i > 0) { @@ -29838,11 +29862,26 @@ BI.GridTable = BI.inherit(BI.Widget, { return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; }, + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + _populateScrollbar: function () { var o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -29856,8 +29895,8 @@ BI.GridTable = BI.inherit(BI.Widget, { summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; } }); - this.topScrollbar.setContentSize(o.items.length * o.rowSize); - this.topScrollbar.setSize(this._height - o.header.length * o.headerRowSize); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); this.topScrollbar.setPosition(Math.min(this.bottomLeftGrid.getScrollTop(), this.bottomRightGrid.getScrollTop())); this.topScrollbar.populate(); @@ -29872,7 +29911,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.rightScrollbar.populate(); var items = this.scrollBarLayout.attr("items"); - items[0].top = o.header.length * o.headerRowSize; + items[0].top = this._getFreezeHeaderHeight(); items[1].top = this._height; items[2].top = this._height; items[2].left = regionSize; @@ -29906,7 +29945,7 @@ BI.GridTable = BI.inherit(BI.Widget, { var o = this.options; var freezeColLength = this._getFreezeColLength(); var leftItems = [], rightItems = []; - BI.each(o.items, function (i, cols) { + BI.each(this._getActualItems(), function (i, cols) { leftItems[i] = []; rightItems[i] = []; BI.each(cols, function (j, col) { @@ -29927,7 +29966,7 @@ BI.GridTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + summaryColumnSizeArray = []; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -29944,13 +29983,13 @@ BI.GridTable = BI.inherit(BI.Widget, { }); var otlw = regionSize; - var otlh = o.header.length * o.headerRowSize; + var otlh = this._getFreezeHeaderHeight(); var otrw = this._width - regionSize; - var otrh = o.header.length * o.headerRowSize; + var otrh = this._getFreezeHeaderHeight(); var oblw = regionSize; - var oblh = this._height - o.header.length * o.headerRowSize; + var oblh = this._height - otlh; var obrw = this._width - regionSize; - var obrh = this._height - o.header.length * o.headerRowSize; + var obrh = this._height - otrh; var tlw = otlw + this._scrollBarSize; var tlh = otlh + this._scrollBarSize; @@ -30003,9 +30042,9 @@ BI.GridTable = BI.inherit(BI.Widget, { var items = this.contextLayout.attr("items"); items[1].left = regionSize; - items[2].top = o.header.length * o.headerRowSize; + items[2].top = this._getFreezeHeaderHeight(); items[3].left = regionSize; - items[3].top = o.header.length * o.headerRowSize; + items[3].top = this._getFreezeHeaderHeight(); this.contextLayout.attr("items", items); this.contextLayout.resize(); diff --git a/bi/core.js b/bi/core.js index 100e50c68..87cdaf46e 100644 --- a/bi/core.js +++ b/bi/core.js @@ -4521,7 +4521,7 @@ BI.Widget = BI.inherit(BI.OB, { } //递归将所有子组件使能 BI.each(this._children, function (i, child) { - child._setEnable && child._setEnable(enable); + !child._manualSetEnable && child._setEnable && child._setEnable(enable); }); }, @@ -4533,7 +4533,7 @@ BI.Widget = BI.inherit(BI.OB, { } //递归将所有子组件使有效 BI.each(this._children, function (i, child) { - child._setValid && child._setValid(valid); + !child._manualSetValid && child._setValid && child._setValid(valid); }); }, @@ -4546,6 +4546,7 @@ BI.Widget = BI.inherit(BI.OB, { }, setEnable: function (enable) { + this._manualSetEnable = true; this._setEnable(enable); if (enable === true) { this.element.removeClass("base-disabled disabled"); @@ -4567,7 +4568,7 @@ BI.Widget = BI.inherit(BI.OB, { }, setValid: function (valid) { - this.options.invalid = !valid; + this._manualSetValid = true; this._setValid(valid); if (valid === true) { this.element.removeClass("base-invalid invalid"); diff --git a/docs/base.js b/docs/base.js index 6df42bb8b..9aa2a6024 100644 --- a/docs/base.js +++ b/docs/base.js @@ -29054,11 +29054,26 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; }, + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + _populateScrollbar: function () { var o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -29072,8 +29087,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; } }); - this.topScrollbar.setContentSize(o.items.length * o.rowSize); - this.topScrollbar.setSize(this._height - o.header.length * o.headerRowSize); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); this.topScrollbar.populate(); @@ -29088,7 +29103,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.rightScrollbar.populate(); var items = this.scrollBarLayout.attr("items"); - items[0].top = o.header.length * o.headerRowSize; + items[0].top = this._getFreezeHeaderHeight(); items[1].top = this._height; items[2].top = this._height; items[2].left = regionSize; @@ -29099,8 +29114,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -29116,13 +29130,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); var otlw = regionSize; - var otlh = o.header.length * o.headerRowSize; + var otlh = this._getFreezeHeaderHeight(); var otrw = this._width - regionSize; - var otrh = o.header.length * o.headerRowSize; + var otrh = this._getFreezeHeaderHeight(); var oblw = regionSize; - var oblh = this._height - o.header.length * o.headerRowSize; + var oblh = this._height - otlh; var obrw = this._width - regionSize; - var obrh = this._height - o.header.length * o.headerRowSize; + var obrh = this._height - otrh; var tlw = otlw + this._scrollBarSize; var tlh = otlh + this._scrollBarSize; @@ -29166,9 +29180,9 @@ BI.CollectionTable = BI.inherit(BI.Widget, { var items = this.contextLayout.attr("items"); items[1].left = regionSize; - items[2].top = o.header.length * o.headerRowSize; + items[2].top = this._getFreezeHeaderHeight(); items[3].left = regionSize; - items[3].top = o.header.length * o.headerRowSize; + items[3].top = this._getFreezeHeaderHeight(); this.contextLayout.attr("items", items); this.contextLayout.resize(); @@ -29184,8 +29198,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }; run(this.topLeftItems, o.header, leftHeader); run(this.topRightItems, o.header, rightHeader); - run(this.bottomLeftItems, o.items, leftItems); - run(this.bottomRightItems, o.items, rightItems); + run(this.bottomLeftItems, this._getActualItems(), leftItems); + run(this.bottomRightItems, this._getActualItems(), rightItems); this.topLeftCollection._populate(leftHeader); this.topRightCollection._populate(rightHeader); @@ -29196,13 +29210,23 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _digest: function () { var o = this.options; var freezeColLength = this._getFreezeColLength(); - this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); - this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); - this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); - this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } }, - _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols) { + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; var self = this, o = this.options; var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; var summaryColumnSize = []; @@ -29252,7 +29276,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { } cache[i][j] = cols[j]; map[i][j] = {}; - if (mergeCols === true || mergeCols.indexOf(j) > -1) { + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { if (i === 0 && j === startCol) { createOneEl(0, startCol); } else if (j === startCol && i > 0) { @@ -29838,11 +29862,26 @@ BI.GridTable = BI.inherit(BI.Widget, { return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; }, + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + _populateScrollbar: function () { var o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -29856,8 +29895,8 @@ BI.GridTable = BI.inherit(BI.Widget, { summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; } }); - this.topScrollbar.setContentSize(o.items.length * o.rowSize); - this.topScrollbar.setSize(this._height - o.header.length * o.headerRowSize); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); this.topScrollbar.setPosition(Math.min(this.bottomLeftGrid.getScrollTop(), this.bottomRightGrid.getScrollTop())); this.topScrollbar.populate(); @@ -29872,7 +29911,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.rightScrollbar.populate(); var items = this.scrollBarLayout.attr("items"); - items[0].top = o.header.length * o.headerRowSize; + items[0].top = this._getFreezeHeaderHeight(); items[1].top = this._height; items[2].top = this._height; items[2].left = regionSize; @@ -29906,7 +29945,7 @@ BI.GridTable = BI.inherit(BI.Widget, { var o = this.options; var freezeColLength = this._getFreezeColLength(); var leftItems = [], rightItems = []; - BI.each(o.items, function (i, cols) { + BI.each(this._getActualItems(), function (i, cols) { leftItems[i] = []; rightItems[i] = []; BI.each(cols, function (j, col) { @@ -29927,7 +29966,7 @@ BI.GridTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + summaryColumnSizeArray = []; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -29944,13 +29983,13 @@ BI.GridTable = BI.inherit(BI.Widget, { }); var otlw = regionSize; - var otlh = o.header.length * o.headerRowSize; + var otlh = this._getFreezeHeaderHeight(); var otrw = this._width - regionSize; - var otrh = o.header.length * o.headerRowSize; + var otrh = this._getFreezeHeaderHeight(); var oblw = regionSize; - var oblh = this._height - o.header.length * o.headerRowSize; + var oblh = this._height - otlh; var obrw = this._width - regionSize; - var obrh = this._height - o.header.length * o.headerRowSize; + var obrh = this._height - otrh; var tlw = otlw + this._scrollBarSize; var tlh = otlh + this._scrollBarSize; @@ -30003,9 +30042,9 @@ BI.GridTable = BI.inherit(BI.Widget, { var items = this.contextLayout.attr("items"); items[1].left = regionSize; - items[2].top = o.header.length * o.headerRowSize; + items[2].top = this._getFreezeHeaderHeight(); items[3].left = regionSize; - items[3].top = o.header.length * o.headerRowSize; + items[3].top = this._getFreezeHeaderHeight(); this.contextLayout.attr("items", items); this.contextLayout.resize(); diff --git a/docs/core.js b/docs/core.js index 5103bb804..b89a7f08d 100644 --- a/docs/core.js +++ b/docs/core.js @@ -14523,7 +14523,7 @@ BI.Widget = BI.inherit(BI.OB, { } //递归将所有子组件使能 BI.each(this._children, function (i, child) { - child._setEnable && child._setEnable(enable); + !child._manualSetEnable && child._setEnable && child._setEnable(enable); }); }, @@ -14535,7 +14535,7 @@ BI.Widget = BI.inherit(BI.OB, { } //递归将所有子组件使有效 BI.each(this._children, function (i, child) { - child._setValid && child._setValid(valid); + !child._manualSetValid && child._setValid && child._setValid(valid); }); }, @@ -14548,6 +14548,7 @@ BI.Widget = BI.inherit(BI.OB, { }, setEnable: function (enable) { + this._manualSetEnable = true; this._setEnable(enable); if (enable === true) { this.element.removeClass("base-disabled disabled"); @@ -14569,7 +14570,7 @@ BI.Widget = BI.inherit(BI.OB, { }, setValid: function (valid) { - this.options.invalid = !valid; + this._manualSetValid = true; this._setValid(valid); if (valid === true) { this.element.removeClass("base-invalid invalid"); diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index 63da1b991..ee5aea9aa 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -173,11 +173,26 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; }, + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + _populateScrollbar: function () { var o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -191,8 +206,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; } }); - this.topScrollbar.setContentSize(o.items.length * o.rowSize); - this.topScrollbar.setSize(this._height - o.header.length * o.headerRowSize); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); this.topScrollbar.setPosition(this.bottomRightCollection.getScrollTop()); this.topScrollbar.populate(); @@ -207,7 +222,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.rightScrollbar.populate(); var items = this.scrollBarLayout.attr("items"); - items[0].top = o.header.length * o.headerRowSize; + items[0].top = this._getFreezeHeaderHeight(); items[1].top = this._height; items[2].top = this._height; items[2].left = regionSize; @@ -218,8 +233,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -235,13 +249,13 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }); var otlw = regionSize; - var otlh = o.header.length * o.headerRowSize; + var otlh = this._getFreezeHeaderHeight(); var otrw = this._width - regionSize; - var otrh = o.header.length * o.headerRowSize; + var otrh = this._getFreezeHeaderHeight(); var oblw = regionSize; - var oblh = this._height - o.header.length * o.headerRowSize; + var oblh = this._height - otlh; var obrw = this._width - regionSize; - var obrh = this._height - o.header.length * o.headerRowSize; + var obrh = this._height - otrh; var tlw = otlw + this._scrollBarSize; var tlh = otlh + this._scrollBarSize; @@ -285,9 +299,9 @@ BI.CollectionTable = BI.inherit(BI.Widget, { var items = this.contextLayout.attr("items"); items[1].left = regionSize; - items[2].top = o.header.length * o.headerRowSize; + items[2].top = this._getFreezeHeaderHeight(); items[3].left = regionSize; - items[3].top = o.header.length * o.headerRowSize; + items[3].top = this._getFreezeHeaderHeight(); this.contextLayout.attr("items", items); this.contextLayout.resize(); @@ -303,8 +317,8 @@ BI.CollectionTable = BI.inherit(BI.Widget, { }; run(this.topLeftItems, o.header, leftHeader); run(this.topRightItems, o.header, rightHeader); - run(this.bottomLeftItems, o.items, leftItems); - run(this.bottomRightItems, o.items, rightItems); + run(this.bottomLeftItems, this._getActualItems(), leftItems); + run(this.bottomRightItems, this._getActualItems(), rightItems); this.topLeftCollection._populate(leftHeader); this.topRightCollection._populate(rightHeader); @@ -315,13 +329,23 @@ BI.CollectionTable = BI.inherit(BI.Widget, { _digest: function () { var o = this.options; var freezeColLength = this._getFreezeColLength(); - this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); - this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); - this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); - this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + //如果表头位置不够,取消表头冻结 + if (this._getFreezeHeaderHeight() <= 0) { + this.topLeftItems = []; + this.topRightItems = []; + this.bottomLeftItems = this._serialize(this._getActualItems(), 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + this.bottomRightItems = this._serialize(this._getActualItems(), freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols, BI.range(o.header.length)); + } else { + this.topLeftItems = this._serialize(o.header, 0, freezeColLength, o.headerRowSize, o.columnSize, o.mergeCols); + this.topRightItems = this._serialize(o.header, freezeColLength, o.columnSize.length, o.headerRowSize, o.columnSize, true); + this.bottomLeftItems = this._serialize(o.items, 0, freezeColLength, o.rowSize, o.columnSize, o.mergeCols); + this.bottomRightItems = this._serialize(o.items, freezeColLength, o.columnSize.length, o.rowSize, o.columnSize, o.mergeCols); + } }, - _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols) { + _serialize: function (items, startCol, endCol, rowHeight, columnSize, mergeCols, mergeRows) { + mergeCols = mergeCols || []; + mergeRows = mergeRows || []; var self = this, o = this.options; var result = [], cache = {}, preCol = {}, preRow = {}, map = {}; var summaryColumnSize = []; @@ -371,7 +395,7 @@ BI.CollectionTable = BI.inherit(BI.Widget, { } cache[i][j] = cols[j]; map[i][j] = {}; - if (mergeCols === true || mergeCols.indexOf(j) > -1) { + if (mergeCols === true || mergeCols.indexOf(j) > -1 || mergeRows === true || mergeRows.indexOf(i) > -1) { if (i === 0 && j === startCol) { createOneEl(0, startCol); } else if (j === startCol && i > 0) { diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 155b5b614..1eae8487b 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -176,11 +176,26 @@ BI.GridTable = BI.inherit(BI.Widget, { return this.options.isNeedFreeze ? this.options.freezeCols.length : 0; }, + _getFreezeHeaderHeight: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return 0; + } + return o.header.length * o.headerRowSize; + }, + + _getActualItems: function () { + var o = this.options; + if (o.header.length * o.headerRowSize >= this._height) { + return o.header.concat(o.items); + } + return o.items; + }, + _populateScrollbar: function () { var o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; - var freezeColLength = this._getFreezeColLength(); + summaryColumnSizeArray = []; BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { totalLeftColumnSize += size; @@ -194,8 +209,8 @@ BI.GridTable = BI.inherit(BI.Widget, { summaryColumnSizeArray[i] = summaryColumnSizeArray[i - 1] + size; } }); - this.topScrollbar.setContentSize(o.items.length * o.rowSize); - this.topScrollbar.setSize(this._height - o.header.length * o.headerRowSize); + this.topScrollbar.setContentSize(this._getActualItems().length * o.rowSize); + this.topScrollbar.setSize(this._height - this._getFreezeHeaderHeight()); this.topScrollbar.setPosition(Math.min(this.bottomLeftGrid.getScrollTop(), this.bottomRightGrid.getScrollTop())); this.topScrollbar.populate(); @@ -210,7 +225,7 @@ BI.GridTable = BI.inherit(BI.Widget, { this.rightScrollbar.populate(); var items = this.scrollBarLayout.attr("items"); - items[0].top = o.header.length * o.headerRowSize; + items[0].top = this._getFreezeHeaderHeight(); items[1].top = this._height; items[2].top = this._height; items[2].left = regionSize; @@ -244,7 +259,7 @@ BI.GridTable = BI.inherit(BI.Widget, { var o = this.options; var freezeColLength = this._getFreezeColLength(); var leftItems = [], rightItems = []; - BI.each(o.items, function (i, cols) { + BI.each(this._getActualItems(), function (i, cols) { leftItems[i] = []; rightItems[i] = []; BI.each(cols, function (j, col) { @@ -265,7 +280,7 @@ BI.GridTable = BI.inherit(BI.Widget, { _populateTable: function () { var self = this, o = this.options; var regionSize = this.getRegionSize(), totalLeftColumnSize = 0, totalRightColumnSize = 0, totalColumnSize = 0, - summaryColumnSizeArray = [], totalRowSize = o.items.length * o.rowSize; + summaryColumnSizeArray = []; var freezeColLength = this._getFreezeColLength(); BI.each(o.columnSize, function (i, size) { if (o.isNeedFreeze === true && o.freezeCols.contains(i)) { @@ -282,13 +297,13 @@ BI.GridTable = BI.inherit(BI.Widget, { }); var otlw = regionSize; - var otlh = o.header.length * o.headerRowSize; + var otlh = this._getFreezeHeaderHeight(); var otrw = this._width - regionSize; - var otrh = o.header.length * o.headerRowSize; + var otrh = this._getFreezeHeaderHeight(); var oblw = regionSize; - var oblh = this._height - o.header.length * o.headerRowSize; + var oblh = this._height - otlh; var obrw = this._width - regionSize; - var obrh = this._height - o.header.length * o.headerRowSize; + var obrh = this._height - otrh; var tlw = otlw + this._scrollBarSize; var tlh = otlh + this._scrollBarSize; @@ -341,9 +356,9 @@ BI.GridTable = BI.inherit(BI.Widget, { var items = this.contextLayout.attr("items"); items[1].left = regionSize; - items[2].top = o.header.length * o.headerRowSize; + items[2].top = this._getFreezeHeaderHeight(); items[3].left = regionSize; - items[3].top = o.header.length * o.headerRowSize; + items[3].top = this._getFreezeHeaderHeight(); this.contextLayout.attr("items", items); this.contextLayout.resize(); diff --git a/src/core/widget.js b/src/core/widget.js index a868b4d31..610b38492 100644 --- a/src/core/widget.js +++ b/src/core/widget.js @@ -198,7 +198,7 @@ BI.Widget = BI.inherit(BI.OB, { } //递归将所有子组件使能 BI.each(this._children, function (i, child) { - child._setEnable && child._setEnable(enable); + !child._manualSetEnable && child._setEnable && child._setEnable(enable); }); }, @@ -210,7 +210,7 @@ BI.Widget = BI.inherit(BI.OB, { } //递归将所有子组件使有效 BI.each(this._children, function (i, child) { - child._setValid && child._setValid(valid); + !child._manualSetValid && child._setValid && child._setValid(valid); }); }, @@ -223,6 +223,7 @@ BI.Widget = BI.inherit(BI.OB, { }, setEnable: function (enable) { + this._manualSetEnable = true; this._setEnable(enable); if (enable === true) { this.element.removeClass("base-disabled disabled"); @@ -244,7 +245,7 @@ BI.Widget = BI.inherit(BI.OB, { }, setValid: function (valid) { - this.options.invalid = !valid; + this._manualSetValid = true; this._setValid(valid); if (valid === true) { this.element.removeClass("base-invalid invalid"); From cf2168d618b73b270bddf1e4559f29d42297aac6 Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 7 Jun 2017 11:24:43 +0800 Subject: [PATCH 27/27] add --- bi/base.js | 2 +- docs/base.js | 2 +- src/base/single/button/button.basic.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bi/base.js b/bi/base.js index 9aa2a6024..c5c7353c3 100644 --- a/bi/base.js +++ b/bi/base.js @@ -710,7 +710,7 @@ BI.BasicButton = BI.inherit(BI.Single, { $(document).bind("mouseup." + self.getName(), function (e) { // if (e.button === 0) { if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { - self.setSelected(!self.isSelected()); + // self.setSelected(!self.isSelected()); self._trigger(); } mouseDown = false; diff --git a/docs/base.js b/docs/base.js index 9aa2a6024..c5c7353c3 100644 --- a/docs/base.js +++ b/docs/base.js @@ -710,7 +710,7 @@ BI.BasicButton = BI.inherit(BI.Single, { $(document).bind("mouseup." + self.getName(), function (e) { // if (e.button === 0) { if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { - self.setSelected(!self.isSelected()); + // self.setSelected(!self.isSelected()); self._trigger(); } mouseDown = false; diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index c5de615f5..db0e4b3ab 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -127,7 +127,7 @@ BI.BasicButton = BI.inherit(BI.Single, { $(document).bind("mouseup." + self.getName(), function (e) { // if (e.button === 0) { if (BI.DOM.isExist(self) && !hand.__isMouseInBounds__(e) && mouseDown === true && !selected) { - self.setSelected(!self.isSelected()); + // self.setSelected(!self.isSelected()); self._trigger(); } mouseDown = false;