Browse Source

Merge pull request #50 in FUI/fineui from ~GUY/fineui:master to master

* commit '007613a6430f1059d46b5d1fa01dc0d95a920985': (27 commits)
  复制到粘贴板IE8兼容
  add
  复制到粘贴板改用clipboard
  add
  add
  add
  class写错了
  listview
  add
  floatOpened
  virtuallist
  add
  精度
  update
  _setValid
  add
  add
  add
  add
  update
  ...
master
guy 8 years ago
parent
commit
b0bc0f3efc
  1. 14
      bi/base.css
  2. 360
      bi/base.js
  3. 1917
      bi/case.js
  4. 182
      bi/core.js
  5. 500
      bi/widget.js
  6. 5
      demo/config.js
  7. 8
      demo/js/case/demo.clipboard.js
  8. 40
      demo/js/component/demo.treevaluechooser.js
  9. 23
      demo/js/component/demo.treevaluechoosercombo.js
  10. 16
      demo/js/component/demo.treevaluechooserpane.js
  11. 0
      demo/js/component/demo.valuechoosercombo.js
  12. 15
      demo/js/component/demo.valuechooserpane.js
  13. 4
      demo/js/config/case.js
  14. 10
      demo/js/config/component.js
  15. 8
      demo/js/config/core.js
  16. 2
      demo/js/core/abstract/demo.collection_view.js
  17. 4
      demo/js/core/abstract/demo.grid_view.js
  18. 22
      demo/js/core/abstract/demo.list_view.js
  19. 18
      demo/js/core/abstract/demo.virtual_list.js
  20. 4
      demo/version.js
  21. 14
      docs/base.css
  22. 360
      docs/base.js
  23. 1917
      docs/case.js
  24. 182
      docs/core.js
  25. 214
      docs/demo.js
  26. 500
      docs/widget.js
  27. 4
      src/base/collection/collection.js
  28. 0
      src/base/foundation/message.js
  29. 12
      src/base/grid/grid.js
  30. 2
      src/base/layer/layer.popup.js
  31. 110
      src/base/list/listview.js
  32. 179
      src/base/list/virtuallist.js
  33. 13
      src/base/single/button/button.basic.js
  34. 5
      src/base/single/editor/editor.js
  35. 8
      src/base/single/editor/editor.textarea.js
  36. 4
      src/base/single/input/input.js
  37. 2
      src/base/tree/asynctree.js
  38. 2
      src/base/tree/parttree.js
  39. 19
      src/base/tree/treeview.js
  40. 1319
      src/case/clipboard/clipboard.js
  41. 46
      src/case/clipboard/index.js
  42. 6
      src/case/editor/editor.search.js
  43. 5
      src/case/editor/editor.sign.js
  44. 14
      src/case/toolbar/toolbar.multiselect.js
  45. 495
      src/case/zclip/jquery.zclip.js
  46. 31
      src/case/zclip/zclip.js
  47. 79
      src/component/allvaluechooser/abstract.allvaluechooser.js
  48. 62
      src/component/allvaluechooser/combo.allvaluechooser.js
  49. 62
      src/component/allvaluechooser/pane.allvaluechooser.js
  50. 548
      src/component/treevaluechooser/abstract.treevaluechooser.js
  51. 550
      src/component/treevaluechooser/combo.treevaluechooser.js
  52. 49
      src/component/treevaluechooser/pane.treevaluechooser.js
  53. 89
      src/component/valuechooser/abstract.valuechooser.js
  54. 72
      src/component/valuechooser/combo.valuechooser.js
  55. 56
      src/component/valuechooser/pane.valuechooser.js
  56. 16
      src/core/base.js
  57. 3
      src/core/controller/controller.floatbox.js
  58. 2
      src/core/controller/controller.layer.js
  59. 95
      src/core/proto/jquery.js
  60. 2
      src/core/proto/number.js
  61. 2
      src/core/utils/prefixIntervalTree.js
  62. 51
      src/core/utils/tree.js
  63. 11
      src/core/widget.js
  64. 14
      src/css/base/view/popupview.css
  65. 4
      src/less/base/view/popupview.less
  66. 13
      src/widget/multiselectlist/multiselectlist.js
  67. 16
      src/widget/multiselecttree/multiselecttree.js
  68. 6
      src/widget/multiselecttree/multiselecttree.popup.js
  69. 4
      src/widget/sequencetable/treenumber.sequencetable.js

14
bi/base.css

