diff --git a/Gruntfile.js b/Gruntfile.js index ce4ad486c3..1f1f46d42a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -49,7 +49,7 @@ module.exports = function (grunt) { 'src/base/combination/tree.button.js', 'src/base/combination/map.button.js', 'src/base/tree/treeview.js', - 'src/base/tree/synctree.js', + 'src/base/tree/asynctree.js', 'src/base/tree/parttree.js', 'src/base/**/*.js' ], @@ -162,7 +162,7 @@ module.exports = function (grunt) { 'src/base/combination/tree.button.js', 'src/base/combination/map.button.js', 'src/base/tree/treeview.js', - 'src/base/tree/synctree.js', + 'src/base/tree/asynctree.js', 'src/base/tree/parttree.js', 'src/base/**/*.js' ], diff --git a/bi/base.js b/bi/base.js index 005c9fea96..165a9b0259 100644 --- a/bi/base.js +++ b/bi/base.js @@ -781,7 +781,7 @@ BI.BasicButton = BI.inherit(BI.Single, { }); //之后的300ms点击无效 - var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true); + var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, true); function ev(e) { if (o.stopEvent) { @@ -803,6 +803,11 @@ BI.BasicButton = BI.inherit(BI.Single, { _trigger: function () { var o = this.options; + if (!this.isDisableSelected()) { + this.isForceSelected() ? this.setSelected(true) : + (this.isForceNotSelected() ? this.setSelected(false) : + this.setSelected(!this.isSelected())); + } if (this.isValid()) { o.handler.call(this, this.getValue(), this); var v = this.getValue(); @@ -811,13 +816,15 @@ BI.BasicButton = BI.inherit(BI.Single, { } }, - doClick: function () { - if (!this.isDisableSelected()) { - this.isForceSelected() ? this.setSelected(true) : - (this.isForceNotSelected() ? this.setSelected(false) : - this.setSelected(!this.isSelected())); - } + _doClick: function () { this._trigger(); + if (this.isValid()) { + this.doClick(); + } + }, + + doClick: function () { + }, handle: function () { @@ -1956,6 +1963,12 @@ BI.TreeView = BI.inherit(BI.Pane, { }); }, + getExpandedValue: function(){ + if (!this.nodes) { + return null; + } + }, + refresh: function () { this.nodes && this.nodes.refresh(); }, @@ -1991,15 +2004,15 @@ BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT; BI.shortcut("bi.tree_view", BI.TreeView);/** * guy * 同步树 - * @class BI.SyncTree + * @class BI.AsyncTree * @extends BI.TreeView */ -BI.SyncTree = BI.inherit(BI.TreeView, { +BI.AsyncTree = BI.inherit(BI.TreeView, { _defaultConfig: function () { - return BI.extend(BI.SyncTree.superclass._defaultConfig.apply(this, arguments), {}) + return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {}) }, _init: function () { - BI.SyncTree.superclass._init.apply(this, arguments); + BI.AsyncTree.superclass._init.apply(this, arguments); }, //配置属性 @@ -2069,7 +2082,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } function beforeExpand(treeId, treeNode) { - self._expandNode(treeId, treeNode); + self._beforeExpandNode(treeId, treeNode); } function onCheck(event, treeId, treeNode) { @@ -2090,7 +2103,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { _selectTreeNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); - var name = this._getNodeValue(treeNode) + var name = this._getNodeValue(treeNode); // var values = parentValues.concat([name]); if (treeNode.checked === true) { } else { @@ -2109,11 +2122,11 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } } } - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }, //展开节点 - _expandNode: function (treeId, treeNode) { + _beforeExpandNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var op = BI.extend({}, o.paras, { @@ -2168,7 +2181,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { }, hasChecked: function () { - return !BI.isEmpty(this.selectedValues) || BI.SyncTree.superclass.hasChecked.apply(this, arguments); + return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments); }, getValue: function () { @@ -2196,13 +2209,13 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } }); -BI.shortcut("bi.sync_tree", BI.SyncTree);/** +BI.shortcut("bi.async_tree", BI.AsyncTree);/** * guy * 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点 * @class BI.PartTree - * @extends BI.SyncTree + * @extends BI.AsyncTree */ -BI.PartTree = BI.inherit(BI.SyncTree, { +BI.PartTree = BI.inherit(BI.AsyncTree, { _defaultConfig: function () { return BI.extend(BI.PartTree.superclass._defaultConfig.apply(this, arguments), {}) }, @@ -2241,7 +2254,7 @@ BI.PartTree = BI.inherit(BI.SyncTree, { var name = this._getNodeValue(treeNode) // var values = parentValues.concat([name]); if (treeNode.checked === true) { - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA, @@ -2266,7 +2279,7 @@ BI.PartTree = BI.inherit(BI.SyncTree, { } } self.selectedValues = new_values; - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); } }, @@ -2777,6 +2790,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { _populate: function (items) { var o = this.options; + this._reRange(); if (items && items !== this.options.items) { this.options.items = items; this._calculateSizeAndPositionData(); @@ -2850,7 +2864,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { }, //重新计算children - reRange: function () { + _reRange: function () { this.renderRange = {}; }, @@ -14873,6 +14887,7 @@ BI.GridView = BI.inherit(BI.Widget, { _populate: function (items) { var self = this, o = this.options; + this._reRange(); if (items && items !== this.options.items) { this.options.items = items; } @@ -14961,7 +14976,7 @@ BI.GridView = BI.inherit(BI.Widget, { }, //重新计算children - reRange: function () { + _reRange: function () { this.renderRange = {}; }, @@ -28993,7 +29008,6 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return; } if (this._isNeedDigest === true) { - this._reRange(); this._digest(); } this._isNeedDigest = false; @@ -29091,13 +29105,6 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.bottomRightCollection.restore(); }, - _reRange: function () { - this.topLeftCollection.reRange(); - this.topRightCollection.reRange(); - this.bottomLeftCollection.reRange(); - this.bottomRightCollection.reRange(); - }, - restore: function () { this._restore(); } @@ -29710,10 +29717,6 @@ BI.GridTable = BI.inherit(BI.Widget, { if (this._width <= 0 || this._height <= 0) { return; } - if (this._isNeedDigest === true) { - this._reRange(); - this._isNeedDigest = false; - } this._populateTable(); this._populateScrollbar(); }, @@ -29789,13 +29792,11 @@ BI.GridTable = BI.inherit(BI.Widget, { populate: function (items, header) { if (items && this.options.items !== items) { - this._isNeedDigest = true; this.options.items = items; this.items = this._getItems(); this._restore(); } if (header && this.options.header !== header) { - this._isNeedDigest = true; this.options.header = header; this.header = this._getHeader(); this._restore(); @@ -29810,13 +29811,6 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid.restore(); }, - _reRange: function () { - this.topLeftGrid.reRange(); - this.topRightGrid.reRange(); - this.bottomLeftGrid.reRange(); - this.bottomRightGrid.reRange(); - }, - restore: function () { this._restore(); } diff --git a/bi/case.js b/bi/case.js index 2fcf3869ee..2a7f667cdb 100644 --- a/bi/case.js +++ b/bi/case.js @@ -7951,6 +7951,10 @@ BI.AllCountPager = BI.inherit(BI.Widget, { this.pager.setValue(v); }, + setVPage: function (v) { + this.pager.setValue(v); + }, + setCount: function (count) { this.rowCount.setText(count); this.rowCount.setTitle(count); diff --git a/bi/polyfill.js b/bi/polyfill.js index 854ed288f6..f493c89a5e 100644 --- a/bi/polyfill.js +++ b/bi/polyfill.js @@ -4,7 +4,7 @@ if(![].indexOf){ * @param {Object} o 要检查的值 * @return {Number} o在数组中的索引(如果不在数组中则返回-1) */ - [].indexOf = function (o) { + Array.prototype.indexOf = function (o) { for (var i = 0, len = this.length; i < len; i++) { if (_.isEqual(o, this[i])) { return i; @@ -20,7 +20,7 @@ if(![].lastIndexOf){ * @param {Object} o 要检查的值 * @return {Number} o在数组中的索引(如果不在数组中则返回-1) */ - [].lastIndexOf = function (o) { + Array.prototype.lastIndexOf = function (o) { for (var len = this.length, i = len - 1; i >= 0; i--) { if (_.isEqual(o, this[i])) { return i; diff --git a/bi/widget.js b/bi/widget.js index 903504541b..55d86a401e 100644 --- a/bi/widget.js +++ b/bi/widget.js @@ -10957,17 +10957,17 @@ BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSe BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** * Created by zcf_1 on 2017/5/2. */ -BI.MultiStringList = BI.inherit(BI.Widget, { +BI.MultiSelectList = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.MultiStringList.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-string-list', + return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-list', itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, el: {} }) }, _init: function () { - BI.MultiStringList.superclass._init.apply(this, arguments); + BI.MultiSelectList.superclass._init.apply(this, arguments); var self = this, o = this.options; this.storeValue = {}; @@ -10978,7 +10978,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this.adapter = BI.createWidget({ type: "bi.multi_select_loader", - cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, // onLoaded: o.onLoaded, @@ -10990,7 +10990,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); }); }); @@ -11049,7 +11049,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { self._setStartValue(keyword); assertShowValue(); self._setStartValue(""); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); }) } else { self._showAdapter(); @@ -11150,7 +11150,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this._assertValue(this.storeValue); if (!this._allData) { o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_ALL_DATA + type: BI.MultiSelectList.REQ_GET_ALL_DATA }, function (ob) { self._allData = BI.pluck(ob.items, "value"); digest(self._allData); @@ -11174,7 +11174,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { var self = this, o = this.options; this._assertValue(res); o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_ALL_DATA, + type: BI.MultiSelectList.REQ_GET_ALL_DATA, keyword: self.trigger.getKeyword() }, function (ob) { var items = BI.pluck(ob.items, "value"); @@ -11211,7 +11211,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { var self = this, o = this.options; if (!this._count) { o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_DATA_LENGTH + type: BI.MultiSelectList.REQ_GET_DATA_LENGTH }, function (res) { self._count = res.count; adjust(); @@ -11294,13 +11294,214 @@ BI.MultiStringList = BI.inherit(BI.Widget, { } }); -BI.extend(BI.MultiStringList, { +BI.extend(BI.MultiSelectList, { REQ_GET_DATA_LENGTH: 0, REQ_GET_ALL_DATA: -1 }); -BI.MultiStringList.EVENT_CHANGE = "BI.MultiStringList.EVENT_CHANGE"; -BI.shortcut("bi.multi_string_list", BI.MultiStringList);/** +BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/** + * Created by zcf_1 on 2017/5/11. + */ +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 + }) + }, + + _init: function () { + BI.MultiSelectTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = {value: {}}; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_tree_popup", + itemsCreator: o.itemsCreator + }); + this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + }); + + this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.trigger.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self.storeValue = {value: self.adapter.getValue()}; + self.searcherPane.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + self.adapter.setValue(self.storeValue); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.trigger, + height: 30 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) + + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + resize: function () { + + }, + + setValue: function (v) { + this.storeValue.value = v || {}; + this.adapter.setValue({ + value: v || {} + }); + this.trigger.setValue({ + value: v || {} + }); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.trigger.populate.apply(this.trigger, arguments); + this.adapter.populate.apply(this.adapter, arguments); + } +}); +BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** + * Created by zcf on 2016/12/21. + */ +BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom", + itemsCreator: BI.emptyFn + }); + }, + _init: function () { + BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popup = BI.createWidget({ + type: "bi.async_tree", + height: 400, + element: this, + itemsCreator: o.itemsCreator + }); + this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { + self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) + }); + this.popup.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) + }); + }, + + hasChecked: function () { + return this.popup.hasChecked(); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + v || (v = {}); + this.popup.setValue(v.value); + }, + + populate: function (config) { + this.popup.stroke(config); + } + +}); +BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; +BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/** * * @class BI.MultiTreeCheckPane * @extends BI.Pane @@ -11695,7 +11896,7 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, { this.selectedValues = {}; this.tree = BI.createWidget({ - type: "bi.sync_tree", + type: "bi.async_tree", height: 400, cls:"popup-view-tree", itemsCreator: opts.itemsCreator, @@ -12039,208 +12240,7 @@ BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** - * Created by zcf_1 on 2017/5/11. - */ -BI.MultiSelectTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', - itemsCreator: BI.emptyFn, - height: 25 - }) - }, - - _init: function () { - BI.MultiSelectTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = {value: {}}; - - this.adapter = BI.createWidget({ - type: "bi.multi_select_tree_popup", - itemsCreator: o.itemsCreator - }); - this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { - if (self.trigger.isSearching()) { - self.storeValue = {value: self.searcherPane.getValue()}; - } else { - self.storeValue = {value: self.adapter.getValue()}; - } - self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); - }); - - this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 - type: "bi.multi_tree_search_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - keywordGetter: function () { - return self.trigger.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keyword = self.trigger.getKeyword(); - o.itemsCreator(op, callback); - } - }); - this.searcherPane.setVisible(false); - - this.trigger = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback({ - keyword: self.trigger.getKeyword() - }); - }, - adapter: this.adapter, - popup: this.searcherPane, - height: 200, - masker: false, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setValue(self.storeValue); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setValue(self.storeValue); - BI.nextTick(function () { - self.adapter.populate(); - }); - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function () { - if (self.trigger.isSearching()) { - self.storeValue = {value: self.searcherPane.getValue()}; - } else { - self.storeValue = {value: self.adapter.getValue()}; - } - self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - self._showAdapter(); - } - }] - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - height: "100%", - width: "100%", - items: [{ - el: this.trigger, - height: 30 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - height: "100%", - width: "100%", - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }) - - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - resize: function () { - - }, - - setValue: function (v) { - this.storeValue.value = v || {}; - this.adapter.setValue({ - value: v || {} - }); - this.trigger.setValue({ - value: v || {} - }); - }, - - getValue: function () { - return this.storeValue.value; - }, - - populate: function () { - this.trigger.populate.apply(this.trigger, arguments); - this.adapter.populate.apply(this.adapter, arguments); - } -}); -BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** - * Created by zcf on 2016/12/21. - */ -BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", - itemsCreator: BI.emptyFn - }); - }, - _init: function () { - BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.popup = BI.createWidget({ - type: "bi.sync_tree", - height: 400, - element: this, - itemsCreator: o.itemsCreator - }); - this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) - }); - this.popup.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) - }); - }, - - hasChecked: function () { - return this.popup.hasChecked(); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - v || (v = {}); - this.popup.setValue(v.value); - }, - - populate: function (config) { - this.popup.stroke(config); - } - -}); -BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; -BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1 +BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1 //closeMIn:最小值的符号,closeMax:最大值的符号 /** * Created by roy on 15/9/17. @@ -15964,6 +15964,7 @@ BI.SequenceTableListNumber = BI.inherit(BI.Widget, { }, setVPage: function (v) { + v = v < 1 ? 1 : v; var o = this.options; this.start = (v - 1) * o.pageSize + 1; }, diff --git a/demo/js/config/base.js b/demo/js/config/base.js index 54056d5479..f3c020ded3 100644 --- a/demo/js/config/base.js +++ b/demo/js/config/base.js @@ -76,7 +76,7 @@ Demo.BASE_CONFIG = [{ value: "demo.tree_view" }, { pId: 203, - text: "bi.sync_tree", + text: "bi.async_tree", value: "demo.sync_tree" }, { pId: 203, diff --git a/docs/base.js b/docs/base.js index 005c9fea96..165a9b0259 100644 --- a/docs/base.js +++ b/docs/base.js @@ -781,7 +781,7 @@ BI.BasicButton = BI.inherit(BI.Single, { }); //之后的300ms点击无效 - var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true); + var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, true); function ev(e) { if (o.stopEvent) { @@ -803,6 +803,11 @@ BI.BasicButton = BI.inherit(BI.Single, { _trigger: function () { var o = this.options; + if (!this.isDisableSelected()) { + this.isForceSelected() ? this.setSelected(true) : + (this.isForceNotSelected() ? this.setSelected(false) : + this.setSelected(!this.isSelected())); + } if (this.isValid()) { o.handler.call(this, this.getValue(), this); var v = this.getValue(); @@ -811,13 +816,15 @@ BI.BasicButton = BI.inherit(BI.Single, { } }, - doClick: function () { - if (!this.isDisableSelected()) { - this.isForceSelected() ? this.setSelected(true) : - (this.isForceNotSelected() ? this.setSelected(false) : - this.setSelected(!this.isSelected())); - } + _doClick: function () { this._trigger(); + if (this.isValid()) { + this.doClick(); + } + }, + + doClick: function () { + }, handle: function () { @@ -1956,6 +1963,12 @@ BI.TreeView = BI.inherit(BI.Pane, { }); }, + getExpandedValue: function(){ + if (!this.nodes) { + return null; + } + }, + refresh: function () { this.nodes && this.nodes.refresh(); }, @@ -1991,15 +2004,15 @@ BI.TreeView.EVENT_AFTERINIT = BI.Events.AFTERINIT; BI.shortcut("bi.tree_view", BI.TreeView);/** * guy * 同步树 - * @class BI.SyncTree + * @class BI.AsyncTree * @extends BI.TreeView */ -BI.SyncTree = BI.inherit(BI.TreeView, { +BI.AsyncTree = BI.inherit(BI.TreeView, { _defaultConfig: function () { - return BI.extend(BI.SyncTree.superclass._defaultConfig.apply(this, arguments), {}) + return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {}) }, _init: function () { - BI.SyncTree.superclass._init.apply(this, arguments); + BI.AsyncTree.superclass._init.apply(this, arguments); }, //配置属性 @@ -2069,7 +2082,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } function beforeExpand(treeId, treeNode) { - self._expandNode(treeId, treeNode); + self._beforeExpandNode(treeId, treeNode); } function onCheck(event, treeId, treeNode) { @@ -2090,7 +2103,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { _selectTreeNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); - var name = this._getNodeValue(treeNode) + var name = this._getNodeValue(treeNode); // var values = parentValues.concat([name]); if (treeNode.checked === true) { } else { @@ -2109,11 +2122,11 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } } } - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }, //展开节点 - _expandNode: function (treeId, treeNode) { + _beforeExpandNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var op = BI.extend({}, o.paras, { @@ -2168,7 +2181,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { }, hasChecked: function () { - return !BI.isEmpty(this.selectedValues) || BI.SyncTree.superclass.hasChecked.apply(this, arguments); + return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments); }, getValue: function () { @@ -2196,13 +2209,13 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } }); -BI.shortcut("bi.sync_tree", BI.SyncTree);/** +BI.shortcut("bi.async_tree", BI.AsyncTree);/** * guy * 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点 * @class BI.PartTree - * @extends BI.SyncTree + * @extends BI.AsyncTree */ -BI.PartTree = BI.inherit(BI.SyncTree, { +BI.PartTree = BI.inherit(BI.AsyncTree, { _defaultConfig: function () { return BI.extend(BI.PartTree.superclass._defaultConfig.apply(this, arguments), {}) }, @@ -2241,7 +2254,7 @@ BI.PartTree = BI.inherit(BI.SyncTree, { var name = this._getNodeValue(treeNode) // var values = parentValues.concat([name]); if (treeNode.checked === true) { - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA, @@ -2266,7 +2279,7 @@ BI.PartTree = BI.inherit(BI.SyncTree, { } } self.selectedValues = new_values; - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); } }, @@ -2777,6 +2790,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { _populate: function (items) { var o = this.options; + this._reRange(); if (items && items !== this.options.items) { this.options.items = items; this._calculateSizeAndPositionData(); @@ -2850,7 +2864,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { }, //重新计算children - reRange: function () { + _reRange: function () { this.renderRange = {}; }, @@ -14873,6 +14887,7 @@ BI.GridView = BI.inherit(BI.Widget, { _populate: function (items) { var self = this, o = this.options; + this._reRange(); if (items && items !== this.options.items) { this.options.items = items; } @@ -14961,7 +14976,7 @@ BI.GridView = BI.inherit(BI.Widget, { }, //重新计算children - reRange: function () { + _reRange: function () { this.renderRange = {}; }, @@ -28993,7 +29008,6 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return; } if (this._isNeedDigest === true) { - this._reRange(); this._digest(); } this._isNeedDigest = false; @@ -29091,13 +29105,6 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.bottomRightCollection.restore(); }, - _reRange: function () { - this.topLeftCollection.reRange(); - this.topRightCollection.reRange(); - this.bottomLeftCollection.reRange(); - this.bottomRightCollection.reRange(); - }, - restore: function () { this._restore(); } @@ -29710,10 +29717,6 @@ BI.GridTable = BI.inherit(BI.Widget, { if (this._width <= 0 || this._height <= 0) { return; } - if (this._isNeedDigest === true) { - this._reRange(); - this._isNeedDigest = false; - } this._populateTable(); this._populateScrollbar(); }, @@ -29789,13 +29792,11 @@ BI.GridTable = BI.inherit(BI.Widget, { populate: function (items, header) { if (items && this.options.items !== items) { - this._isNeedDigest = true; this.options.items = items; this.items = this._getItems(); this._restore(); } if (header && this.options.header !== header) { - this._isNeedDigest = true; this.options.header = header; this.header = this._getHeader(); this._restore(); @@ -29810,13 +29811,6 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid.restore(); }, - _reRange: function () { - this.topLeftGrid.reRange(); - this.topRightGrid.reRange(); - this.bottomLeftGrid.reRange(); - this.bottomRightGrid.reRange(); - }, - restore: function () { this._restore(); } diff --git a/docs/case.js b/docs/case.js index 2fcf3869ee..2a7f667cdb 100644 --- a/docs/case.js +++ b/docs/case.js @@ -7951,6 +7951,10 @@ BI.AllCountPager = BI.inherit(BI.Widget, { this.pager.setValue(v); }, + setVPage: function (v) { + this.pager.setValue(v); + }, + setCount: function (count) { this.rowCount.setText(count); this.rowCount.setTitle(count); diff --git a/docs/demo.js b/docs/demo.js index e7a4a5c0f7..f1787c8f12 100644 --- a/docs/demo.js +++ b/docs/demo.js @@ -2755,7 +2755,7 @@ BI.shortcut("demo.value_chooser_combo", Demo.ValueChooserCombo);Demo.BASE_CONFIG value: "demo.tree_view" }, { pId: 203, - text: "bi.sync_tree", + text: "bi.async_tree", value: "demo.sync_tree" }, { pId: 203, diff --git a/docs/polyfill.js b/docs/polyfill.js index 854ed288f6..f493c89a5e 100644 --- a/docs/polyfill.js +++ b/docs/polyfill.js @@ -4,7 +4,7 @@ if(![].indexOf){ * @param {Object} o 要检查的值 * @return {Number} o在数组中的索引(如果不在数组中则返回-1) */ - [].indexOf = function (o) { + Array.prototype.indexOf = function (o) { for (var i = 0, len = this.length; i < len; i++) { if (_.isEqual(o, this[i])) { return i; @@ -20,7 +20,7 @@ if(![].lastIndexOf){ * @param {Object} o 要检查的值 * @return {Number} o在数组中的索引(如果不在数组中则返回-1) */ - [].lastIndexOf = function (o) { + Array.prototype.lastIndexOf = function (o) { for (var len = this.length, i = len - 1; i >= 0; i--) { if (_.isEqual(o, this[i])) { return i; diff --git a/docs/widget.js b/docs/widget.js index 903504541b..55d86a401e 100644 --- a/docs/widget.js +++ b/docs/widget.js @@ -10957,17 +10957,17 @@ BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSe BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** * Created by zcf_1 on 2017/5/2. */ -BI.MultiStringList = BI.inherit(BI.Widget, { +BI.MultiSelectList = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.MultiStringList.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-string-list', + return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-list', itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, el: {} }) }, _init: function () { - BI.MultiStringList.superclass._init.apply(this, arguments); + BI.MultiSelectList.superclass._init.apply(this, arguments); var self = this, o = this.options; this.storeValue = {}; @@ -10978,7 +10978,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this.adapter = BI.createWidget({ type: "bi.multi_select_loader", - cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, // onLoaded: o.onLoaded, @@ -10990,7 +10990,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); }); }); @@ -11049,7 +11049,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { self._setStartValue(keyword); assertShowValue(); self._setStartValue(""); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); }) } else { self._showAdapter(); @@ -11150,7 +11150,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this._assertValue(this.storeValue); if (!this._allData) { o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_ALL_DATA + type: BI.MultiSelectList.REQ_GET_ALL_DATA }, function (ob) { self._allData = BI.pluck(ob.items, "value"); digest(self._allData); @@ -11174,7 +11174,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { var self = this, o = this.options; this._assertValue(res); o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_ALL_DATA, + type: BI.MultiSelectList.REQ_GET_ALL_DATA, keyword: self.trigger.getKeyword() }, function (ob) { var items = BI.pluck(ob.items, "value"); @@ -11211,7 +11211,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { var self = this, o = this.options; if (!this._count) { o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_DATA_LENGTH + type: BI.MultiSelectList.REQ_GET_DATA_LENGTH }, function (res) { self._count = res.count; adjust(); @@ -11294,13 +11294,214 @@ BI.MultiStringList = BI.inherit(BI.Widget, { } }); -BI.extend(BI.MultiStringList, { +BI.extend(BI.MultiSelectList, { REQ_GET_DATA_LENGTH: 0, REQ_GET_ALL_DATA: -1 }); -BI.MultiStringList.EVENT_CHANGE = "BI.MultiStringList.EVENT_CHANGE"; -BI.shortcut("bi.multi_string_list", BI.MultiStringList);/** +BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/** + * Created by zcf_1 on 2017/5/11. + */ +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 + }) + }, + + _init: function () { + BI.MultiSelectTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = {value: {}}; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_tree_popup", + itemsCreator: o.itemsCreator + }); + this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + }); + + this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.trigger.getKeyword(); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.trigger.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self.storeValue = {value: self.adapter.getValue()}; + self.searcherPane.setValue(self.storeValue); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + self.adapter.setValue(self.storeValue); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.trigger.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.trigger, + height: 30 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + height: "100%", + width: "100%", + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }) + + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + resize: function () { + + }, + + setValue: function (v) { + this.storeValue.value = v || {}; + this.adapter.setValue({ + value: v || {} + }); + this.trigger.setValue({ + value: v || {} + }); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.trigger.populate.apply(this.trigger, arguments); + this.adapter.populate.apply(this.adapter, arguments); + } +}); +BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** + * Created by zcf on 2016/12/21. + */ +BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom", + itemsCreator: BI.emptyFn + }); + }, + _init: function () { + BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popup = BI.createWidget({ + type: "bi.async_tree", + height: 400, + element: this, + itemsCreator: o.itemsCreator + }); + this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { + self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) + }); + this.popup.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) + }); + }, + + hasChecked: function () { + return this.popup.hasChecked(); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + v || (v = {}); + this.popup.setValue(v.value); + }, + + populate: function (config) { + this.popup.stroke(config); + } + +}); +BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; +BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/** * * @class BI.MultiTreeCheckPane * @extends BI.Pane @@ -11695,7 +11896,7 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, { this.selectedValues = {}; this.tree = BI.createWidget({ - type: "bi.sync_tree", + type: "bi.async_tree", height: 400, cls:"popup-view-tree", itemsCreator: opts.itemsCreator, @@ -12039,208 +12240,7 @@ BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** - * Created by zcf_1 on 2017/5/11. - */ -BI.MultiSelectTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', - itemsCreator: BI.emptyFn, - height: 25 - }) - }, - - _init: function () { - BI.MultiSelectTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = {value: {}}; - - this.adapter = BI.createWidget({ - type: "bi.multi_select_tree_popup", - itemsCreator: o.itemsCreator - }); - this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { - if (self.trigger.isSearching()) { - self.storeValue = {value: self.searcherPane.getValue()}; - } else { - self.storeValue = {value: self.adapter.getValue()}; - } - self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); - }); - - this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样 - type: "bi.multi_tree_search_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - keywordGetter: function () { - return self.trigger.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keyword = self.trigger.getKeyword(); - o.itemsCreator(op, callback); - } - }); - this.searcherPane.setVisible(false); - - this.trigger = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback({ - keyword: self.trigger.getKeyword() - }); - }, - adapter: this.adapter, - popup: this.searcherPane, - height: 200, - masker: false, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - self.storeValue = {value: self.adapter.getValue()}; - self.searcherPane.setValue(self.storeValue); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - // self.storeValue = {value: self.searcherPane.getValue()}; - self.adapter.setValue(self.storeValue); - BI.nextTick(function () { - self.adapter.populate(); - }); - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function () { - if (self.trigger.isSearching()) { - self.storeValue = {value: self.searcherPane.getValue()}; - } else { - self.storeValue = {value: self.adapter.getValue()}; - } - self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - self._showAdapter(); - } - }] - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - height: "100%", - width: "100%", - items: [{ - el: this.trigger, - height: 30 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - height: "100%", - width: "100%", - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }) - - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - resize: function () { - - }, - - setValue: function (v) { - this.storeValue.value = v || {}; - this.adapter.setValue({ - value: v || {} - }); - this.trigger.setValue({ - value: v || {} - }); - }, - - getValue: function () { - return this.storeValue.value; - }, - - populate: function () { - this.trigger.populate.apply(this.trigger, arguments); - this.adapter.populate.apply(this.adapter, arguments); - } -}); -BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** - * Created by zcf on 2016/12/21. - */ -BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", - itemsCreator: BI.emptyFn - }); - }, - _init: function () { - BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.popup = BI.createWidget({ - type: "bi.sync_tree", - height: 400, - element: this, - itemsCreator: o.itemsCreator - }); - this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT) - }); - this.popup.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE) - }); - }, - - hasChecked: function () { - return this.popup.hasChecked(); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - v || (v = {}); - this.popup.setValue(v.value); - }, - - populate: function (config) { - this.popup.stroke(config); - } - -}); -BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; -BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1 +BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);//小于号的值为:0,小于等于号的值为:1 //closeMIn:最小值的符号,closeMax:最大值的符号 /** * Created by roy on 15/9/17. @@ -15964,6 +15964,7 @@ BI.SequenceTableListNumber = BI.inherit(BI.Widget, { }, setVPage: function (v) { + v = v < 1 ? 1 : v; var o = this.options; this.start = (v - 1) * o.pageSize + 1; }, diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index 1b03201872..d359668a56 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -267,6 +267,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { _populate: function (items) { var o = this.options; + this._reRange(); if (items && items !== this.options.items) { this.options.items = items; this._calculateSizeAndPositionData(); @@ -340,7 +341,7 @@ BI.CollectionView = BI.inherit(BI.Widget, { }, //重新计算children - reRange: function () { + _reRange: function () { this.renderRange = {}; }, diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index 92798e55b8..c76f354c75 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -223,6 +223,7 @@ BI.GridView = BI.inherit(BI.Widget, { _populate: function (items) { var self = this, o = this.options; + this._reRange(); if (items && items !== this.options.items) { this.options.items = items; } @@ -311,7 +312,7 @@ BI.GridView = BI.inherit(BI.Widget, { }, //重新计算children - reRange: function () { + _reRange: function () { this.renderRange = {}; }, diff --git a/src/base/single/button/button.basic.js b/src/base/single/button/button.basic.js index 80b513862d..8e1079af03 100644 --- a/src/base/single/button/button.basic.js +++ b/src/base/single/button/button.basic.js @@ -198,7 +198,7 @@ BI.BasicButton = BI.inherit(BI.Single, { }); //之后的300ms点击无效 - var onClick = BI.debounce(this.doClick, BI.EVENT_RESPONSE_TIME, true); + var onClick = BI.debounce(this._doClick, BI.EVENT_RESPONSE_TIME, true); function ev(e) { if (o.stopEvent) { @@ -220,6 +220,11 @@ BI.BasicButton = BI.inherit(BI.Single, { _trigger: function () { var o = this.options; + if (!this.isDisableSelected()) { + this.isForceSelected() ? this.setSelected(true) : + (this.isForceNotSelected() ? this.setSelected(false) : + this.setSelected(!this.isSelected())); + } if (this.isValid()) { o.handler.call(this, this.getValue(), this); var v = this.getValue(); @@ -228,13 +233,15 @@ BI.BasicButton = BI.inherit(BI.Single, { } }, - doClick: function () { - if (!this.isDisableSelected()) { - this.isForceSelected() ? this.setSelected(true) : - (this.isForceNotSelected() ? this.setSelected(false) : - this.setSelected(!this.isSelected())); - } + _doClick: function () { this._trigger(); + if (this.isValid()) { + this.doClick(); + } + }, + + doClick: function () { + }, handle: function () { diff --git a/src/base/table/table.collection.js b/src/base/table/table.collection.js index dd31c1cc05..63da1b9914 100644 --- a/src/base/table/table.collection.js +++ b/src/base/table/table.collection.js @@ -429,7 +429,6 @@ BI.CollectionTable = BI.inherit(BI.Widget, { return; } if (this._isNeedDigest === true) { - this._reRange(); this._digest(); } this._isNeedDigest = false; @@ -527,13 +526,6 @@ BI.CollectionTable = BI.inherit(BI.Widget, { this.bottomRightCollection.restore(); }, - _reRange: function () { - this.topLeftCollection.reRange(); - this.topRightCollection.reRange(); - this.bottomLeftCollection.reRange(); - this.bottomRightCollection.reRange(); - }, - restore: function () { this._restore(); } diff --git a/src/base/table/table.grid.js b/src/base/table/table.grid.js index 0746479242..7454fafd29 100644 --- a/src/base/table/table.grid.js +++ b/src/base/table/table.grid.js @@ -357,10 +357,6 @@ BI.GridTable = BI.inherit(BI.Widget, { if (this._width <= 0 || this._height <= 0) { return; } - if (this._isNeedDigest === true) { - this._reRange(); - this._isNeedDigest = false; - } this._populateTable(); this._populateScrollbar(); }, @@ -436,13 +432,11 @@ BI.GridTable = BI.inherit(BI.Widget, { populate: function (items, header) { if (items && this.options.items !== items) { - this._isNeedDigest = true; this.options.items = items; this.items = this._getItems(); this._restore(); } if (header && this.options.header !== header) { - this._isNeedDigest = true; this.options.header = header; this.header = this._getHeader(); this._restore(); @@ -457,13 +451,6 @@ BI.GridTable = BI.inherit(BI.Widget, { this.bottomRightGrid.restore(); }, - _reRange: function () { - this.topLeftGrid.reRange(); - this.topRightGrid.reRange(); - this.bottomLeftGrid.reRange(); - this.bottomRightGrid.reRange(); - }, - restore: function () { this._restore(); } diff --git a/src/base/tree/synctree.js b/src/base/tree/asynctree.js similarity index 91% rename from src/base/tree/synctree.js rename to src/base/tree/asynctree.js index 7aa8bbf2d4..96f9c900df 100644 --- a/src/base/tree/synctree.js +++ b/src/base/tree/asynctree.js @@ -1,15 +1,15 @@ /** * guy * 同步树 - * @class BI.SyncTree + * @class BI.AsyncTree * @extends BI.TreeView */ -BI.SyncTree = BI.inherit(BI.TreeView, { +BI.AsyncTree = BI.inherit(BI.TreeView, { _defaultConfig: function () { - return BI.extend(BI.SyncTree.superclass._defaultConfig.apply(this, arguments), {}) + return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {}) }, _init: function () { - BI.SyncTree.superclass._init.apply(this, arguments); + BI.AsyncTree.superclass._init.apply(this, arguments); }, //配置属性 @@ -79,7 +79,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } function beforeExpand(treeId, treeNode) { - self._expandNode(treeId, treeNode); + self._beforeExpandNode(treeId, treeNode); } function onCheck(event, treeId, treeNode) { @@ -100,7 +100,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { _selectTreeNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); - var name = this._getNodeValue(treeNode) + var name = this._getNodeValue(treeNode); // var values = parentValues.concat([name]); if (treeNode.checked === true) { } else { @@ -119,11 +119,11 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } } } - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }, //展开节点 - _expandNode: function (treeId, treeNode) { + _beforeExpandNode: function (treeId, treeNode) { var self = this, o = this.options; var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var op = BI.extend({}, o.paras, { @@ -178,7 +178,7 @@ BI.SyncTree = BI.inherit(BI.TreeView, { }, hasChecked: function () { - return !BI.isEmpty(this.selectedValues) || BI.SyncTree.superclass.hasChecked.apply(this, arguments); + return !BI.isEmpty(this.selectedValues) || BI.AsyncTree.superclass.hasChecked.apply(this, arguments); }, getValue: function () { @@ -206,4 +206,4 @@ BI.SyncTree = BI.inherit(BI.TreeView, { } }); -BI.shortcut("bi.sync_tree", BI.SyncTree); \ No newline at end of file +BI.shortcut("bi.async_tree", BI.AsyncTree); \ No newline at end of file diff --git a/src/base/tree/parttree.js b/src/base/tree/parttree.js index a3f809cdde..e75cce7a05 100644 --- a/src/base/tree/parttree.js +++ b/src/base/tree/parttree.js @@ -2,9 +2,9 @@ * guy * 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点 * @class BI.PartTree - * @extends BI.SyncTree + * @extends BI.AsyncTree */ -BI.PartTree = BI.inherit(BI.SyncTree, { +BI.PartTree = BI.inherit(BI.AsyncTree, { _defaultConfig: function () { return BI.extend(BI.PartTree.superclass._defaultConfig.apply(this, arguments), {}) }, @@ -43,7 +43,7 @@ BI.PartTree = BI.inherit(BI.SyncTree, { var name = this._getNodeValue(treeNode) // var values = parentValues.concat([name]); if (treeNode.checked === true) { - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); } else { o.itemsCreator(BI.extend({}, o.paras, { type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA, @@ -68,7 +68,7 @@ BI.PartTree = BI.inherit(BI.SyncTree, { } } self.selectedValues = new_values; - BI.SyncTree.superclass._selectTreeNode.apply(self, arguments); + BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); }); } }, diff --git a/src/base/tree/treeview.js b/src/base/tree/treeview.js index 8c0762c292..204d5936a2 100644 --- a/src/base/tree/treeview.js +++ b/src/base/tree/treeview.js @@ -469,6 +469,12 @@ BI.TreeView = BI.inherit(BI.Pane, { }); }, + getExpandedValue: function(){ + if (!this.nodes) { + return null; + } + }, + refresh: function () { this.nodes && this.nodes.refresh(); }, diff --git a/src/case/pager/pager.all.count.js b/src/case/pager/pager.all.count.js index fee63982f9..5a029ca75f 100644 --- a/src/case/pager/pager.all.count.js +++ b/src/case/pager/pager.all.count.js @@ -132,6 +132,10 @@ BI.AllCountPager = BI.inherit(BI.Widget, { this.pager.setValue(v); }, + setVPage: function (v) { + this.pager.setValue(v); + }, + setCount: function (count) { this.rowCount.setText(count); this.rowCount.setTitle(count); diff --git a/src/less/widget/multistringlist/multistringlist.less b/src/less/widget/multistringlist/multistringlist.less index 4610336cf8..7511c12009 100644 --- a/src/less/widget/multistringlist/multistringlist.less +++ b/src/less/widget/multistringlist/multistringlist.less @@ -1,5 +1,5 @@ @import "../../bibase"; -.bi-multi-string-list{ - & .popup-multi-string-list{ +.bi-multi-select-list{ + & .popup-multi-select-list{ } } \ No newline at end of file diff --git a/src/polyfill/array.js b/src/polyfill/array.js index 65f018588c..5dadd1588a 100644 --- a/src/polyfill/array.js +++ b/src/polyfill/array.js @@ -4,7 +4,7 @@ if(![].indexOf){ * @param {Object} o 要检查的值 * @return {Number} o在数组中的索引(如果不在数组中则返回-1) */ - [].indexOf = function (o) { + Array.prototype.indexOf = function (o) { for (var i = 0, len = this.length; i < len; i++) { if (_.isEqual(o, this[i])) { return i; @@ -20,7 +20,7 @@ if(![].lastIndexOf){ * @param {Object} o 要检查的值 * @return {Number} o在数组中的索引(如果不在数组中则返回-1) */ - [].lastIndexOf = function (o) { + Array.prototype.lastIndexOf = function (o) { for (var len = this.length, i = len - 1; i >= 0; i--) { if (_.isEqual(o, this[i])) { return i; diff --git a/src/widget/multistringlist/multistringlist.js b/src/widget/multiselectlist/multiselectlist.js similarity index 93% rename from src/widget/multistringlist/multistringlist.js rename to src/widget/multiselectlist/multiselectlist.js index f1783428da..4913c7e410 100644 --- a/src/widget/multistringlist/multistringlist.js +++ b/src/widget/multiselectlist/multiselectlist.js @@ -1,17 +1,17 @@ /** * Created by zcf_1 on 2017/5/2. */ -BI.MultiStringList = BI.inherit(BI.Widget, { +BI.MultiSelectList = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.MultiStringList.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-string-list', + return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: 'bi-multi-select-list', itemsCreator: BI.emptyFn, valueFormatter: BI.emptyFn, el: {} }) }, _init: function () { - BI.MultiStringList.superclass._init.apply(this, arguments); + BI.MultiSelectList.superclass._init.apply(this, arguments); var self = this, o = this.options; this.storeValue = {}; @@ -22,7 +22,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this.adapter = BI.createWidget({ type: "bi.multi_select_loader", - cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, // onLoaded: o.onLoaded, @@ -34,7 +34,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { self.storeValue = this.getValue(); self._adjust(function () { assertShowValue(); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); }); }); @@ -93,7 +93,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { self._setStartValue(keyword); assertShowValue(); self._setStartValue(""); - self.fireEvent(BI.MultiStringList.EVENT_CHANGE); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); }) } else { self._showAdapter(); @@ -194,7 +194,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { this._assertValue(this.storeValue); if (!this._allData) { o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_ALL_DATA + type: BI.MultiSelectList.REQ_GET_ALL_DATA }, function (ob) { self._allData = BI.pluck(ob.items, "value"); digest(self._allData); @@ -218,7 +218,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { var self = this, o = this.options; this._assertValue(res); o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_ALL_DATA, + type: BI.MultiSelectList.REQ_GET_ALL_DATA, keyword: self.trigger.getKeyword() }, function (ob) { var items = BI.pluck(ob.items, "value"); @@ -255,7 +255,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, { var self = this, o = this.options; if (!this._count) { o.itemsCreator({ - type: BI.MultiStringList.REQ_GET_DATA_LENGTH + type: BI.MultiSelectList.REQ_GET_DATA_LENGTH }, function (res) { self._count = res.count; adjust(); @@ -338,10 +338,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, { } }); -BI.extend(BI.MultiStringList, { +BI.extend(BI.MultiSelectList, { REQ_GET_DATA_LENGTH: 0, REQ_GET_ALL_DATA: -1 }); -BI.MultiStringList.EVENT_CHANGE = "BI.MultiStringList.EVENT_CHANGE"; -BI.shortcut("bi.multi_string_list", BI.MultiStringList); \ No newline at end of file +BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_list", BI.MultiSelectList); \ No newline at end of file diff --git a/src/widget/multitreelist/multitreelist.js b/src/widget/multiselecttree/multiselecttree.js similarity index 97% rename from src/widget/multitreelist/multitreelist.js rename to src/widget/multiselecttree/multiselecttree.js index 2403eac14a..4475e433e2 100644 --- a/src/widget/multitreelist/multitreelist.js +++ b/src/widget/multiselecttree/multiselecttree.js @@ -4,7 +4,7 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: 'bi-multi-tree-combo', + baseCls: 'bi-multi-select-tree', itemsCreator: BI.emptyFn, height: 25 }) diff --git a/src/widget/multitreelist/multitreelist.popup.js b/src/widget/multiselecttree/multiselecttree.popup.js similarity index 91% rename from src/widget/multitreelist/multitreelist.popup.js rename to src/widget/multiselecttree/multiselecttree.popup.js index 864137a9c6..8f8ee61b2e 100644 --- a/src/widget/multitreelist/multitreelist.popup.js +++ b/src/widget/multiselecttree/multiselecttree.popup.js @@ -4,7 +4,7 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { _defaultConfig: function () { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", + baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom", itemsCreator: BI.emptyFn }); }, @@ -12,7 +12,7 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); var self = this, o = this.options; this.popup = BI.createWidget({ - type: "bi.sync_tree", + type: "bi.async_tree", height: 400, element: this, itemsCreator: o.itemsCreator diff --git a/src/widget/multitree/multi.tree.popup.js b/src/widget/multitree/multi.tree.popup.js index e8c5cded0e..349779d23a 100644 --- a/src/widget/multitree/multi.tree.popup.js +++ b/src/widget/multitree/multi.tree.popup.js @@ -23,7 +23,7 @@ BI.MultiTreePopup = BI.inherit(BI.Pane, { this.selectedValues = {}; this.tree = BI.createWidget({ - type: "bi.sync_tree", + type: "bi.async_tree", height: 400, cls:"popup-view-tree", itemsCreator: opts.itemsCreator, diff --git a/src/widget/sequencetable/listnumber.sequencetable.js b/src/widget/sequencetable/listnumber.sequencetable.js index bab51144ab..94e2882339 100644 --- a/src/widget/sequencetable/listnumber.sequencetable.js +++ b/src/widget/sequencetable/listnumber.sequencetable.js @@ -211,6 +211,7 @@ BI.SequenceTableListNumber = BI.inherit(BI.Widget, { }, setVPage: function (v) { + v = v < 1 ? 1 : v; var o = this.options; this.start = (v - 1) * o.pageSize + 1; },