@ -1342,30 +1342,30 @@ li.CodeMirror-hint-active {
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
/**********BI.BIListView*************/
.bi-list-view {
.bi-popup-view {
position: fixed !important;
overflow-y: visible !important;
overflow-x: visible !important;
overflow: visible !important;
cursor: default;
}
.bi-list-view .list-view-outer {
.bi-popup-view .list-view-outer {
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.bi-list-view .list-view-toolbar {
.bi-popup-view .list-view-toolbar {
line-height: 30px;
}
.bi-list-view .list-view-toolbar > .center-element {
.bi-popup-view .list-view-toolbar > .center-element {
border-left: 1px solid #d4dadd;
}
.bi-list-view .list-view-toolbar > .first-element {
.bi-popup-view .list-view-toolbar > .first-element {
border-left: none;
}
.bi-theme-dark .bi-list-view .list-view-toolbar > .center-element {
.bi-theme-dark .bi-popup-view .list-view-toolbar > .center-element {
border-left: 1px solid #525466;
}
.bi-theme-dark .bi-list-view .list-view-toolbar > .first-element {
.bi-theme-dark .bi-popup-view .list-view-toolbar > .first-element {
border-left: none;
}

360
bi/base.js

@ -797,7 +797,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return;
}
onClick.apply(self);
onClick.apply(self, arguments);
}
},
@ -816,13 +816,20 @@ BI.BasicButton = BI.inherit(BI.Single, {
}
},
_doClick: function () {
_doClick: function (e) {
if (this.isValid()) {
this.beforeClick(e);
}
this._trigger();
if (this.isValid()) {
this.doClick();
this.doClick(e);
}
},
beforeClick: function () {
},
doClick: function () {
},
@ -1710,7 +1717,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
_getNodeValue: function (node) {
//去除标红
return node.value || node.text.replace(/<[^>]+>/g, "");
return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value;
},
//获取半选框值
@ -1802,6 +1809,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var self = this, o = this.options;
var ns = BI.Tree.arrayFormat(nodes);
BI.each(ns, function (i, n) {
n.title = n.title || n.text || n.value;
//处理标红
if (BI.isKey(o.paras.keyword)) {
n.text = $("<div>").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
@ -1936,6 +1944,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this.nodes && this.nodes.expandAll(flag);
},
//设置树节点的状态
setValue: function (value, param) {
this.setSelectedValue(value);
this.checkAll(false);
@ -1944,7 +1953,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.options.paras.selectedValues = BI.deepClone(value) || {};
this.selectedValues = BI.deepClone(value) || {};
},
@ -1963,12 +1972,6 @@ BI.TreeView = BI.inherit(BI.Pane, {
});
},
getExpandedValue: function(){
if (!this.nodes) {
return null;
}
},
refresh: function () {
this.nodes && this.nodes.refresh();
},
@ -1980,14 +1983,9 @@ BI.TreeView = BI.inherit(BI.Pane, {
return this._getSelectedValues();
},
empty: function () {
BI.isNotNull(this.nodes) && this.nodes.destroy();
},
destroy: function () {
destroyed: function () {
this.stop();
this.nodes && this.nodes.destroy();
BI.TreeView.superclass.destroy.apply(this, arguments);
}
});
BI.extend(BI.TreeView, {
@ -2190,7 +2188,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return this.selectedValues;
return BI.deepClone(this.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
return checkedValues;
@ -2257,7 +2255,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA,
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues
@ -2532,8 +2530,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-collection",
width: 400,
height: 300,
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
cellSizeAndPositionGetter: BI.emptyFn,
@ -14673,16 +14671,16 @@ BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
width: 400,
height: 300,
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
overscanColumnCount: 0,
overscanRowCount: 0,
rowHeightGetter: BI.emptyFn,
columnWidthGetter: BI.emptyFn,
estimatedColumnSize: 100,
estimatedRowSize: 30,
rowHeightGetter: BI.emptyFn, //number类型或function类型
columnWidthGetter: BI.emptyFn, //number类型或function类型
// estimatedColumnSize: 100, //columnWidthGetter为function时必设
// estimatedRowSize: 30, //rowHeightGetter为function时必设
scrollLeft: 0,
scrollTop: 0,
items: []
@ -15157,7 +15155,7 @@ BI.FloatBox.EVENT_FLOAT_BOX_OPEN = "EVENT_FLOAT_BOX_CLOSED";
BI.PopupView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-list-view",
baseCls: "bi-popup-view",
maxWidth: 'auto',
minWidth: 100,
//maxHeight: 200,
@ -15458,6 +15456,295 @@ BI.SearcherView = BI.inherit(BI.Pane, {
BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.searcher_view", BI.SearcherView);/**
* 表示当前对象
*
* Created by GUY on 2017/5/23.
* @class BI.ListView
* @extends BI.Widget
*/
BI.ListView = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-list-view",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
el: {},
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [BI.extend({
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, o.el)],
element: this
}
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
restore: function () {
this.renderedIndex = -1;
this.container.empty();
this.cache = {};
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut('bi.list_view', BI.ListView);
/**
* 表示当前对象
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
*/
BI.VirtualList = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-virtual-list",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
}, {
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
}],
element: this
}
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
var height = this.element.height();
var minContentHeightFrom = o.scrollTop - o.overscanHeight;
var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
var start = this.tree.greatestLowerBound(minContentHeightFrom);
var end = this.tree.leastUpperBound(minContentHeightTo);
var needDestroyed = [];
for (var i = 0; i < start; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
for (var i = end + 1; i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
var firstFragment = document.createDocumentFragment(), lastFragment = document.createDocumentFragment();
var currentFragment = firstFragment;
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
currentFragment = lastFragment;
}
if (this.cache[i].destroyed === true) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
var w = this.container._addElement(j, BI.extend({root: true}, BI.stripEL(o.items[j])));
currentFragment.appendChild(w.element[0]);
}
this.cache[i].destroyed = false;
}
}
this.container.element.prepend(firstFragment);
this.container.element.append(lastFragment);
this.topBlank.setHeight(this.cache[start < 0 ? 0 : start].scrollTop);
var lastCache = this.cache[Math.min(end, this.renderedIndex)];
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - lastCache.scrollTop - lastCache.height);
BI.each(needDestroyed, function (i, child) {
child && child._destroy();
});
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize));
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
_clearChildren: function () {
BI.each(this.container._children, function (i, cell) {
cell && cell.el._destroy();
});
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
this.renderedIndex = -1;
this._clearChildren();
this.cache = {};
this.options.scrollTop = 0;
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut('bi.virtual_list', BI.VirtualList);
/**
* 分页控件
*
* Created by GUY on 2015/8/31.
@ -17848,11 +18135,6 @@ BI.Editor = BI.inherit(BI.Single, {
return BI.trim(this.editor.getValue());
},
setValid: function (b) {
BI.Editor.superclass.setValid.apply(this, arguments);
this.editor.setValid(b);
},
isEditing: function () {
return this.editor.isEditing();
},
@ -18119,10 +18401,10 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
return this.style;
},
setValid: function (b) {
BI.TextAreaEditor.superclass.setValid.apply(this, arguments);
this.content.setValid(b);
this.watermark && this.watermark.setValid(b);
_setValid: function (b) {
BI.TextAreaEditor.superclass._setValid.apply(this, arguments);
// this.content.setValid(b);
// this.watermark && this.watermark.setValid(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -19115,8 +19397,8 @@ BI.Input = BI.inherit(BI.Single, {
return this._lastValidValue;
},
setValid: function () {
BI.Input.superclass.setValid.apply(this, arguments);
_setValid: function () {
BI.Input.superclass._setValid.apply(this, arguments);
if (this.isValid()) {
this._lastValidValue = this.getValue();
this.element.removeClass("bi-input-error");

1917
bi/case.js

File diff suppressed because it is too large Load Diff

182
bi/core.js

@ -2352,15 +2352,15 @@ if (!window.BI) {
},
has: function (obj, keys) {
if (BI.isKey(keys)) {
return _.has.apply(_, arguments);
}
if (!keys || BI.isEmpty(keys)) {
return false;
if (BI.isArray(keys)) {
if (keys.length === 0) {
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key
@ -4365,9 +4365,10 @@ BI.Widget = BI.inherit(BI.OB, {
this._initRoot();
this._initElementWidth();
this._initElementHeight();
this._initVisualEffects();
this._initVisual();
this._initState();
this._initElement();
this._initEffects();
this.created && this.created();
},
@ -4422,21 +4423,23 @@ BI.Widget = BI.inherit(BI.OB, {
}
},
_initVisualEffects: function () {
_initVisual: function () {
var o = this.options;
if (o.invisible) {
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none");
}
},
_initEffects: function () {
var o = this.options;
if (o.disabled || o.invalid) {
// BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
// }, this));
}
},
@ -6544,59 +6547,64 @@ Function.prototype.after = function (func) {
* All rights reserved.
*/
if (jQuery) {
(function($){
(function ($) {
// richer:容器在其各个边缘留出的空间
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
if (!$.fn.insets) {
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
};
};
};
}
// richer:获取 && 设置jQuery元素的边界
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds : true};
if (!$.fn.bounds) {
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds: true};
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0;
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
}
this.css(tmp);
return this;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
else {
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
'x': tmp.left,
'y': tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(),
'height': this.outerHeight()
};
}
this.css(tmp);
return this;
}
else {
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
'x': tmp.left,
'y': tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(),
'height': this.outerHeight()
};
}
};
};
}
})(jQuery);
};if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
}
;if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
(0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' ||
(1000000000000000128).toFixed(0) !== "1000000000000000128") {
(function () {
@ -6857,7 +6865,7 @@ function accDiv(arg1, arg2) {
with (Math) {
r1 = Number(arg1.toString().replace(".", ""));
r2 = Number(arg2.toString().replace(".", ""));
return (r1 / r2) * pow(10, t2 - t1);
return (t2 > t1) ? (r1 / r2) * pow(10, t2 - t1) : (r1 / r2) / pow(10, t1 - t2);
}
}
@ -9657,7 +9665,7 @@ $.extend(BI, {
return new BI.PrefixIntervalTree(xs);
};
BI.PrefixIntervalTree.empty = function () {
BI.PrefixIntervalTree.empty = function (size) {
return BI.PrefixIntervalTree.uniform(size, 0);
};
@ -9990,7 +9998,7 @@ $.extend(BI, {
},
isRoot: function (node) {
return node === this.root || node.id === this.root.id;
return node === this.root;
},
getRoot: function () {
@ -10367,7 +10375,7 @@ $.extend(BI, {
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = BI.clone(nodes[i]);
node.pId = pId;
node.pId = node.pId == null ? pId : node.pId;
delete node.children;
r.push(node);
if (nodes[i]["children"]) {
@ -10376,7 +10384,7 @@ $.extend(BI, {
}
} else {
var newNodes = BI.clone(nodes);
newNodes.pId = pId;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
delete newNodes.children;
r.push(newNodes);
if (nodes["children"]) {
@ -10387,21 +10395,25 @@ $.extend(BI, {
},
arrayFormat: function (nodes, pId) {
if (!nodes) return [];
if (!nodes) {
return [];
}
var r = [];
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
node.pId = node.pId == null ? pId : node.pId;
r.push(node);
if (nodes[i]["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
}
}
} else {
var newNodes = nodes;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
r.push(newNodes);
if (nodes["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
}
}
return r;
@ -10417,13 +10429,13 @@ $.extend(BI, {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if(BI.isNull(sNodes[i].id)) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
@ -10439,6 +10451,37 @@ $.extend(BI, {
}
},
treeFormat: function (sNodes) {
var i, l;
if (!sNodes) {
return [];
}
if (BI.isArray(sNodes)) {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = sNodes[i];
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
} else {
r.push(tmpMap[sNodes[i].id]);
}
}
return r;
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;
@ -15351,7 +15394,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
}
this.floatContainer[name] = BI.createWidget({
type: "bi.absolute",
cls: "bi-list-view",
cls: "bi-popup-view",
items: [{
el: (this.floatLayer[name] = BI.createWidget({
type: 'bi.absolute',
@ -15441,6 +15484,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
delete this.floatLayer[name];
delete this.zindexMap[name];
delete this.floatContainer[name];
delete this.floatOpened[name];
return this;
}
});/**
@ -15538,7 +15582,7 @@ BI.LayerController = BI.inherit(BI.Controller, {
}]
});
if (w) {
layout.element.addClass("bi-list-view");
layout.element.addClass("bi-popup-view");
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),

500
bi/widget.js

@ -79,7 +79,9 @@ BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
var cnt = this.start;
function track(node) {
self.cache[node.text || node.value] = cnt++;
//如果已经有缓存了就不改计数了,复杂表会出现这种情况
self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
cnt++;
}
BI.each(nodes, function (i, node) {
@ -10962,8 +10964,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
el: {}
valueFormatter: BI.emptyFn
})
},
_init: function () {
@ -10974,6 +10975,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -11033,6 +11035,8 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
@ -11044,7 +11048,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
@ -11064,13 +11067,11 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
}
@ -11096,8 +11097,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 30
@ -11109,8 +11108,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
@ -11307,8 +11304,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-tree',
itemsCreator: BI.emptyFn,
height: 25
itemsCreator: BI.emptyFn
})
},
@ -11354,7 +11350,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
@ -11394,8 +11389,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 30
@ -11407,8 +11400,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
@ -11444,6 +11435,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
});
},
stopSearch: function () {
this.trigger.stopSearch();
},
updateValue: function (v) {
this.adapter.updateValue(v);
},
getValue: function () {
return this.storeValue.value;
},
@ -11469,7 +11468,6 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.async_tree",
height: 400,
element: this,
itemsCreator: o.itemsCreator
});
@ -11494,6 +11492,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
this.popup.setValue(v.value);
},
updateValue: function (v) {
this.popup.updateValue(v);
this.popup.refresh();
},
populate: function (config) {
this.popup.stroke(config);
}
@ -16975,17 +16978,17 @@ BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/**
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserCombo
* @class BI.AbstractAllValueChooser
* @extends BI.Widget
*/
BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 10
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-combo",
return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
width: 200,
height: 30,
items: null,
@ -16994,35 +16997,17 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
});
},
_init: function () {
BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
return text;
},
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
});
});
}
return text;
},
_itemsCreator: function (options, callback) {
@ -17065,6 +17050,46 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
hasNext: false
});
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserCombo
* @extends BI.AbstractAllValueChooser
*/
BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
});
},
setValue: function (v) {
@ -17088,70 +17113,84 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
});
BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
BI.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);/**
* 简单的复选下拉树控件, 适用于数据量少的情况
* 简单的复选下拉框控件, 适用于数据量少的情况 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserCombo
* @extends BI.Widget
* @class BI.AllValueChooserPane
* @extends BI.AbstractAllValueChooser
*/
BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
_const: {
perPage: 10
},
BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-combo",
return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-pane",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
BI.AllValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this._initData(o.items);
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_tree_combo',
this.list = BI.createWidget({
type: 'bi.multi_select_list',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
});
},
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.transformToTreeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
this._initMap();
this._initFloors();
setValue: function (v) {
this.list.setValue({
type: BI.Selection.Multi,
value: v || []
});
},
_initMap: function () {
var map = this.map = {};
BI.each(this.items, function (i, item) {
map[item.value] = item;
getValue: function () {
var val = this.list.getValue() || {};
if (val.type === BI.Selection.All) {
return val.assist;
}
return val.value || [];
},
populate: function () {
this.list.populate.apply(this.list, arguments);
}
});
BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
items: null,
itemsCreator: BI.emptyFn
});
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
},
_itemsCreator: function (options, callback) {
@ -17195,32 +17234,29 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
return;
}
doCheck(0, [], this.tree.getRoot(), selectedValues);
doCheck([], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(floor, parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
function doCheck(parentValues, node, selected) {
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {});
doCheck(newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(k);
var node = self._getNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]);
doCheck(newParents, node, selected[k]);
})
}
@ -17310,9 +17346,6 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
if (self._isMatch(current, keyword)) {
return true;
}
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents);
@ -17448,9 +17481,6 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
@ -17475,14 +17505,14 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self.map[value];
var node = self._getNode(parentValues, value)
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: parentValues.length + 1 < self.floors,
isParent: node.getChildrenLength() > 0,
open: isOpen,
checked: checked,
halfCheck: half,
@ -17566,7 +17596,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: parentValues.length + 1 < this.floors,
isParent: nodes[i].getChildrenLength() > 0,
checked: state[0],
halfCheck: state[1]
})
@ -17613,14 +17643,14 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) {
var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
@ -17653,14 +17683,34 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (v) {
return this.tree.search(v, "value");
_getNode: function (parentValues, v) {
var self = this;
var findedParentNode;
var index = 0;
this.tree.traverse(function (node) {
if (self.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
return false;
}
if (index === parentValues.length && node.value === v) {
findedParentNode = node;
return false;
}
if (node.value === parentValues[index]) {
index++;
return;
}
return true;
});
return findedParentNode;
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this.tree.search(value, "value");
var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
var parent = this.tree.getRoot();
}
@ -17669,6 +17719,43 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
_getChildCount: function (parentValues) {
return this._getChildren(parentValues).length;
}
});/**
* 简单的复选下拉树控件, 适用于数据量少的情况
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserCombo
* @extends BI.Widget
*/
BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this._initData(o.items);
}
this.combo = BI.createWidget({
type: 'bi.multi_tree_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
});
},
setValue: function (v) {
@ -17680,63 +17767,91 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
},
populate: function () {
this.combo.populate.apply(this, arguments);
this.combo.populate.apply(this.combo, arguments);
}
});
BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
BI.shortcut('bi.tree_value_chooser_combo', BI.TreeValueChooserCombo);/**
* 简单的复选下拉树控件, 适用于数据量少的情况
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserPane
* @extends BI.AbstractTreeValueChooser
*/
BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-pane",
items: null,
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.pane = BI.createWidget({
type: 'bi.multi_select_tree',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this)
});
this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
});
if (BI.isNotNull(o.items)) {
this._initData(o.items);
this.populate();
}
},
setValue: function (v) {
this.pane.setValue(v);
},
getValue: function () {
return this.pane.getValue();
},
populate: function () {
this.pane.populate.apply(this.pane, arguments);
}
});
BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserCombo
* @class BI.AbstractValueChooser
* @extends BI.Widget
*/
BI.ValueChooserCombo = BI.inherit(BI.Widget, {
BI.AbstractValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 10
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-combo",
width: 200,
height: 30,
return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
return text;
},
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
});
});
}
return text;
},
_getItemsByTimes: function (items, times) {
@ -17791,6 +17906,46 @@ BI.ValueChooserCombo = BI.inherit(BI.Widget, {
hasNext: self._hasNextByTimes(items, options.times)
});
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserCombo
* @extends BI.Widget
*/
BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
});
},
setValue: function (v) {
@ -17810,4 +17965,59 @@ BI.ValueChooserCombo = BI.inherit(BI.Widget, {
}
});
BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);
BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserPane
* @extends BI.Widget
*/
BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-pane",
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.list = BI.createWidget({
type: 'bi.multi_select_list',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this)
});
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
});
if (BI.isNotNull(o.items)) {
this.items = o.items;
this.populate();
}
},
setValue: function (v) {
this.list.setValue(v);
},
getValue: function () {
var val = this.list.getValue() || {};
return {
type: val.type,
value: val.value
}
},
populate: function () {
this.list.populate.apply(this.list, arguments);
}
});
BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane);

5
demo/config.js

File diff suppressed because one or more lines are too long

8
demo/js/case/demo.zclip.js → demo/js/case/demo.clipboard.js

@ -10,8 +10,8 @@ Demo.Func = BI.inherit(BI.Widget, {
height: 30,
value: "这是复制的内容"
});
var zclip = BI.createWidget({
type: 'bi.zero_clip',
var clipboard = BI.createWidget({
type: 'bi.clipboard',
width: 100,
height: 100,
cls: 'layout-bg1',
@ -32,11 +32,11 @@ Demo.Func = BI.inherit(BI.Widget, {
left: 100,
top: 50,
}, {
el: zclip,
el: clipboard,
left: 100,
top: 100
}]
})
}
});
BI.shortcut("demo.zclip", Demo.Func);
BI.shortcut("demo.clipboard", Demo.Func);

40
demo/js/component/demo.treevaluechooser.js

@ -1,40 +0,0 @@
Demo.TreeValueChooser = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-tree-value-chooser"
},
render: function () {
var tree = [];
for (var i = 0; i < 21; i++) {
tree.push({
value: "" + i + "",
text: "" + i + "",
id: i + "",
pId: null
});
for (var j = 0; j < 9; j++) {
tree.push({
value: i + "-" + j,
text: j + "",
id: i + "-" + j,
pId: i + ""
})
}
}
var widget = BI.createWidget({
type: "bi.tree_value_chooser_combo",
width: 300,
items: tree,
itemsCreator: function (op, callback) {
callback(tree);
}
});
return {
type: "bi.vertical",
hgap: 200,
vgap: 10,
items: [widget]
};
}
});
BI.shortcut("demo.tree_value_chooser", Demo.TreeValueChooser);

23
demo/js/component/demo.treevaluechoosercombo.js

@ -0,0 +1,23 @@
Demo.TreeValueChooser = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-tree-value-chooser-combo"
},
render: function () {
var widget = BI.createWidget({
type: "bi.tree_value_chooser_combo",
width: 300,
// items: BI.deepClone(Demo.CONSTANTS.TREEITEMS),
itemsCreator: function (op, callback) {
callback(BI.deepClone(Demo.CONSTANTS.TREEITEMS));
}
});
return {
type: "bi.vertical",
hgap: 200,
vgap: 10,
items: [widget]
};
}
});
BI.shortcut("demo.tree_value_chooser_combo", Demo.TreeValueChooser);

16
demo/js/component/demo.treevaluechooserpane.js

@ -0,0 +1,16 @@
Demo.TreeValueChooser = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-tree-value-chooser"
},
render: function () {
return {
type: "bi.tree_value_chooser_pane",
items: BI.deepClone(Demo.CONSTANTS.TREEITEMS),
// itemsCreator: function (op, callback) {
// callback(tree);
// }
};
}
});
BI.shortcut("demo.tree_value_chooser_pane", Demo.TreeValueChooser);

0
demo/js/component/demo.valuechooser.js → demo/js/component/demo.valuechoosercombo.js

15
demo/js/component/demo.valuechooserpane.js

@ -0,0 +1,15 @@
Demo.ValueChooserPane = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-value-chooser-pane"
},
render: function () {
return {
type: "bi.value_chooser_pane",
items: BI.deepClone(Demo.CONSTANTS.ITEMS),
// itemsCreator: function (op, callback) {
// callback(BI.deepClone(Demo.CONSTANTS.ITEMS));
// }
};
}
});
BI.shortcut("demo.value_chooser_pane", Demo.ValueChooserPane);

4
demo/js/config/case.js

@ -80,8 +80,8 @@ Demo.CASE_CONFIG = [{
value: "demo.calendar"
}, {
pId: 3,
text: "bi.zclip",
value: "demo.zclip"
text: "bi.clipboard",
value: "demo.clipboard"
}, {
pId: 3,
text: "bi.complex_canvas",

10
demo/js/config/component.js

@ -8,8 +8,16 @@ Demo.COMPONENT_CONFIG = [{
pId: 5,
text: "bi.value_chooser_combo",
value: "demo.value_chooser_combo"
}, {
pId: 5,
text: "bi.value_chooser_pane",
value: "demo.value_chooser_pane"
}, {
pId: 5,
text: "bi.tree_value_chooser_combo",
value: "demo.tree_value_chooser"
value: "demo.tree_value_chooser_combo"
}, {
pId: 5,
text: "bi.tree_value_chooser_pane",
value: "demo.tree_value_chooser_pane"
}];

8
demo/js/config/core.js

@ -105,6 +105,14 @@ Demo.CORE_CONFIG = [{
pId: 102,
text: "bi.collection_view",
value: "demo.collection_view"
}, {
pId: 102,
text: "bi.list_view",
value: "demo.list_view"
}, {
pId: 102,
text: "bi.virtual_list",
value: "demo.virtual_list"
}, {
pId: 102,
id: 10201,

2
demo/js/core/abstract/demo.collection_view.js

@ -13,6 +13,8 @@ Demo.Func = BI.inherit(BI.Widget, {
}
var grid = BI.createWidget({
type: "bi.collection_view",
width: 400,
height: 300,
items: items,
cellSizeAndPositionGetter: function (index) {
return {

4
demo/js/core/abstract/demo.grid_view.js

@ -16,6 +16,10 @@ Demo.Func = BI.inherit(BI.Widget, {
}
var grid = BI.createWidget({
type: "bi.grid_view",
width: 400,
height: 300,
estimatedRowSize: 30,
estimatedColumnSize: 100,
items: items,
scrollTop: 100,
rowHeightGetter: function () {

22
demo/js/core/abstract/demo.list_view.js

@ -0,0 +1,22 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
return {
type: "bi.list_view",
el: {
type: "bi.left"
},
items: BI.map(Demo.CONSTANTS.ITEMS, function (i, item) {
return BI.extend({}, item, {
type: "bi.label",
width: 200,
height: 200,
text: (i + 1) + "." + item.text,
});
})
}
}
});
BI.shortcut("demo.list_view", Demo.Func);

18
demo/js/core/abstract/demo.virtual_list.js

@ -0,0 +1,18 @@
Demo.Func = BI.inherit(BI.Widget, {
props: {
baseCls: "demo-func"
},
render: function () {
return {
type: "bi.virtual_list",
items: BI.map(Demo.CONSTANTS.ITEMS, function (i, item) {
return BI.extend({}, item, {
type: "bi.label",
height: 30,
text: (i + 1) + "." + item.text,
});
})
}
}
});
BI.shortcut("demo.virtual_list", Demo.Func);

4
demo/version.js

@ -6,6 +6,6 @@ BI.i18n = {
"BI-Basic_OK": "确定"
};
BI.servletURL = "dist/";
BI.resourceURL = "dist/resource/";
BI.servletURL = "";
BI.resourceURL = "resource/";
BI.i18n = {};

14
docs/base.css

@ -1342,30 +1342,30 @@ li.CodeMirror-hint-active {
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
/**********BI.BIListView*************/
.bi-list-view {
.bi-popup-view {
position: fixed !important;
overflow-y: visible !important;
overflow-x: visible !important;
overflow: visible !important;
cursor: default;
}
.bi-list-view .list-view-outer {
.bi-popup-view .list-view-outer {
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.bi-list-view .list-view-toolbar {
.bi-popup-view .list-view-toolbar {
line-height: 30px;
}
.bi-list-view .list-view-toolbar > .center-element {
.bi-popup-view .list-view-toolbar > .center-element {
border-left: 1px solid #d4dadd;
}
.bi-list-view .list-view-toolbar > .first-element {
.bi-popup-view .list-view-toolbar > .first-element {
border-left: none;
}
.bi-theme-dark .bi-list-view .list-view-toolbar > .center-element {
.bi-theme-dark .bi-popup-view .list-view-toolbar > .center-element {
border-left: 1px solid #525466;
}
.bi-theme-dark .bi-list-view .list-view-toolbar > .first-element {
.bi-theme-dark .bi-popup-view .list-view-toolbar > .first-element {
border-left: none;
}

360
docs/base.js

@ -797,7 +797,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return;
}
onClick.apply(self);
onClick.apply(self, arguments);
}
},
@ -816,13 +816,20 @@ BI.BasicButton = BI.inherit(BI.Single, {
}
},
_doClick: function () {
_doClick: function (e) {
if (this.isValid()) {
this.beforeClick(e);
}
this._trigger();
if (this.isValid()) {
this.doClick();
this.doClick(e);
}
},
beforeClick: function () {
},
doClick: function () {
},
@ -1710,7 +1717,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
_getNodeValue: function (node) {
//去除标红
return node.value || node.text.replace(/<[^>]+>/g, "");
return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value;
},
//获取半选框值
@ -1802,6 +1809,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var self = this, o = this.options;
var ns = BI.Tree.arrayFormat(nodes);
BI.each(ns, function (i, n) {
n.title = n.title || n.text || n.value;
//处理标红
if (BI.isKey(o.paras.keyword)) {
n.text = $("<div>").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
@ -1936,6 +1944,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this.nodes && this.nodes.expandAll(flag);
},
//设置树节点的状态
setValue: function (value, param) {
this.setSelectedValue(value);
this.checkAll(false);
@ -1944,7 +1953,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.options.paras.selectedValues = BI.deepClone(value) || {};
this.selectedValues = BI.deepClone(value) || {};
},
@ -1963,12 +1972,6 @@ BI.TreeView = BI.inherit(BI.Pane, {
});
},
getExpandedValue: function(){
if (!this.nodes) {
return null;
}
},
refresh: function () {
this.nodes && this.nodes.refresh();
},
@ -1980,14 +1983,9 @@ BI.TreeView = BI.inherit(BI.Pane, {
return this._getSelectedValues();
},
empty: function () {
BI.isNotNull(this.nodes) && this.nodes.destroy();
},
destroy: function () {
destroyed: function () {
this.stop();
this.nodes && this.nodes.destroy();
BI.TreeView.superclass.destroy.apply(this, arguments);
}
});
BI.extend(BI.TreeView, {
@ -2190,7 +2188,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return this.selectedValues;
return BI.deepClone(this.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
return checkedValues;
@ -2257,7 +2255,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA,
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues
@ -2532,8 +2530,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-collection",
width: 400,
height: 300,
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
cellSizeAndPositionGetter: BI.emptyFn,
@ -14673,16 +14671,16 @@ BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
width: 400,
height: 300,
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
overscanColumnCount: 0,
overscanRowCount: 0,
rowHeightGetter: BI.emptyFn,
columnWidthGetter: BI.emptyFn,
estimatedColumnSize: 100,
estimatedRowSize: 30,
rowHeightGetter: BI.emptyFn, //number类型或function类型
columnWidthGetter: BI.emptyFn, //number类型或function类型
// estimatedColumnSize: 100, //columnWidthGetter为function时必设
// estimatedRowSize: 30, //rowHeightGetter为function时必设
scrollLeft: 0,
scrollTop: 0,
items: []
@ -15157,7 +15155,7 @@ BI.FloatBox.EVENT_FLOAT_BOX_OPEN = "EVENT_FLOAT_BOX_CLOSED";
BI.PopupView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-list-view",
baseCls: "bi-popup-view",
maxWidth: 'auto',
minWidth: 100,
//maxHeight: 200,
@ -15458,6 +15456,295 @@ BI.SearcherView = BI.inherit(BI.Pane, {
BI.SearcherView.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.searcher_view", BI.SearcherView);/**
* 表示当前对象
*
* Created by GUY on 2017/5/23.
* @class BI.ListView
* @extends BI.Widget
*/
BI.ListView = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-list-view",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
el: {},
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [BI.extend({
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, o.el)],
element: this
}
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
restore: function () {
this.renderedIndex = -1;
this.container.empty();
this.cache = {};
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut('bi.list_view', BI.ListView);
/**
* 表示当前对象
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
*/
BI.VirtualList = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-virtual-list",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
}, {
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
}],
element: this
}
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
var height = this.element.height();
var minContentHeightFrom = o.scrollTop - o.overscanHeight;
var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
var start = this.tree.greatestLowerBound(minContentHeightFrom);
var end = this.tree.leastUpperBound(minContentHeightTo);
var needDestroyed = [];
for (var i = 0; i < start; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
for (var i = end + 1; i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
var firstFragment = document.createDocumentFragment(), lastFragment = document.createDocumentFragment();
var currentFragment = firstFragment;
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
currentFragment = lastFragment;
}
if (this.cache[i].destroyed === true) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
var w = this.container._addElement(j, BI.extend({root: true}, BI.stripEL(o.items[j])));
currentFragment.appendChild(w.element[0]);
}
this.cache[i].destroyed = false;
}
}
this.container.element.prepend(firstFragment);
this.container.element.append(lastFragment);
this.topBlank.setHeight(this.cache[start < 0 ? 0 : start].scrollTop);
var lastCache = this.cache[Math.min(end, this.renderedIndex)];
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - lastCache.scrollTop - lastCache.height);
BI.each(needDestroyed, function (i, child) {
child && child._destroy();
});
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize));
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
_clearChildren: function () {
BI.each(this.container._children, function (i, cell) {
cell && cell.el._destroy();
});
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
this.renderedIndex = -1;
this._clearChildren();
this.cache = {};
this.options.scrollTop = 0;
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut('bi.virtual_list', BI.VirtualList);
/**
* 分页控件
*
* Created by GUY on 2015/8/31.
@ -17848,11 +18135,6 @@ BI.Editor = BI.inherit(BI.Single, {
return BI.trim(this.editor.getValue());
},
setValid: function (b) {
BI.Editor.superclass.setValid.apply(this, arguments);
this.editor.setValid(b);
},
isEditing: function () {
return this.editor.isEditing();
},
@ -18119,10 +18401,10 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
return this.style;
},
setValid: function (b) {
BI.TextAreaEditor.superclass.setValid.apply(this, arguments);
this.content.setValid(b);
this.watermark && this.watermark.setValid(b);
_setValid: function (b) {
BI.TextAreaEditor.superclass._setValid.apply(this, arguments);
// this.content.setValid(b);
// this.watermark && this.watermark.setValid(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";
@ -19115,8 +19397,8 @@ BI.Input = BI.inherit(BI.Single, {
return this._lastValidValue;
},
setValid: function () {
BI.Input.superclass.setValid.apply(this, arguments);
_setValid: function () {
BI.Input.superclass._setValid.apply(this, arguments);
if (this.isValid()) {
this._lastValidValue = this.getValue();
this.element.removeClass("bi-input-error");

1917
docs/case.js

File diff suppressed because it is too large Load Diff

182
docs/core.js

@ -13494,15 +13494,15 @@ if (!window.BI) {
},
has: function (obj, keys) {
if (BI.isKey(keys)) {
return _.has.apply(_, arguments);
}
if (!keys || BI.isEmpty(keys)) {
return false;
if (BI.isArray(keys)) {
if (keys.length === 0) {
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key
@ -14367,9 +14367,10 @@ BI.Widget = BI.inherit(BI.OB, {
this._initRoot();
this._initElementWidth();
this._initElementHeight();
this._initVisualEffects();
this._initVisual();
this._initState();
this._initElement();
this._initEffects();
this.created && this.created();
},
@ -14424,21 +14425,23 @@ BI.Widget = BI.inherit(BI.OB, {
}
},
_initVisualEffects: function () {
_initVisual: function () {
var o = this.options;
if (o.invisible) {
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none");
}
},
_initEffects: function () {
var o = this.options;
if (o.disabled || o.invalid) {
// BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
// }, this));
}
},
@ -18115,7 +18118,7 @@ $.extend(BI, {
return new BI.PrefixIntervalTree(xs);
};
BI.PrefixIntervalTree.empty = function () {
BI.PrefixIntervalTree.empty = function (size) {
return BI.PrefixIntervalTree.uniform(size, 0);
};
@ -18448,7 +18451,7 @@ $.extend(BI, {
},
isRoot: function (node) {
return node === this.root || node.id === this.root.id;
return node === this.root;
},
getRoot: function () {
@ -18825,7 +18828,7 @@ $.extend(BI, {
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = BI.clone(nodes[i]);
node.pId = pId;
node.pId = node.pId == null ? pId : node.pId;
delete node.children;
r.push(node);
if (nodes[i]["children"]) {
@ -18834,7 +18837,7 @@ $.extend(BI, {
}
} else {
var newNodes = BI.clone(nodes);
newNodes.pId = pId;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
delete newNodes.children;
r.push(newNodes);
if (nodes["children"]) {
@ -18845,21 +18848,25 @@ $.extend(BI, {
},
arrayFormat: function (nodes, pId) {
if (!nodes) return [];
if (!nodes) {
return [];
}
var r = [];
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
node.pId = node.pId == null ? pId : node.pId;
r.push(node);
if (nodes[i]["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
}
}
} else {
var newNodes = nodes;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
r.push(newNodes);
if (nodes["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
}
}
return r;
@ -18875,13 +18882,13 @@ $.extend(BI, {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if(BI.isNull(sNodes[i].id)) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
@ -18897,6 +18904,37 @@ $.extend(BI, {
}
},
treeFormat: function (sNodes) {
var i, l;
if (!sNodes) {
return [];
}
if (BI.isArray(sNodes)) {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = sNodes[i];
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
} else {
r.push(tmpMap[sNodes[i].id]);
}
}
return r;
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;
@ -20949,7 +20987,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
}
this.floatContainer[name] = BI.createWidget({
type: "bi.absolute",
cls: "bi-list-view",
cls: "bi-popup-view",
items: [{
el: (this.floatLayer[name] = BI.createWidget({
type: 'bi.absolute',
@ -21039,6 +21077,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
delete this.floatLayer[name];
delete this.zindexMap[name];
delete this.floatContainer[name];
delete this.floatOpened[name];
return this;
}
});/**
@ -21136,7 +21175,7 @@ BI.LayerController = BI.inherit(BI.Controller, {
}]
});
if (w) {
layout.element.addClass("bi-list-view");
layout.element.addClass("bi-popup-view");
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),
@ -24042,59 +24081,64 @@ Function.prototype.after = function (func) {
* All rights reserved.
*/
if (jQuery) {
(function($){
(function ($) {
// richer:容器在其各个边缘留出的空间
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
if (!$.fn.insets) {
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
};
};
};
}
// richer:获取 && 设置jQuery元素的边界
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds : true};
if (!$.fn.bounds) {
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds: true};
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0;
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
}
this.css(tmp);
return this;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
else {
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
'x': tmp.left,
'y': tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(),
'height': this.outerHeight()
};
}
this.css(tmp);
return this;
}
else {
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
'x': tmp.left,
'y': tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(),
'height': this.outerHeight()
};
}
};
};
}
})(jQuery);
};if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
}
;if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' ||
(0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' ||
(1000000000000000128).toFixed(0) !== "1000000000000000128") {
(function () {
@ -24355,7 +24399,7 @@ function accDiv(arg1, arg2) {
with (Math) {
r1 = Number(arg1.toString().replace(".", ""));
r2 = Number(arg2.toString().replace(".", ""));
return (r1 / r2) * pow(10, t2 - t1);
return (t2 > t1) ? (r1 / r2) * pow(10, t2 - t1) : (r1 / r2) / pow(10, t1 - t2);
}
}

214
docs/demo.js

File diff suppressed because one or more lines are too long

500
docs/widget.js

@ -79,7 +79,9 @@ BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
var cnt = this.start;
function track(node) {
self.cache[node.text || node.value] = cnt++;
//如果已经有缓存了就不改计数了,复杂表会出现这种情况
self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
cnt++;
}
BI.each(nodes, function (i, node) {
@ -10962,8 +10964,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
el: {}
valueFormatter: BI.emptyFn
})
},
_init: function () {
@ -10974,6 +10975,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -11033,6 +11035,8 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
@ -11044,7 +11048,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
@ -11064,13 +11067,11 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
}
@ -11096,8 +11097,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 30
@ -11109,8 +11108,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
@ -11307,8 +11304,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-tree',
itemsCreator: BI.emptyFn,
height: 25
itemsCreator: BI.emptyFn
})
},
@ -11354,7 +11350,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
@ -11394,8 +11389,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 30
@ -11407,8 +11400,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
@ -11444,6 +11435,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
});
},
stopSearch: function () {
this.trigger.stopSearch();
},
updateValue: function (v) {
this.adapter.updateValue(v);
},
getValue: function () {
return this.storeValue.value;
},
@ -11469,7 +11468,6 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.async_tree",
height: 400,
element: this,
itemsCreator: o.itemsCreator
});
@ -11494,6 +11492,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
this.popup.setValue(v.value);
},
updateValue: function (v) {
this.popup.updateValue(v);
this.popup.refresh();
},
populate: function (config) {
this.popup.stroke(config);
}
@ -16975,17 +16978,17 @@ BI.shortcut('bi.year_quarter_combo', BI.YearQuarterCombo);/**
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserCombo
* @class BI.AbstractAllValueChooser
* @extends BI.Widget
*/
BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 10
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-combo",
return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
width: 200,
height: 30,
items: null,
@ -16994,35 +16997,17 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
});
},
_init: function () {
BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
return text;
},
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
});
});
}
return text;
},
_itemsCreator: function (options, callback) {
@ -17065,6 +17050,46 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
hasNext: false
});
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserCombo
* @extends BI.AbstractAllValueChooser
*/
BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.AllValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM);
});
},
setValue: function (v) {
@ -17088,70 +17113,84 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
});
BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM";
BI.shortcut('bi.all_value_chooser_combo', BI.AllValueChooserCombo);/**
* 简单的复选下拉树控件, 适用于数据量少的情况
* 简单的复选下拉框控件, 适用于数据量少的情况 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserCombo
* @extends BI.Widget
* @class BI.AllValueChooserPane
* @extends BI.AbstractAllValueChooser
*/
BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
_const: {
perPage: 10
},
BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-combo",
return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-pane",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
BI.AllValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this._initData(o.items);
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_tree_combo',
this.list = BI.createWidget({
type: 'bi.multi_select_list',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
});
},
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.transformToTreeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
this._initMap();
this._initFloors();
setValue: function (v) {
this.list.setValue({
type: BI.Selection.Multi,
value: v || []
});
},
_initMap: function () {
var map = this.map = {};
BI.each(this.items, function (i, item) {
map[item.value] = item;
getValue: function () {
var val = this.list.getValue() || {};
if (val.type === BI.Selection.All) {
return val.assist;
}
return val.value || [];
},
populate: function () {
this.list.populate.apply(this.list, arguments);
}
});
BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
items: null,
itemsCreator: BI.emptyFn
});
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
},
_itemsCreator: function (options, callback) {
@ -17195,32 +17234,29 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
return;
}
doCheck(0, [], this.tree.getRoot(), selectedValues);
doCheck([], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(floor, parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
function doCheck(parentValues, node, selected) {
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {});
doCheck(newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(k);
var node = self._getNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]);
doCheck(newParents, node, selected[k]);
})
}
@ -17310,9 +17346,6 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
if (self._isMatch(current, keyword)) {
return true;
}
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents);
@ -17448,9 +17481,6 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
@ -17475,14 +17505,14 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self.map[value];
var node = self._getNode(parentValues, value)
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: parentValues.length + 1 < self.floors,
isParent: node.getChildrenLength() > 0,
open: isOpen,
checked: checked,
halfCheck: half,
@ -17566,7 +17596,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: parentValues.length + 1 < this.floors,
isParent: nodes[i].getChildrenLength() > 0,
checked: state[0],
halfCheck: state[1]
})
@ -17613,14 +17643,14 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) {
var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
@ -17653,14 +17683,34 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (v) {
return this.tree.search(v, "value");
_getNode: function (parentValues, v) {
var self = this;
var findedParentNode;
var index = 0;
this.tree.traverse(function (node) {
if (self.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
return false;
}
if (index === parentValues.length && node.value === v) {
findedParentNode = node;
return false;
}
if (node.value === parentValues[index]) {
index++;
return;
}
return true;
});
return findedParentNode;
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this.tree.search(value, "value");
var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
var parent = this.tree.getRoot();
}
@ -17669,6 +17719,43 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
_getChildCount: function (parentValues) {
return this._getChildren(parentValues).length;
}
});/**
* 简单的复选下拉树控件, 适用于数据量少的情况
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserCombo
* @extends BI.Widget
*/
BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.TreeValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this._initData(o.items);
}
this.combo = BI.createWidget({
type: 'bi.multi_tree_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM);
});
},
setValue: function (v) {
@ -17680,63 +17767,91 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
},
populate: function () {
this.combo.populate.apply(this, arguments);
this.combo.populate.apply(this.combo, arguments);
}
});
BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";
BI.shortcut('bi.tree_value_chooser_combo', BI.TreeValueChooserCombo);/**
* 简单的复选下拉树控件, 适用于数据量少的情况
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserPane
* @extends BI.AbstractTreeValueChooser
*/
BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-pane",
items: null,
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.pane = BI.createWidget({
type: 'bi.multi_select_tree',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this)
});
this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
});
if (BI.isNotNull(o.items)) {
this._initData(o.items);
this.populate();
}
},
setValue: function (v) {
this.pane.setValue(v);
},
getValue: function () {
return this.pane.getValue();
},
populate: function () {
this.pane.populate.apply(this.pane, arguments);
}
});
BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserCombo
* @class BI.AbstractValueChooser
* @extends BI.Widget
*/
BI.ValueChooserCombo = BI.inherit(BI.Widget, {
BI.AbstractValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 10
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-combo",
width: 200,
height: 30,
return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
return text;
},
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
});
});
}
return text;
},
_getItemsByTimes: function (items, times) {
@ -17791,6 +17906,46 @@ BI.ValueChooserCombo = BI.inherit(BI.Widget, {
hasNext: self._hasNextByTimes(items, options.times)
});
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserCombo
* @extends BI.Widget
*/
BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-combo",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM);
});
},
setValue: function (v) {
@ -17810,4 +17965,59 @@ BI.ValueChooserCombo = BI.inherit(BI.Widget, {
}
});
BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM";
BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);
BI.shortcut('bi.value_chooser_combo', BI.ValueChooserCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserPane
* @extends BI.Widget
*/
BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-pane",
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.list = BI.createWidget({
type: 'bi.multi_select_list',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this)
});
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
});
if (BI.isNotNull(o.items)) {
this.items = o.items;
this.populate();
}
},
setValue: function (v) {
this.list.setValue(v);
},
getValue: function () {
var val = this.list.getValue() || {};
return {
type: val.type,
value: val.value
}
},
populate: function () {
this.list.populate.apply(this.list, arguments);
}
});
BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane);

4
src/base/collection/collection.js

@ -9,8 +9,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.CollectionView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-collection",
width: 400,
height: 300,
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
cellSizeAndPositionGetter: BI.emptyFn,

0
src/base/foundation/bi.message.js → src/base/foundation/message.js

12
src/base/grid/grid.js

@ -9,16 +9,16 @@ BI.GridView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.GridView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-grid-view",
width: 400,
height: 300,
// width: 400, //必设
// height: 300, //必设
overflowX: true,
overflowY: true,
overscanColumnCount: 0,
overscanRowCount: 0,
rowHeightGetter: BI.emptyFn,
columnWidthGetter: BI.emptyFn,
estimatedColumnSize: 100,
estimatedRowSize: 30,
rowHeightGetter: BI.emptyFn, //number类型或function类型
columnWidthGetter: BI.emptyFn, //number类型或function类型
// estimatedColumnSize: 100, //columnWidthGetter为function时必设
// estimatedRowSize: 30, //rowHeightGetter为function时必设
scrollLeft: 0,
scrollTop: 0,
items: []

2
src/base/layer/layer.popup.js

@ -6,7 +6,7 @@
BI.PopupView = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.PopupView.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-list-view",
baseCls: "bi-popup-view",
maxWidth: 'auto',
minWidth: 100,
//maxHeight: 200,

110
src/base/list/listview.js

@ -0,0 +1,110 @@
/**
* 表示当前对象
*
* Created by GUY on 2017/5/23.
* @class BI.ListView
* @extends BI.Widget
*/
BI.ListView = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-list-view",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
el: {},
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [BI.extend({
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, o.el)],
element: this
}
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
restore: function () {
this.renderedIndex = -1;
this.container.empty();
this.cache = {};
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut('bi.list_view', BI.ListView);

179
src/base/list/virtuallist.js

@ -0,0 +1,179 @@
/**
* 表示当前对象
*
* Created by GUY on 2017/5/22.
* @class BI.VirtualList
* @extends BI.Widget
*/
BI.VirtualList = BI.inherit(BI.Widget, {
props: function () {
return {
baseCls: "bi-virtual-list",
overscanHeight: 100,
blockSize: 10,
scrollTop: 0,
items: []
};
},
init: function () {
var self = this;
this.renderedIndex = -1;
this.cache = {};
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
items: [{
type: "bi.layout",
ref: function () {
self.topBlank = this;
}
}, {
type: "bi.vertical",
scrolly: false,
ref: function () {
self.container = this;
}
}, {
type: "bi.layout",
ref: function () {
self.bottomBlank = this;
}
}],
element: this
}
},
mounted: function () {
var self = this, o = this.options;
this._populate();
this.element.scroll(function (e) {
o.scrollTop = self.element.scrollTop();
self._calculateBlocksToRender();
});
BI.ResizeDetector.addResizeListener(this, function () {
self._calculateBlocksToRender();
});
},
_renderMoreIf: function () {
var self = this, o = this.options;
var height = this.element.height();
var minContentHeight = o.scrollTop + height + o.overscanHeight;
var index = (this.cache[this.renderedIndex] && (this.cache[this.renderedIndex].index + o.blockSize)) || 0,
cnt = this.renderedIndex + 1;
var lastHeight;
var getElementHeight = function () {
return self.container.element.height() + self.topBlank.element.height() + self.bottomBlank.element.height();
};
while ((lastHeight = getElementHeight()) < minContentHeight && index < o.items.length) {
var items = o.items.slice(index, index + o.blockSize);
this.container.addItems(items);
var addedHeight = getElementHeight() - lastHeight;
this.cache[cnt] = {
index: index,
scrollTop: lastHeight,
height: addedHeight
};
this.tree.set(cnt, addedHeight);
this.renderedIndex = cnt;
cnt++;
index += o.blockSize;
}
},
_calculateBlocksToRender: function () {
var o = this.options;
this._renderMoreIf();
var height = this.element.height();
var minContentHeightFrom = o.scrollTop - o.overscanHeight;
var minContentHeightTo = o.scrollTop + height + o.overscanHeight;
var start = this.tree.greatestLowerBound(minContentHeightFrom);
var end = this.tree.leastUpperBound(minContentHeightTo);
var needDestroyed = [];
for (var i = 0; i < start; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
for (var i = end + 1; i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
needDestroyed.push(this.container._children[j]);
this.container._children[j] = null;
}
this.cache[i].destroyed = true;
}
}
var firstFragment = document.createDocumentFragment(), lastFragment = document.createDocumentFragment();
var currentFragment = firstFragment;
for (var i = (start < 0 ? 0 : start); i <= end && i <= this.renderedIndex; i++) {
var index = this.cache[i].index;
if (!this.cache[i].destroyed) {
currentFragment = lastFragment;
}
if (this.cache[i].destroyed === true) {
for (var j = index; j < index + o.blockSize && j < o.items.length; j++) {
var w = this.container._addElement(j, BI.extend({root: true}, BI.stripEL(o.items[j])));
currentFragment.appendChild(w.element[0]);
}
this.cache[i].destroyed = false;
}
}
this.container.element.prepend(firstFragment);
this.container.element.append(lastFragment);
this.topBlank.setHeight(this.cache[start < 0 ? 0 : start].scrollTop);
var lastCache = this.cache[Math.min(end, this.renderedIndex)];
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - lastCache.scrollTop - lastCache.height);
BI.each(needDestroyed, function (i, child) {
child && child._destroy();
});
},
_populate: function (items) {
var o = this.options;
if (items && this.options.items !== items) {
this.options.items = items;
}
this.tree = BI.PrefixIntervalTree.empty(Math.ceil(o.items.length / o.blockSize));
this._calculateBlocksToRender();
this.element.scrollTop(o.scrollTop);
},
_clearChildren: function () {
BI.each(this.container._children, function (i, cell) {
cell && cell.el._destroy();
});
this.container._children = {};
this.container.attr("items", []);
},
restore: function () {
this.renderedIndex = -1;
this._clearChildren();
this.cache = {};
this.options.scrollTop = 0;
},
populate: function (items) {
if (items && this.options.items !== items) {
this.restore();
}
this._populate();
},
destroyed: function () {
this.restore();
}
});
BI.shortcut('bi.virtual_list', BI.VirtualList);

13
src/base/single/button/button.basic.js

@ -214,7 +214,7 @@ BI.BasicButton = BI.inherit(BI.Single, {
if (!self.isEnabled() || (self.isOnce() && self.isSelected())) {
return;
}
onClick.apply(self);
onClick.apply(self, arguments);
}
},
@ -233,13 +233,20 @@ BI.BasicButton = BI.inherit(BI.Single, {
}
},
_doClick: function () {
_doClick: function (e) {
if (this.isValid()) {
this.beforeClick(e);
}
this._trigger();
if (this.isValid()) {
this.doClick();
this.doClick(e);
}
},
beforeClick: function () {
},
doClick: function () {
},

5
src/base/single/editor/editor.js

@ -292,11 +292,6 @@ BI.Editor = BI.inherit(BI.Single, {
return BI.trim(this.editor.getValue());
},
setValid: function (b) {
BI.Editor.superclass.setValid.apply(this, arguments);
this.editor.setValid(b);
},
isEditing: function () {
return this.editor.isEditing();
},

8
src/base/single/editor/editor.textarea.js

@ -149,10 +149,10 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
return this.style;
},
setValid: function (b) {
BI.TextAreaEditor.superclass.setValid.apply(this, arguments);
this.content.setValid(b);
this.watermark && this.watermark.setValid(b);
_setValid: function (b) {
BI.TextAreaEditor.superclass._setValid.apply(this, arguments);
// this.content.setValid(b);
// this.watermark && this.watermark.setValid(b);
}
});
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";

4
src/base/single/input/input.js

@ -241,8 +241,8 @@ BI.Input = BI.inherit(BI.Single, {
return this._lastValidValue;
},
setValid: function () {
BI.Input.superclass.setValid.apply(this, arguments);
_setValid: function () {
BI.Input.superclass._setValid.apply(this, arguments);
if (this.isValid()) {
this._lastValidValue = this.getValue();
this.element.removeClass("bi-input-error");

2
src/base/tree/asynctree.js

@ -187,7 +187,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return this.selectedValues;
return BI.deepClone(this.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
return checkedValues;

2
src/base/tree/parttree.js

@ -46,7 +46,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA,
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues

19
src/base/tree/treeview.js

@ -216,7 +216,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
_getNodeValue: function (node) {
//去除标红
return node.value || node.text.replace(/<[^>]+>/g, "");
return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value;
},
//获取半选框值
@ -308,6 +308,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var self = this, o = this.options;
var ns = BI.Tree.arrayFormat(nodes);
BI.each(ns, function (i, n) {
n.title = n.title || n.text || n.value;
//处理标红
if (BI.isKey(o.paras.keyword)) {
n.text = $("<div>").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
@ -442,6 +443,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
this.nodes && this.nodes.expandAll(flag);
},
//设置树节点的状态
setValue: function (value, param) {
this.setSelectedValue(value);
this.checkAll(false);
@ -450,7 +452,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.options.paras.selectedValues = BI.deepClone(value) || {};
this.selectedValues = BI.deepClone(value) || {};
},
@ -469,12 +471,6 @@ BI.TreeView = BI.inherit(BI.Pane, {
});
},
getExpandedValue: function(){
if (!this.nodes) {
return null;
}
},
refresh: function () {
this.nodes && this.nodes.refresh();
},
@ -486,14 +482,9 @@ BI.TreeView = BI.inherit(BI.Pane, {
return this._getSelectedValues();
},
empty: function () {
BI.isNotNull(this.nodes) && this.nodes.destroy();
},
destroy: function () {
destroyed: function () {
this.stop();
this.nodes && this.nodes.destroy();
BI.TreeView.superclass.destroy.apply(this, arguments);
}
});
BI.extend(BI.TreeView, {

1319
src/case/clipboard/clipboard.js

File diff suppressed because it is too large Load Diff

46
src/case/clipboard/index.js

@ -0,0 +1,46 @@
/**
* 复制
* Created by GUY on 2016/2/16.
* @class BI.ClipBoard
* @extends BI.BasicButton
*/
BI.ClipBoard = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
return BI.extend(BI.ClipBoard.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-clipboard",
copy: BI.emptyFn,
afterCopy: BI.emptyFn
})
},
_init: function () {
BI.ClipBoard.superclass._init.apply(this, arguments);
},
mounted: function () {
var self = this, o = this.options;
if (window.Clipboard) {
this.clipboard = new Clipboard(this.element[0], {
text: function () {
return BI.isFunction(o.copy) ? o.copy() : o.copy;
}
});
this.clipboard.on("success", function (e) {
o.afterCopy();
})
} else {
this.element.zclip({
path: BI.resourceURL + "/ZeroClipboard.swf",
copy: o.copy,
beforeCopy: o.beforeCopy,
afterCopy: o.afterCopy
});
}
},
destroyed: function () {
this.clipboard && this.clipboard.destroy();
}
});
BI.shortcut("bi.clipboard", BI.ClipBoard);

6
src/case/editor/editor.search.js

@ -157,11 +157,7 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
this.clear.visible();
}
},
setValid: function (b) {
this.editor.setValid(b);
},
isEditing: function () {
return this.editor.isEditing();
},

5
src/case/editor/editor.sign.js

@ -206,11 +206,6 @@ BI.SignEditor = BI.inherit(BI.Widget, {
return this.editor.isValid();
},
setValid: function (v) {
BI.SignEditor.superclass.setValid.apply(this, arguments);
this.editor.setValid(v);
},
setErrorText: function (text) {
this.editor.setErrorText(text);
},

14
src/case/toolbar/toolbar.multiselect.js

@ -12,7 +12,8 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
height: 25,
text: BI.i18nText('BI-Select_All'),
isAllCheckedBySelectedValue: BI.emptyFn,
onCheck: BI.emptyFn,
//手动控制选中
disableSelected: true,
isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0;
}
@ -26,7 +27,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(self.isSelected());
o.onCheck.call(self, self.isSelected());
}
});
this.half = BI.createWidget({
@ -34,7 +34,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(true);
o.onCheck.call(self, self.isSelected());
}
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
@ -77,19 +76,14 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
this.half.invisible();
},
doClick: function () {
//自己手动控制选中
beforeClick: function () {
var isHalf = this.isHalfSelected(), isSelected = this.isSelected();
if (isHalf === true) {
this.setSelected(true);
} else {
this.setSelected(!isSelected);
}
if (this.isValid()) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, this.getValue(), this);
this.options.onCheck.call(this, this.isSelected());
this.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, this.isSelected(), this);
}
},
setSelected: function (v) {

495
src/case/zclip/jquery.zclip.js

@ -1,495 +0,0 @@
/*
* zClip :: jQuery ZeroClipboard v1.1.1
* http://steamdev.com/zclip
*
* Copyright 2011, SteamDev
* Released under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Date: Wed Jun 01, 2011
*/
(function ($) {
$.fn.zclip = function (params) {
if (typeof params == "object" && !params.length) {
var settings = $.extend({
path: 'ZeroClipboard.swf',
copy: null,
beforeCopy: null,
afterCopy: null,
clickAfter: true,
setHandCursor: true,
setCSSEffects: true
}, params);
return this.each(function () {
var o = $(this);
if (o.is(':visible') && (typeof settings.copy == 'string' || $.isFunction(settings.copy))) {
ZeroClipboard.setMoviePath(settings.path);
var clip = new ZeroClipboard.Client();
if($.isFunction(settings.copy)){
o.bind('zClip_copy',settings.copy);
}
if($.isFunction(settings.beforeCopy)){
o.bind('zClip_beforeCopy',settings.beforeCopy);
}
if($.isFunction(settings.afterCopy)){
o.bind('zClip_afterCopy',settings.afterCopy);
}
clip.setHandCursor(settings.setHandCursor);
clip.setCSSEffects(settings.setCSSEffects);
clip.addEventListener('mouseOver', function (client) {
o.trigger('mouseenter');
});
clip.addEventListener('mouseOut', function (client) {
o.trigger('mouseleave');
});
clip.addEventListener('mouseDown', function (client) {
o.trigger('mousedown');
if(!$.isFunction(settings.copy)){
clip.setText(settings.copy);
} else {
clip.setText(o.triggerHandler('zClip_copy'));
}
if ($.isFunction(settings.beforeCopy)) {
o.trigger('zClip_beforeCopy');
}
});
clip.addEventListener('complete', function (client, text) {
if ($.isFunction(settings.afterCopy)) {
o.trigger('zClip_afterCopy');
} else {
if (text.length > 500) {
text = text.substr(0, 500) + "...\n\n(" + (text.length - 500) + " characters not shown)";
}
o.removeClass('hover');
alert("Copied text to clipboard:\n\n " + text);
}
if (settings.clickAfter) {
o.trigger('click');
}
});
clip.glue(o[0], o.parent()[0]);
$(window).bind('load resize',function(){clip.reposition();});
}
});
} else if (typeof params == "string") {
return this.each(function () {
var o = $(this);
params = params.toLowerCase();
var zclipId = o.data('zclipId');
var clipElm = $('#' + zclipId + '.zclip');
if (params == "remove") {
clipElm.remove();
o.removeClass('active hover');
} else if (params == "hide") {
clipElm.hide();
o.removeClass('active hover');
} else if (params == "show") {
clipElm.show();
}
});
}
}
})(jQuery);
// ZeroClipboard
// Simple Set Clipboard System
// Author: Joseph Huckaby
var ZeroClipboard = {
version: "1.0.7",
clients: {},
// registered upload clients on page, indexed by id
moviePath: 'ZeroClipboard.swf',
// URL to movie
nextId: 1,
// ID of next movie
$: function (thingy) {
// simple DOM lookup utility function
if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
if (!thingy.addClass) {
// extend element with a few useful methods
thingy.hide = function () {
this.style.display = 'none';
};
thingy.show = function () {
this.style.display = '';
};
thingy.addClass = function (name) {
this.removeClass(name);
this.className += ' ' + name;
};
thingy.removeClass = function (name) {
var classes = this.className.split(/\s+/);
var idx = -1;
for (var k = 0; k < classes.length; k++) {
if (classes[k] == name) {
idx = k;
k = classes.length;
}
}
if (idx > -1) {
classes.splice(idx, 1);
this.className = classes.join(' ');
}
return this;
};
thingy.hasClass = function (name) {
return !!this.className.match(new RegExp("\\s*" + name + "\\s*"));
};
}
return thingy;
},
setMoviePath: function (path) {
// set path to ZeroClipboard.swf
this.moviePath = path;
},
dispatch: function (id, eventName, args) {
// receive event from flash movie, send to client
var client = this.clients[id];
if (client) {
client.receiveEvent(eventName, args);
}
},
register: function (id, client) {
// register new client to receive events
this.clients[id] = client;
},
getDOMObjectPosition: function (obj, stopObj) {
// get absolute coordinates for dom element
var info = {
left: 0,
top: 0,
width: obj.width ? obj.width : obj.offsetWidth,
height: obj.height ? obj.height : obj.offsetHeight
};
if (obj && (obj != stopObj)) {
info.left += obj.offsetLeft;
info.top += obj.offsetTop;
}
return info;
},
Client: function (elem) {
// constructor for new simple upload client
this.handlers = {};
// unique ID
this.id = ZeroClipboard.nextId++;
this.movieId = 'ZeroClipboardMovie_' + this.id;
// register client with singleton to receive flash events
ZeroClipboard.register(this.id, this);
// create movie
if (elem) this.glue(elem);
}
};
ZeroClipboard.Client.prototype = {
id: 0,
// unique ID for us
ready: false,
// whether movie is ready to receive events or not
movie: null,
// reference to movie object
clipText: '',
// text to copy to clipboard
handCursorEnabled: true,
// whether to show hand cursor, or default pointer cursor
cssEffects: true,
// enable CSS mouse effects on dom container
handlers: null,
// user event handlers
glue: function (elem, appendElem, stylesToAdd) {
// glue to DOM element
// elem can be ID or actual DOM element object
this.domElement = ZeroClipboard.$(elem);
// float just above object, or zIndex 99 if dom element isn't set
var zIndex = 99;
if (this.domElement.style.zIndex) {
zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
}
if (typeof(appendElem) == 'string') {
appendElem = ZeroClipboard.$(appendElem);
} else if (typeof(appendElem) == 'undefined') {
appendElem = document.getElementsByTagName('body')[0];
}
// find X/Y position of domElement
var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
// create floating DIV above element
this.div = document.createElement('div');
this.div.className = "zclip";
this.div.id = "zclip-" + this.movieId;
$(this.domElement).data('zclipId', 'zclip-' + this.movieId);
var style = this.div.style;
style.position = 'absolute';
style.left = '' + box.left + 'px';
style.top = '' + box.top + 'px';
style.width = '' + box.width + 'px';
style.height = '' + box.height + 'px';
style.zIndex = zIndex;
if (typeof(stylesToAdd) == 'object') {
for (addedStyle in stylesToAdd) {
style[addedStyle] = stylesToAdd[addedStyle];
}
}
// style.backgroundColor = '#f00'; // debug
appendElem.appendChild(this.div);
this.div.innerHTML = this.getHTML(box.width, box.height);
},
getHTML: function (width, height) {
// return HTML for movie
var html = '';
var flashvars = 'id=' + this.id + '&width=' + width + '&height=' + height;
if (navigator.userAgent.match(/MSIE/)) {
// IE gets an OBJECT tag
var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' + protocol + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" id="' + this.movieId + '" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="' + ZeroClipboard.moviePath + '" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="' + flashvars + '"/><param name="wmode" value="transparent"/></object>';
} else {
// all other browsers get an EMBED tag
html += '<embed id="' + this.movieId + '" src="' + ZeroClipboard.moviePath + '" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="' + this.movieId + '" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + flashvars + '" wmode="transparent" />';
}
return html;
},
hide: function () {
// temporarily hide floater offscreen
if (this.div) {
this.div.style.left = '-2000px';
}
},
show: function () {
// show ourselves after a call to hide()
this.reposition();
},
destroy: function () {
// destroy control and floater
if (this.domElement && this.div) {
this.hide();
this.div.innerHTML = '';
var body = document.getElementsByTagName('body')[0];
try {
body.removeChild(this.div);
} catch (e) {;
}
this.domElement = null;
this.div = null;
}
},
reposition: function (elem) {
// reposition our floating div, optionally to new container
// warning: container CANNOT change size, only position
if (elem) {
this.domElement = ZeroClipboard.$(elem);
if (!this.domElement) this.hide();
}
if (this.domElement && this.div) {
var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
var style = this.div.style;
style.left = '' + box.left + 'px';
style.top = '' + box.top + 'px';
}
},
setText: function (newText) {
// set text to be copied to clipboard
this.clipText = newText;
if (this.ready) {
this.movie.setText(newText);
}
},
addEventListener: function (eventName, func) {
// add user event listener for event
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
if (!this.handlers[eventName]) {
this.handlers[eventName] = [];
}
this.handlers[eventName].push(func);
},
setHandCursor: function (enabled) {
// enable hand cursor (true), or default arrow cursor (false)
this.handCursorEnabled = enabled;
if (this.ready) {
this.movie.setHandCursor(enabled);
}
},
setCSSEffects: function (enabled) {
// enable or disable CSS effects on DOM container
this.cssEffects = !! enabled;
},
receiveEvent: function (eventName, args) {
// receive event from flash
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
// special behavior for certain events
switch (eventName) {
case 'load':
// movie claims it is ready, but in IE this isn't always the case...
// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
this.movie = document.getElementById(this.movieId);
if (!this.movie) {
var self = this;
setTimeout(function () {
self.receiveEvent('load', null);
}, 1);
return;
}
// firefox on pc needs a "kick" in order to set these in certain cases
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
var self = this;
setTimeout(function () {
self.receiveEvent('load', null);
}, 100);
this.ready = true;
return;
}
this.ready = true;
try {
this.movie.setText(this.clipText);
} catch (e) {}
try {
this.movie.setHandCursor(this.handCursorEnabled);
} catch (e) {}
break;
case 'mouseover':
if (this.domElement && this.cssEffects) {
this.domElement.addClass('hover');
if (this.recoverActive) {
this.domElement.addClass('active');
}
}
break;
case 'mouseout':
if (this.domElement && this.cssEffects) {
this.recoverActive = false;
if (this.domElement.hasClass('active')) {
this.domElement.removeClass('active');
this.recoverActive = true;
}
this.domElement.removeClass('hover');
}
break;
case 'mousedown':
if (this.domElement && this.cssEffects) {
this.domElement.addClass('active');
}
break;
case 'mouseup':
if (this.domElement && this.cssEffects) {
this.domElement.removeClass('active');
this.recoverActive = false;
}
break;
} // switch eventName
if (this.handlers[eventName]) {
for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
var func = this.handlers[eventName][idx];
if (typeof(func) == 'function') {
// actual function reference
func(this, args);
} else if ((typeof(func) == 'object') && (func.length == 2)) {
// PHP style object + method, i.e. [myObject, 'myMethod']
func[0][func[1]](this, args);
} else if (typeof(func) == 'string') {
// name of function
window[func](this, args);
}
} // foreach event handler defined
} // user defined handler for event
}
};

31
src/case/zclip/zclip.js

@ -1,31 +0,0 @@
/**
* 复制
* Created by GUY on 2016/2/16.
* @class BI.ZeroClip
* @extends BI.BasicButton
*/
BI.ZeroClip = BI.inherit(BI.BasicButton, {
_defaultConfig: function () {
return BI.extend(BI.ZeroClip.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-zero-clip",
copy: BI.emptyFn,
beforeCopy: BI.emptyFn,
afterCopy: BI.emptyFn
})
},
_init: function () {
BI.ZeroClip.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.nextTick(function () {
self.element.zclip({
path: BI.resourceURL + "/ZeroClipboard.swf",
copy: o.copy,
beforeCopy: o.beforeCopy,
afterCopy: o.afterCopy
});
});
}
});
BI.shortcut("bi.zero_clip", BI.ZeroClip);

79
src/component/allvaluechooser/abstract.allvaluechooser.js

@ -0,0 +1,79 @@
/**
* 简单的复选下拉框控件, 适用于数据量少的情况 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AbstractAllValueChooser
* @extends BI.Widget
*/
BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), {
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
}
return text;
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, function (items) {
self.items = items;
call(items);
});
} else {
call(this.items);
}
function call(items) {
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.matched.concat(search.finded);
});
if (options.selectedValues) {//过滤
var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: items,
hasNext: false
});
}
}
});

62
src/component/allvaluechooser/combo.allvaluechooser.js

@ -4,13 +4,10 @@
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserCombo
* @extends BI.Widget
* @extends BI.AbstractAllValueChooser
*/
BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, {
_const: {
perPage: 10
},
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-combo",
@ -32,18 +29,7 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
}
return text;
},
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
@ -53,48 +39,6 @@ BI.AllValueChooserCombo = BI.inherit(BI.Widget, {
});
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, function (items) {
self.items = items;
call(items);
});
} else {
call(this.items);
}
function call(items) {
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.matched.concat(search.finded);
});
if (options.selectedValues) {//过滤
var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: items,
hasNext: false
});
}
},
setValue: function (v) {
this.combo.setValue({
type: BI.Selection.Multi,

62
src/component/allvaluechooser/pane.allvaluechooser.js

@ -0,0 +1,62 @@
/**
* 简单的复选下拉框控件, 适用于数据量少的情况 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AllValueChooserPane
* @extends BI.AbstractAllValueChooser
*/
BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-all-value-chooser-pane",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.AllValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.list = BI.createWidget({
type: 'bi.multi_select_list',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE);
});
},
setValue: function (v) {
this.list.setValue({
type: BI.Selection.Multi,
value: v || []
});
},
getValue: function () {
var val = this.list.getValue() || {};
if (val.type === BI.Selection.All) {
return val.assist;
}
return val.value || [];
},
populate: function () {
this.list.populate.apply(this.list, arguments);
}
});
BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);

548
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -0,0 +1,548 @@
BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), {
items: null,
itemsCreator: BI.emptyFn
});
},
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!this.items) {
o.itemsCreator({}, function (items) {
self._initData(items);
call();
});
} else {
call();
}
function call() {
switch (options.type) {
case BI.TreeView.REQ_TYPE_INIT_DATA:
self._reqInitTreeNode(options, callback);
break;
case BI.TreeView.REQ_TYPE_ADJUST_DATA:
self._reqAdjustTreeNode(options, callback);
break;
case BI.TreeView.REQ_TYPE_SELECT_DATA:
self._reqSelectedTreeNode(options, callback);
break;
case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
self._reqDisplayTreeNode(options, callback);
break;
default :
self._reqTreeNode(options, callback);
break;
}
}
},
_reqDisplayTreeNode: function (op, callback) {
var self = this;
var result = [];
var selectedValues = op.selectedValues;
if (selectedValues == null || BI.isEmpty(selectedValues)) {
callback({});
return;
}
doCheck([], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(parentValues, node, selected) {
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(newParents, node, selected[k]);
})
}
function getCount(jo, parentValues) {
if (jo == null) {
return 0;
}
if (BI.isEmpty(jo)) {
return self._getChildCount(parentValues);
}
return BI.size(jo);
}
function createOneJson(node, pId, llen) {
result.push({
id: node.id,
pId: pId,
text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
value: node.value,
open: true
});
}
},
_reqSelectedTreeNode: function (op, callback) {
var self = this;
var selectedValues = op.selectedValues;
var notSelectedValue = op.notSelectedValue || {};
var keyword = op.keyword || "";
var parentValues = op.parentValues || [];
if (selectedValues == null || BI.isEmpty(selectedValues)) {
callback({});
return;
}
dealWithSelectedValues(selectedValues);
callback(selectedValues);
function dealWithSelectedValues(selectedValues) {
var p = BI.clone(parentValues);
p.push(notSelectedValue);
if (isChild(selectedValues, p)) {
var result = [];
var finded = search(parentValues.length + 1, parentValues, notSelectedValue, result);
if (finded === true) {
var next = selectedValues;
BI.each(p, function (i, v) {
var t = next[v];
if (t == null) {
if (BI.isEmpty(next)) {
var split = p.slice(0, i);
var expanded = self._getChildren(split);
BI.each(expanded, function (m, child) {
if (i === p.length - 1 && child.value === notSelectedValue) {
return true;
}
next[child.value] = {};
});
next = next[v];
} else {
next = {};
next[v] = {};
}
} else {
next = t;
}
});
if (result.length > 0) {
BI.each(result, function (i, strs) {
self._buildTree(selectedValues, strs);
})
}
}
}
}
function search(deep, parents, current, result) {
var newParents = BI.clone(parents);
newParents.push(current);
if (self._isMatch(current, keyword)) {
return true;
}
var children = self._getChildren(newParents);
var notSearch = [];
var can = false;
BI.each(children, function (i, child) {
if (search(deep + 1, newParents, child.value, result)) {
can = true;
} else {
notSearch.push(child.value);
}
});
if (can === true) {
BI.each(notSearch, function (i, v) {
var next = BI.clone(newParents);
next.push(v);
result.push(next);
});
}
return can;
}
function isChild(selectedValues, parents) {
var t = selectedValues;
for (var i = 0; i < parents.length; i++) {
var v = parents[i];
if (!BI.has(t, v)) {
return false;
}
t = t[v];
if (t == null || BI.isEmpty(t)) {
return true;
}
}
return true;
}
},
_reqAdjustTreeNode: function (op, callback) {
var self = this;
var result = [];
var selectedValues = op.selectedValues;
if (selectedValues == null || BI.isEmpty(selectedValues)) {
callback({});
return;
}
BI.each(selectedValues, function (k, v) {
result.push([k]);
});
dealWithSelectedValues(selectedValues, []);
var jo = {};
BI.each(result, function (i, strs) {
self._buildTree(jo, strs);
});
callback(jo);
function dealWithSelectedValues(selected, parents) {
if (selected == null || BI.isEmpty(selected)) {
return true;
}
var can = true;
BI.each(selected, function (k, v) {
var p = BI.clone(parents);
p.push(k);
if (!dealWithSelectedValues(selected[k], p)) {
BI.each(selected[k], function (nk, nv) {
var t = BI.clone(p);
t.push(nk);
result.push(t);
});
can = false;
}
});
return can && isAllSelected(selected, parents);
}
function isAllSelected(selected, parents) {
return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
}
},
_reqInitTreeNode: function (op, callback) {
var self = this;
var result = [];
var keyword = op.keyword || "";
var selectedValues = op.selectedValues;
var lastSearchValue = op.lastSearchValue || "";
var output = search();
BI.nextTick(function () {
callback({
hasNext: output.length > self._const.perPage,
items: result,
lastSearchValue: BI.last(output)
})
});
function search() {
var children = self._getChildren([]);
var start = children.length;
if (lastSearchValue !== "") {
for (var j = 0, len = start; j < len; j++) {
if (children[j].value === lastSearchValue) {
start = j + 1;
break;
}
}
} else {
start = 0;
}
var output = [];
for (var i = start, len = children.length; i < len; i++) {
if (output.length < self._const.perPage) {
var find = nodeSearch(1, [], children[i].value, false, result);
} else if (output.length === self._const.perPage) {
var find = nodeSearch(1, [], children[i].value, false, []);
}
if (find[0] === true) {
output.push(children[i].value);
}
if (output.length > self._const.perPage) {
break;
}
}
return output;
}
function nodeSearch(deep, parentValues, current, isAllSelect, result) {
if (self._isMatch(current, keyword)) {
var checked = isAllSelect || isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
var can = false, checked = false;
var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
BI.each(children, function (i, child) {
var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
if (state[1] === true) {
checked = true;
}
if (state[0] === true) {
can = true;
}
});
if (can === true) {
checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
createOneJson(parentValues, current, true, checked, false, false, result);
}
return [can, checked];
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self._getNode(parentValues, value)
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: node.getChildrenLength() > 0,
open: isOpen,
checked: checked,
halfCheck: half,
flag: flag
});
}
function isHalf(parentValues, value) {
var find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
return BI.any(find, function (v, ob) {
if (v === value) {
if (ob != null && !BI.isEmpty(ob)) {
return true;
}
}
});
}
function isAllSelected(parentValues, value) {
var find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
return BI.any(find, function (v, ob) {
if (v === value) {
if (ob != null && BI.isEmpty(ob)) {
return true;
}
}
});
}
function isSelected(parentValues, value) {
var find = findSelectedObj(parentValues);
if (find == null) {
return false;
}
return BI.any(find, function (v) {
if (v === value) {
return true;
}
});
}
function findSelectedObj(parentValues) {
var find = selectedValues;
if (find == null) {
return null;
}
BI.every(parentValues, function (i, v) {
find = find[v];
if (find == null) {
return false;
}
return true;
});
return find;
}
},
_reqTreeNode: function (op, callback) {
var self = this;
var result = [];
var times = op.times;
var checkState = op.checkState || {};
var parentValues = op.parentValues || [];
var selectedValues = op.selectedValues;
var valueMap = {};
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);
result.push({
id: nodes[i].id,
pId: nodes[i].pId,
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: nodes[i].getChildrenLength() > 0,
checked: state[0],
halfCheck: state[1]
})
}
BI.nextTick(function () {
callback({
items: result,
hasNext: nodes.length > times * self._const.perPage
});
});
function judgeState(parentValues, selected_value, checkState) {
var checked = checkState.checked, half = checkState.half;
if (parentValues.length > 0 && !checked) {
return false;
}
return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
}
function dealWidthSelectedValue(parentValues, selectedValues) {
var valueMap = {};
BI.each(parentValues, function (i, v) {
selectedValues = selectedValues[v];
});
BI.each(selectedValues, function (value, obj) {
if (BI.isNull(obj)) {
valueMap[value] = [0, 0];
return;
}
if (BI.isEmpty(obj)) {
valueMap[value] = [2, 0];
return;
}
var nextNames = {};
BI.each(obj, function (t, o) {
if (BI.isNull(o) || BI.isEmpty(o)) {
nextNames[t] = true;
}
});
valueMap[value] = [1, BI.size(nextNames)];
});
return valueMap;
}
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
tempCheck = true;
}
}
var check;
if (!checked && !halfCheck && !tempCheck) {
check = BI.has(valueMap, current);
} else {
check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
}
return [check, halfCheck];
}
},
_buildTree: function (jo, values) {
var t = jo;
BI.each(values, function (i, v) {
if (!BI.has(t, v)) {
t[v] = {};
}
t = t[v];
});
},
_isMatch: function (value, keyword) {
var finded = BI.Func.getSearchResult([value], keyword);
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (parentValues, v) {
var self = this;
var findedParentNode;
var index = 0;
this.tree.traverse(function (node) {
if (self.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
return false;
}
if (index === parentValues.length && node.value === v) {
findedParentNode = node;
return false;
}
if (node.value === parentValues[index]) {
index++;
return;
}
return true;
});
return findedParentNode;
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
var parent = this.tree.getRoot();
}
return parent.getChildren();
},
_getChildCount: function (parentValues) {
return this._getChildren(parentValues).length;
}
});

550
src/component/treevaluechooser/combo.treevaluechooser.js

@ -5,11 +5,7 @@
* @class BI.TreeValueChooserCombo
* @extends BI.Widget
*/
BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
_const: {
perPage: 10
},
BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
@ -40,548 +36,6 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
});
},
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.transformToTreeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
this._initMap();
this._initFloors();
},
_initMap: function () {
var map = this.map = {};
BI.each(this.items, function (i, item) {
map[item.value] = item;
});
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!this.items) {
o.itemsCreator({}, function (items) {
self._initData(items);
call();
});
} else {
call();
}
function call() {
switch (options.type) {
case BI.TreeView.REQ_TYPE_INIT_DATA:
self._reqInitTreeNode(options, callback);
break;
case BI.TreeView.REQ_TYPE_ADJUST_DATA:
self._reqAdjustTreeNode(options, callback);
break;
case BI.TreeView.REQ_TYPE_SELECT_DATA:
self._reqSelectedTreeNode(options, callback);
break;
case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA:
self._reqDisplayTreeNode(options, callback);
break;
default :
self._reqTreeNode(options, callback);
break;
}
}
},
_reqDisplayTreeNode: function (op, callback) {
var self = this;
var result = [];
var selectedValues = op.selectedValues;
if (selectedValues == null || BI.isEmpty(selectedValues)) {
callback({});
return;
}
doCheck(0, [], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(floor, parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]);
})
}
function getCount(jo, parentValues) {
if (jo == null) {
return 0;
}
if (BI.isEmpty(jo)) {
return self._getChildCount(parentValues);
}
return BI.size(jo);
}
function createOneJson(node, pId, llen) {
result.push({
id: node.id,
pId: pId,
text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""),
value: node.value,
open: true
});
}
},
_reqSelectedTreeNode: function (op, callback) {
var self = this;
var selectedValues = op.selectedValues;
var notSelectedValue = op.notSelectedValue || {};
var keyword = op.keyword || "";
var parentValues = op.parentValues || [];
if (selectedValues == null || BI.isEmpty(selectedValues)) {
callback({});
return;
}
dealWithSelectedValues(selectedValues);
callback(selectedValues);
function dealWithSelectedValues(selectedValues) {
var p = BI.clone(parentValues);
p.push(notSelectedValue);
if (isChild(selectedValues, p)) {
var result = [];
var finded = search(parentValues.length + 1, parentValues, notSelectedValue, result);
if (finded === true) {
var next = selectedValues;
BI.each(p, function (i, v) {
var t = next[v];
if (t == null) {
if (BI.isEmpty(next)) {
var split = p.slice(0, i);
var expanded = self._getChildren(split);
BI.each(expanded, function (m, child) {
if (i === p.length - 1 && child.value === notSelectedValue) {
return true;
}
next[child.value] = {};
});
next = next[v];
} else {
next = {};
next[v] = {};
}
} else {
next = t;
}
});
if (result.length > 0) {
BI.each(result, function (i, strs) {
self._buildTree(selectedValues, strs);
})
}
}
}
}
function search(deep, parents, current, result) {
var newParents = BI.clone(parents);
newParents.push(current);
if (self._isMatch(current, keyword)) {
return true;
}
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents);
var notSearch = [];
var can = false;
BI.each(children, function (i, child) {
if (search(deep + 1, newParents, child.value, result)) {
can = true;
} else {
notSearch.push(child.value);
}
});
if (can === true) {
BI.each(notSearch, function (i, v) {
var next = BI.clone(newParents);
next.push(v);
result.push(next);
});
}
return can;
}
function isChild(selectedValues, parents) {
var t = selectedValues;
for (var i = 0; i < parents.length; i++) {
var v = parents[i];
if (!BI.has(t, v)) {
return false;
}
t = t[v];
if (t == null || BI.isEmpty(t)) {
return true;
}
}
return true;
}
},
_reqAdjustTreeNode: function (op, callback) {
var self = this;
var result = [];
var selectedValues = op.selectedValues;
if (selectedValues == null || BI.isEmpty(selectedValues)) {
callback({});
return;
}
BI.each(selectedValues, function (k, v) {
result.push([k]);
});
dealWithSelectedValues(selectedValues, []);
var jo = {};
BI.each(result, function (i, strs) {
self._buildTree(jo, strs);
});
callback(jo);
function dealWithSelectedValues(selected, parents) {
if (selected == null || BI.isEmpty(selected)) {
return true;
}
var can = true;
BI.each(selected, function (k, v) {
var p = BI.clone(parents);
p.push(k);
if (!dealWithSelectedValues(selected[k], p)) {
BI.each(selected[k], function (nk, nv) {
var t = BI.clone(p);
t.push(nk);
result.push(t);
});
can = false;
}
});
return can && isAllSelected(selected, parents);
}
function isAllSelected(selected, parents) {
return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected);
}
},
_reqInitTreeNode: function (op, callback) {
var self = this;
var result = [];
var keyword = op.keyword || "";
var selectedValues = op.selectedValues;
var lastSearchValue = op.lastSearchValue || "";
var output = search();
BI.nextTick(function () {
callback({
hasNext: output.length > self._const.perPage,
items: result,
lastSearchValue: BI.last(output)
})
});
function search() {
var children = self._getChildren([]);
var start = children.length;
if (lastSearchValue !== "") {
for (var j = 0, len = start; j < len; j++) {
if (children[j].value === lastSearchValue) {
start = j + 1;
break;
}
}
} else {
start = 0;
}
var output = [];
for (var i = start, len = children.length; i < len; i++) {
if (output.length < self._const.perPage) {
var find = nodeSearch(1, [], children[i].value, false, result);
} else if (output.length === self._const.perPage) {
var find = nodeSearch(1, [], children[i].value, false, []);
}
if (find[0] === true) {
output.push(children[i].value);
}
if (output.length > self._const.perPage) {
break;
}
}
return output;
}
function nodeSearch(deep, parentValues, current, isAllSelect, result) {
if (self._isMatch(current, keyword)) {
var checked = isAllSelect || isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
var can = false, checked = false;
var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current);
BI.each(children, function (i, child) {
var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result);
if (state[1] === true) {
checked = true;
}
if (state[0] === true) {
can = true;
}
});
if (can === true) {
checked = isCurAllSelected || (isSelected(parentValues, current) && checked);
createOneJson(parentValues, current, true, checked, false, false, result);
}
return [can, checked];
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self.map[value];
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: parentValues.length + 1 < self.floors,
open: isOpen,
checked: checked,
halfCheck: half,
flag: flag
});
}
function isHalf(parentValues, value) {
var find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
return BI.any(find, function (v, ob) {
if (v === value) {
if (ob != null && !BI.isEmpty(ob)) {
return true;
}
}
});
}
function isAllSelected(parentValues, value) {
var find = findSelectedObj(parentValues);
if (find == null) {
return null;
}
return BI.any(find, function (v, ob) {
if (v === value) {
if (ob != null && BI.isEmpty(ob)) {
return true;
}
}
});
}
function isSelected(parentValues, value) {
var find = findSelectedObj(parentValues);
if (find == null) {
return false;
}
return BI.any(find, function (v) {
if (v === value) {
return true;
}
});
}
function findSelectedObj(parentValues) {
var find = selectedValues;
if (find == null) {
return null;
}
BI.every(parentValues, function (i, v) {
find = find[v];
if (find == null) {
return false;
}
return true;
});
return find;
}
},
_reqTreeNode: function (op, callback) {
var self = this;
var result = [];
var times = op.times;
var checkState = op.checkState || {};
var parentValues = op.parentValues || [];
var selectedValues = op.selectedValues;
var valueMap = {};
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);
result.push({
id: nodes[i].id,
pId: nodes[i].pId,
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: parentValues.length + 1 < this.floors,
checked: state[0],
halfCheck: state[1]
})
}
BI.nextTick(function () {
callback({
items: result,
hasNext: nodes.length > times * self._const.perPage
});
});
function judgeState(parentValues, selected_value, checkState) {
var checked = checkState.checked, half = checkState.half;
if (parentValues.length > 0 && !checked) {
return false;
}
return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
}
function dealWidthSelectedValue(parentValues, selectedValues) {
var valueMap = {};
BI.each(parentValues, function (i, v) {
selectedValues = selectedValues[v];
});
BI.each(selectedValues, function (value, obj) {
if (BI.isNull(obj)) {
valueMap[value] = [0, 0];
return;
}
if (BI.isEmpty(obj)) {
valueMap[value] = [2, 0];
return;
}
var nextNames = {};
BI.each(obj, function (t, o) {
if (BI.isNull(o) || BI.isEmpty(o)) {
nextNames[t] = true;
}
});
valueMap[value] = [1, BI.size(nextNames)];
});
return valueMap;
}
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
tempCheck = true;
}
}
var check;
if (!checked && !halfCheck && !tempCheck) {
check = BI.has(valueMap, current);
} else {
check = ((tempCheck || checked) && !half) || BI.has(valueMap, current);
}
return [check, halfCheck];
}
},
_buildTree: function (jo, values) {
var t = jo;
BI.each(values, function (i, v) {
if (!BI.has(t, v)) {
t[v] = {};
}
t = t[v];
});
},
_isMatch: function (value, keyword) {
var finded = BI.Func.getSearchResult([value], keyword);
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (v) {
return this.tree.search(v, "value");
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this.tree.search(value, "value");
} else {
var parent = this.tree.getRoot();
}
return parent.getChildren();
},
_getChildCount: function (parentValues) {
return this._getChildren(parentValues).length;
},
setValue: function (v) {
this.combo.setValue(v);
},
@ -591,7 +45,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.Widget, {
},
populate: function () {
this.combo.populate.apply(this, arguments);
this.combo.populate.apply(this.combo, arguments);
}
});
BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM";

49
src/component/treevaluechooser/pane.treevaluechooser.js

@ -0,0 +1,49 @@
/**
* 简单的复选下拉树控件, 适用于数据量少的情况
*
* Created by GUY on 2015/10/29.
* @class BI.TreeValueChooserPane
* @extends BI.AbstractTreeValueChooser
*/
BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-value-chooser-pane",
items: null,
itemsCreator: BI.emptyFn
});
},
_init: function () {
BI.TreeValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.pane = BI.createWidget({
type: 'bi.multi_select_tree',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this)
});
this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () {
self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE);
});
if (BI.isNotNull(o.items)) {
this._initData(o.items);
this.populate();
}
},
setValue: function (v) {
this.pane.setValue(v);
},
getValue: function () {
return this.pane.getValue();
},
populate: function () {
this.pane.populate.apply(this.pane, arguments);
}
});
BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.tree_value_chooser_pane', BI.TreeValueChooserPane);

89
src/component/valuechooser/abstract.valuechooser.js

@ -0,0 +1,89 @@
/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.AbstractValueChooser
* @extends BI.Widget
*/
BI.AbstractValueChooser = BI.inherit(BI.Widget, {
_const: {
perPage: 100
},
_defaultConfig: function () {
return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), {
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
}
return text;
},
_getItemsByTimes: function (items, times) {
var res = [];
for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]);
}
return res;
},
_hasNextByTimes: function (items, times) {
return times * this._const.perPage < items.length;
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, function (items) {
self.items = items;
call(items);
});
} else {
call(this.items);
}
function call(items) {
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.matched.concat(search.finded);
});
if (options.selectedValues) {//过滤
var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: self._getItemsByTimes(items, options.times),
hasNext: self._hasNextByTimes(items, options.times)
});
}
}
});

72
src/component/valuechooser/combo.valuechooser.js

@ -6,11 +6,8 @@
* @class BI.ValueChooserCombo
* @extends BI.Widget
*/
BI.ValueChooserCombo = BI.inherit(BI.Widget, {
BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, {
_const: {
perPage: 10
},
_defaultConfig: function () {
return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-combo",
@ -32,18 +29,7 @@ BI.ValueChooserCombo = BI.inherit(BI.Widget, {
type: 'bi.multi_select_combo',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(self.items)) {
BI.some(self.items, function (i, item) {
if (item.value === v) {
text = item.text;
return true;
}
});
}
return text;
},
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height
});
@ -53,60 +39,6 @@ BI.ValueChooserCombo = BI.inherit(BI.Widget, {
});
},
_getItemsByTimes: function (items, times) {
var res = [];
for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) {
res.push(items[i]);
}
return res;
},
_hasNextByTimes: function (items, times) {
return times * this._const.perPage < items.length;
},
_itemsCreator: function (options, callback) {
var self = this, o = this.options;
if (!o.cache || !this.items) {
o.itemsCreator({}, function (items) {
self.items = items;
call(items);
});
} else {
call(this.items);
}
function call(items) {
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.matched.concat(search.finded);
});
if (options.selectedValues) {//过滤
var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: self._getItemsByTimes(items, options.times),
hasNext: self._hasNextByTimes(items, options.times)
});
}
},
setValue: function (v) {
this.combo.setValue(v);
},

56
src/component/valuechooser/pane.valuechooser.js

@ -0,0 +1,56 @@
/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*
* Created by GUY on 2015/10/29.
* @class BI.ValueChooserPane
* @extends BI.Widget
*/
BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-pane",
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.list = BI.createWidget({
type: 'bi.multi_select_list',
element: this,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this)
});
this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () {
self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE);
});
if (BI.isNotNull(o.items)) {
this.items = o.items;
this.populate();
}
},
setValue: function (v) {
this.list.setValue(v);
},
getValue: function () {
var val = this.list.getValue() || {};
return {
type: val.type,
value: val.value
}
},
populate: function () {
this.list.populate.apply(this.list, arguments);
}
});
BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut('bi.value_chooser_pane', BI.ValueChooserPane);

16
src/core/base.js

@ -457,15 +457,15 @@ if (!window.BI) {
},
has: function (obj, keys) {
if (BI.isKey(keys)) {
return _.has.apply(_, arguments);
}
if (!keys || BI.isEmpty(keys)) {
return false;
if (BI.isArray(keys)) {
if (keys.length === 0) {
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key

3
src/core/controller/controller.floatbox.js

@ -47,7 +47,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
}
this.floatContainer[name] = BI.createWidget({
type: "bi.absolute",
cls: "bi-list-view",
cls: "bi-popup-view",
items: [{
el: (this.floatLayer[name] = BI.createWidget({
type: 'bi.absolute',
@ -137,6 +137,7 @@ BI.FloatBoxController = BI.inherit(BI.Controller, {
delete this.floatLayer[name];
delete this.zindexMap[name];
delete this.floatContainer[name];
delete this.floatOpened[name];
return this;
}
});

2
src/core/controller/controller.layer.js

@ -93,7 +93,7 @@ BI.LayerController = BI.inherit(BI.Controller, {
}]
});
if (w) {
layout.element.addClass("bi-list-view");
layout.element.addClass("bi-popup-view");
layout.element.css({
left: w.offset().left + (offset.left || 0),
top: w.offset().top + (offset.top || 0),

95
src/core/proto/jquery.js vendored

@ -6,56 +6,61 @@
* All rights reserved.
*/
if (jQuery) {
(function($){
(function ($) {
// richer:容器在其各个边缘留出的空间
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
if (!$.fn.insets) {
$.fn.insets = function () {
var p = this.padding(),
b = this.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
};
};
};
}
// richer:获取 && 设置jQuery元素的边界
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds : true};
if (!$.fn.bounds) {
$.fn.bounds = function (value) {
var tmp = {hasIgnoredBounds: true};
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0;
if (value) {
if (!isNaN(value.x)) {
tmp.left = value.x;
}
if (!isNaN(value.y)) {
tmp.top = value.y;
}
if (value.width != null) {
tmp.width = (value.width - (this.outerWidth(true) - this.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : value.width;
// fix chrome
//tmp.width = (tmp.width >= 0) ? tmp.width : 0;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
}
this.css(tmp);
return this;
}
if (value.height != null) {
tmp.height = value.height - (this.outerHeight(true) - this.height());
tmp.height = (tmp.height >= 0) ? tmp.height : value.height;
// fix chrome
//tmp.height = (tmp.height >= 0) ? tmp.height : value.0;
else {
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
'x': tmp.left,
'y': tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(),
'height': this.outerHeight()
};
}
this.css(tmp);
return this;
}
else {
// richer:注意此方法只对可见元素有效
tmp = this.position();
return {
'x': tmp.left,
'y': tmp.top,
// richer:这里计算外部宽度和高度的时候,都不包括边框
'width': this.outerWidth(),
'height': this.outerHeight()
};
}
};
};
}
})(jQuery);
};
}
;

2
src/core/proto/number.js

@ -259,7 +259,7 @@ function accDiv(arg1, arg2) {
with (Math) {
r1 = Number(arg1.toString().replace(".", ""));
r2 = Number(arg2.toString().replace(".", ""));
return (r1 / r2) * pow(10, t2 - t1);
return (t2 > t1) ? (r1 / r2) * pow(10, t2 - t1) : (r1 / r2) / pow(10, t1 - t2);
}
}

2
src/core/utils/prefixIntervalTree.js

@ -170,7 +170,7 @@
return new BI.PrefixIntervalTree(xs);
};
BI.PrefixIntervalTree.empty = function () {
BI.PrefixIntervalTree.empty = function (size) {
return BI.PrefixIntervalTree.uniform(size, 0);
};

51
src/core/utils/tree.js

@ -17,7 +17,7 @@
},
isRoot: function (node) {
return node === this.root || node.id === this.root.id;
return node === this.root;
},
getRoot: function () {
@ -394,7 +394,7 @@
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = BI.clone(nodes[i]);
node.pId = pId;
node.pId = node.pId == null ? pId : node.pId;
delete node.children;
r.push(node);
if (nodes[i]["children"]) {
@ -403,7 +403,7 @@
}
} else {
var newNodes = BI.clone(nodes);
newNodes.pId = pId;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
delete newNodes.children;
r.push(newNodes);
if (nodes["children"]) {
@ -414,21 +414,25 @@
},
arrayFormat: function (nodes, pId) {
if (!nodes) return [];
if (!nodes) {
return [];
}
var r = [];
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
node.pId = node.pId == null ? pId : node.pId;
r.push(node);
if (nodes[i]["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
}
}
} else {
var newNodes = nodes;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
r.push(newNodes);
if (nodes["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
}
}
return r;
@ -444,13 +448,13 @@
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if(BI.isNull(sNodes[i].id)) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
@ -466,6 +470,37 @@
}
},
treeFormat: function (sNodes) {
var i, l;
if (!sNodes) {
return [];
}
if (BI.isArray(sNodes)) {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = sNodes[i];
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
} else {
r.push(tmpMap[sNodes[i].id]);
}
}
return r;
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;

11
src/core/widget.js

@ -45,9 +45,10 @@ BI.Widget = BI.inherit(BI.OB, {
this._initRoot();
this._initElementWidth();
this._initElementHeight();
this._initVisualEffects();
this._initVisual();
this._initState();
this._initElement();
this._initEffects();
this.created && this.created();
},
@ -102,21 +103,23 @@ BI.Widget = BI.inherit(BI.OB, {
}
},
_initVisualEffects: function () {
_initVisual: function () {
var o = this.options;
if (o.invisible) {
//用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none");
}
},
_initEffects: function () {
var o = this.options;
if (o.disabled || o.invalid) {
// BI.nextTick(BI.bind(function () {
if (this.options.disabled) {
this.setEnable(false);
}
if (this.options.invalid) {
this.setValid(false);
}
// }, this));
}
},

14
src/css/base/view/popupview.css

@ -2,30 +2,30 @@
/****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/
/**********BI.BIListView*************/
.bi-list-view {
.bi-popup-view {
position: fixed !important;
overflow-y: visible !important;
overflow-x: visible !important;
overflow: visible !important;
cursor: default;
}
.bi-list-view .list-view-outer {
.bi-popup-view .list-view-outer {
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
.bi-list-view .list-view-toolbar {
.bi-popup-view .list-view-toolbar {
line-height: 30px;
}
.bi-list-view .list-view-toolbar > .center-element {
.bi-popup-view .list-view-toolbar > .center-element {
border-left: 1px solid #d4dadd;
}
.bi-list-view .list-view-toolbar > .first-element {
.bi-popup-view .list-view-toolbar > .first-element {
border-left: none;
}
.bi-theme-dark .bi-list-view .list-view-toolbar > .center-element {
.bi-theme-dark .bi-popup-view .list-view-toolbar > .center-element {
border-left: 1px solid #525466;
}
.bi-theme-dark .bi-list-view .list-view-toolbar > .first-element {
.bi-theme-dark .bi-popup-view .list-view-toolbar > .first-element {
border-left: none;
}

4
src/less/base/view/popupview.less

@ -1,7 +1,7 @@
@import "../../bibase";
/**********BI.BIListView*************/
.bi-list-view {
.bi-popup-view {
position: fixed !important;
overflow-y: visible !important;
overflow-x: visible !important;
@ -22,7 +22,7 @@
}
.bi-theme-dark {
.bi-list-view {
.bi-popup-view {
& .list-view-toolbar {
& > .center-element {
border-left: 1px solid @color-bi-border-line-theme-dark;

13
src/widget/multiselectlist/multiselectlist.js

@ -6,8 +6,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
el: {}
valueFormatter: BI.emptyFn
})
},
_init: function () {
@ -18,6 +17,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -77,6 +77,8 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
@ -88,7 +90,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
@ -108,13 +109,11 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
}
@ -140,8 +139,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 30
@ -153,8 +150,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,

16
src/widget/multiselecttree/multiselecttree.js

@ -5,8 +5,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-select-tree',
itemsCreator: BI.emptyFn,
height: 25
itemsCreator: BI.emptyFn
})
},
@ -52,7 +51,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
@ -92,8 +90,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.vtape",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.trigger,
height: 30
@ -105,8 +101,6 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
@ -142,6 +136,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
});
},
stopSearch: function () {
this.trigger.stopSearch();
},
updateValue: function (v) {
this.adapter.updateValue(v);
},
getValue: function () {
return this.storeValue.value;
},

6
src/widget/multiselecttree/multiselecttree.popup.js

@ -13,7 +13,6 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.async_tree",
height: 400,
element: this,
itemsCreator: o.itemsCreator
});
@ -38,6 +37,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
this.popup.setValue(v.value);
},
updateValue: function (v) {
this.popup.updateValue(v);
this.popup.refresh();
},
populate: function (config) {
this.popup.stroke(config);
}

4
src/widget/sequencetable/treenumber.sequencetable.js

@ -79,7 +79,9 @@ BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, {
var cnt = this.start;
function track(node) {
self.cache[node.text || node.value] = cnt++;
//如果已经有缓存了就不改计数了,复杂表会出现这种情况
self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt);
cnt++;
}
BI.each(nodes, function (i, node) {

Loading…
Cancel
Save